shadow mapping problem
But the result is not as expected
Well, what is expected and what is the result ? Some hints or a screenshot would be helpful.
I've updated the question with the pictures where the problem is.
it doesn't matter if it is gldrawbuffer(gl_none) or whatever, the result is the same. So I don't know what's point of asking about it.
It really doesn't matter. If it does, it will surely change something.
why you set gldrawbuffer to gl_none?
Because that's what the spec says. This dates back to the totally incomprehensible specification of EXT_framebuffer_object1, but can also found in the (slightly less obnoxious) wording of the core specification, which states that the initial value for application-generated framebuffers is COLOR_ATTACHMENT0 (which will write color), and only COLOR_ATTACHMENTi or NONE are allowable, otherwise INVALID_OPERATION is generated.
The OP wants to render depth-only, and the framebuffer has no color attachments, so although it would probably work anyway without that glDrawBuffer(GL_NONE), this is "strictly correct".
Not like it makes any sense that you should have to do this (there's no color attachment after all, so it should be pretty clear to OpenGL that no color writes can possibly, or should happen), but pedantically adhering to the wording of the spec, you must do it.
[hr]
1Why, just why do specifications always have to be written in a way so you need to read them 20 times until you understand them?
it's hard to say for sure, but it looks like your shadowmap mvp may be wrong during the 2nd pass.. the first picture shadow projected on the object looks really suspect.
To debug this, try shifting one of the values, such as adding 0.2 to shadowcoord.x, and see what it does to the shadow.
Not even necessarily as a measure of pedenticallity…ious…ness…—if you don’t, it may work on one machine and not another.but pedantically adhering to the wording of the spec, you must do it.
This is the true evil of the lax adherence to standards. NVIDIA is the cause of many headaches in the world of OpenGL shaders for the same reason.
L. Spiro
change depth tex resolution to 512x512, change projection matrix, allpy that to the world 512 / 512 means aspect ratio 1.0