I’ve noticed that my projective texture shader produces artifacts due to z-fighting on my uber “Mobile Intel® 4 Series Express Chipset Family” GPU.
Since shadow mapping is similar, I tested if the problem also occurs with TestPssmShadow and it does.
I managed to solve this issue either in the SceneProcessor like this
[java]
textureMat = new Material(assetManager, “Common/MatDefs/Misc/ProjectiveTextureMapping1pass.j3md”);
textureMat.getAdditionalRenderState().setPolyOffset(-1f, -1f); // prevent z-fighting
[/java]
or in the corresponding vertex shader like this
[java]
gl_Position = g_WorldViewProjectionMatrix * vec4(inPosition, 1.0);
// prevent z-fighting
gl_Position.z *= 0.99999;
gl_Position.z -= 0.00001;
[/java]
Has anyone experience with this and can tell me which method is preferable? Also, does it have any impacts or side effects? Is it Intel GPU’s fault or do the other GPUs just circumvent this issue? I also wonder if it’s possible to get rid of these ugly transition from shadow to light on the sphere surface in “TestPssmShadow”. My “TestProjectiveTextureMapping” does something similar and doesn’t show such fringes.