Hello, I am currently have an issue with the fluid/water mesh in my voxel engine.
I have tired pretty much everything I can outline on this page:
Here is what the issue looks like:
When the chunk mesh overlaps with its neighbor it looks fine but when it overlaps with itself it is culling the faces behind creating a kind of grid like pattern.
I am using a custom ShaderMaterial for the mesh and this is how I create it:
const shaderMaterial = new BABYLON.ShaderMaterial("fluid", scene, "fluid", {
attributes: [
"position",
"normal",
"cuv3",
"colors",
"rgbLightColors",
"sunLightColors",
],
uniforms: [
"world",
"view",
"viewProjection",
"worldView",
"worldMatrix",
"worldViewProjection",
"vFogInfos",
"vFogColor",
"sunLightLevel",
"baseLevel",
"projection",
"arrayTex",
"doSun",
"doRGB",
"doColor",
"time",
...animData.uniforms,
],
needAlphaBlending: true,
needAlphaTesting: false,
});
shaderMaterial.needDepthPrePass = true;
shaderMaterial.separateCullingPass = true;
shaderMaterial.backFaceCulling = false;
And this is the simply fragment shader:
vec4 rgb = texture(arrayTex, vec3(vUV.x,vUV.y,animIndex)) ;
if (rgb.w < 0.5) {
discard;
}
rgb = getColor(rgb);
vec4 mixLight = getLight(rgb);
vec3 finalColor = doFog(mixLight);
gl_FragColor = vec4(finalColor.rgb , rgb.w );
I have tired pretty much everything I could think of and have been searching the internet for a while for answers.
Does anybody know what is going on and how I could fix it?