Hi! I pass matrices to a shader with uniforms and when I print the values on the gpu they are different at each frames but I they don’t change on the CPU thus some pixels are flickering.
On this fact some values are incorrect for exemple the z value for some pixels of my shadow are greater than the ones of my depthtexture or they are behing it and I don’t understand why.
you can find the source code of my shaders here :
https://github.com/LaurentDuroisin7601/ODFAEG/blob/master/ODFAEG/src/odfaeg/Graphics/shadowRenderCompoenent.cpp
Thanks.
Hi! I’m trying to do a dephtTest to test if there is something between my shadows and the camera, but the result is strange :
https://www.youtube.com/watch?v=p9QyER3tGBI
When I simply write the zvalue to a texture with a depthTest it works, so I guess the problem is with the image I use, it doesn’t read what was writting before. So my shadow pixels are flickering. And I don’t know how to synchronize this I used memoryBarrier function but that doesn’t work.
Ok I’ve found the problem, I just have to use interlock and now the z values on my depthText are good.
const std::string buildDepthBufferFragmentShader = R"(#version 460
#extension GL_ARB_bindless_texture : enable
#extension GL_ARB_fragment_shader_interlock : require
in vec4 frontColor;
in vec2 fTexCoords;
in flat uint texIndex;
in flat uint layer;
layout(std140, binding=0) uniform ALL_TEXTURES {
sampler2D textures[200];
};
layout(binding = 0, rgba32f) uniform image2D depthBuffer;
layout (location = 0) out vec4 fColor;
void main () {
vec4 texel = (texIndex != 0) ? frontColor * texture2D(textures[texIndex-1], fTexCoords.xy) : frontColor;
float z = gl_FragCoord.z;
float l = layer;
beginInvocationInterlockARB();
vec4 depth = imageLoad(depthBuffer,ivec2(gl_FragCoord.xy));
if (/*l > depth.y || l == depth.y &&*/ z > depth.z) {
fColor = vec4(0, l, z, texel.a);
imageStore(depthBuffer,ivec2(gl_FragCoord.xy),vec4(0,l,z,texel.a));
memoryBarrier();
} else {
fColor = depth;
}
endInvocationInterlockARB();
}
)";