Shadow map is not filled properly

Hello. I am implementing shadow mapping using LWJGL, but for some reason the shadow map is filled in a really weird, low quality way.

The rectangle in bottom-left corner is the shadow map drawn from same position and direction as the camera. It seems like it’s filled with a binary 1 or 0 value instead of the z and even though the shadow map is 1024x1024 I can see the gaps between triangles, which is weird.

Also for some reason the texture does not update. By that I mean that if I eg. add glClear(DEPTH_BUFFER_BIT) before drawing to shadow map, the whole texture just turns white. So for some reason the texture is drawn to only once although I made sure I draw the models each frame.

I decided not to post any code here because it’s all split into bunch of files and I’m not exactly sure what part could be causing this, but if this is not some kind of “forgot to turn on a flag” error which I’m hoping it to be I can post some code.

Edit: here’s the probably most relevant class ShadowMapFBO: http://pastebin.java-gaming.org/109458f762111

Edit2: Turns out I forgot to set depth func back to GL_LESS after some operations. Caffeine is the best debugging tool :slight_smile: