Hi, we are working with a custom PBR shader that uses shader chunks. We have some models that have mirrored UVs, and it seems like the glossiness or metalness are rendering in a weird way, like they are not getting mirrored at all. Are we missing something in out configuration?
this.chunks = {
uv0VS: `
uniform vec2 offset;
uniform float tiling;
#ifdef INSTANCING
//attribute vec3 vertex_attribute16;
//varying vec3 vInstanceEmissive;
#endif
vec2 getUv0 (){
#ifdef INSTANCING
//vInstanceEmissive = vertex_attribute16;
#endif
return (vertex_texCoord0 + offset) * tiling;
}
`,
normalPS: `
uniform sampler2D texture_normalMap;
uniform float material_bumpiness;
void getNormal() {
vec3 normalMap = unpackNormal(texture2D(texture_normalMap, vUv0, textureBias));
normalMap = mix(vec3(0.0, 0.0, 1.0), normalMap, material_bumpiness);
dNormalW = normalize(dTBN * addNormalDetail(normalMap));
}
`,
diffusePS: `
uniform vec3 material_diffuse;
uniform sampler2D texture_diffuseMap;
uniform vec4 uColorParams; //x static bool, y: contrast, z: bright, w: hue
vec3 hueShift(vec3 color, float h) {
const vec3 k = vec3 (0.57735);
float cosHue = cos(h);
return color * cosHue + cross(k, color) * sin(h) + k * dot(k, color) * (1.0 - cosHue);
}
void getAlbedo() {
dAlbedo = texture2D(texture_diffuseMap, vUv0).rgb;
if(uColorParams.x > 0.5){
dAlbedo *= material_diffuse;
dAlbedo = (dAlbedo + uColorParams.z - 0.5) * max(uColorParams.y + 1.0, 0.0) + 0.5;
dAlbedo = hueShift(dAlbedo,uColorParams.w);
}
}
`,
metalnessPS: `
uniform sampler2D texture_metalnessMap;
uniform float metalness;
void getMetalness() {
dMetalness = texture2D(texture_metalnessMap, vUv0 ).b;
dMetalness *= metalness;
}
`,
glossPS: `
uniform sampler2D texture_glossMap;
uniform vec4 roughChanges; //x static bool, y: black z:white w:contrast
void getGlossiness() {
dGlossiness = 1.0;
dGlossiness *= texture2D(texture_glossMap, (vUv0)).g;
\\ if(roughChanges.x > 0.5){
dGlossiness = mix(roughChanges.y,roughChanges.z,dGlossiness);
dGlossiness *= roughChanges.z;
}
dGlossiness = 1.0 - dGlossiness;
}
`, emissivePS: `
uniform float material_emissiveIntensity;
uniform vec3 emmisiveColor;
uniform float uTime;
uniform vec2 speedEm;
uniform float fresnVal;
uniform sampler2D texture_emissiveMap;
uniform vec3 uEmissiveConfig; //x mask y fresnel z hasmask
#ifdef INSTANCING
//varying vec3 vInstanceEmissive;
#endif
void getEmission() {
vec3 finalColor = emmisiveColor;
#ifdef INSTANCING
//finalColor = vInstanceEmissive;
#endif
dEmission = finalColor * 0.0;
if(uEmissiveConfig.x > 0.5){
if(uEmissiveConfig.z > 0.5){
//dEmission = texture2D(texture_emissiveMap, vUv0).rgb;
float mask = texture2D(texture_emissiveMap, (vUv0+(speedEm*uTime))).r;
dEmission = vec3(mask);
}else{
dEmission = vec3(1.0);
}
dEmission *= finalColor * material_emissiveIntensity;
if(speedEm.x == 0.0 && speedEm.y == 0.0){
dEmission = mix(dEmission, vec3(0.0), sin(uTime*4.0)); //BETY Aqui esta la speed
}
};
if(uEmissiveConfig.y > 0.5){
float fresnel = 1.0 - max(dot(dNormalW, dViewDirW), fresnVal);
fresnel *= fresnel*0.5;
dEmission += finalColor * fresnel * material_emissiveIntensity; //AT
dEmission = mix(dEmission, vec3(0.0), sin(uTime*2.0));
};
}
`, aoPS: `
uniform sampler2D texture_aoMap;
void getAO() {
dAo = texture2D(texture_aoMap, vUv0 ).r;
dAo = dAo*3.0;
}
`
};
