Hey there,
Im using diffuseTexture on standard material for texture and when i add texture then mesh will have black color background and i tried Fragment_Custom_Alpha but its not working.
By the way i’m implementing in React App.
Welcome aboard!
Is your material an instance of CustomMaterial
and not StandardMaterial
?
If you can make a repro in the Playground it will be easier to help you.
Hi @Evgeni_Popov , Thanks for response.
It works fine in pg but in React app, not able to achive same output, This is source code i have in React app.
var mat = new BABYLON.CustomMaterial("mat", scene);
mat.diffuseTexture = new BABYLON.Texture(textureImage, scene, false, false);
materialedMeshes.forEach(mesh => mesh.material = mat);
mat.emissiveColor = new BABYLON.Color3(1, 1, 1);
// mat.diffuseColor = new BABYLON.Color3(1, 0, 1);
// mat.specularColor = new BABYLON.Color3(0.5, 0.6, 0.87);
// mat.emissiveColor = new BABYLON.Color3(1, 1, 1);
// mat.ambientColor = new BABYLON.Color3(0.23, 0.98, 0.53);
mat.diffuseTexture.uOffset = -0.1000;
mat.diffuseTexture.vOffset = -1.1800;
mat.diffuseTexture.uScale = 1.2200;
mat.diffuseTexture.vScale = 2.2200;
mat.diffuseTexture.uAng = Math.PI;
mat.diffuseTexture.wrapU = BABYLON.Constants.TEXTURE_CLAMP_ADDRESSMODE;
mat.diffuseTexture.wrapV = BABYLON.Constants.TEXTURE_CLAMP_ADDRESSMODE;
mat.Fragment_Custom_Alpha(`
if (baseColor.r == 0. && baseColor.g == 0. && baseColor.b == 0.) {
baseColor.rgb = vec3(0.85, 0.85, 0.85);
}
baseColor.rgb = mix(vec3(0.85, 0.85, 0.85), baseColor.rgb, baseColor.a);
`);
@NinjaGamer Try with this. Im not sure how it should be used in React but in pg it works.
mat.Fragment_Custom_Diffuse(`
vec2 updatedUV = vDiffuseUV + uvOffset;
if (updatedUV.x < 0.0 || updatedUV.x > 1.0 || updatedUV.y < 0.0 || updatedUV.y > 1.0) {
baseColor.rgb = vec3(0.25, 0.85, 0.75);
}
`);
Hello @NinjaGamer just checking in if you’re still having issues?