I'm porting an existing (very basic) shadow map implementation from an XNA project over to one based on OpenGL and I'm getting the following, wrong result. Can anyone venture a guess as to what's going wrong? Something with the projected texture coordinates I suppose, but I can't figure out what.
There's supposed to be a single spotlight casting the shadow, located just in front of the camera and pointing in the view direction.
What's wrong with this picture? (shadow mapping problem)
Looks like your texture is up-side-down from what you expect ;)
OpenGL texture coordinates are up-side-down compared to DirectX coordinates. Assuming you're using shaders, a quick fix is to add "texCoord.y = 1.0-texCoord.y" right before you sample the projected shadow map.
OpenGL texture coordinates are up-side-down compared to DirectX coordinates. Assuming you're using shaders, a quick fix is to add "texCoord.y = 1.0-texCoord.y" right before you sample the projected shadow map.
I tried that already actually, then I can't see any shadows at all. If I invert both x and y coordinates then I get the following result. The shadows are offset incorrectly in the x-direction now, and silhouettes are standing right next to the objects casting them. It looks like something is wrong with the light projection matrix or something, like the depths are inverted?
It looks as if your light source is being projected from the same location as your shadows, in which case, the shadows are going to be behind hidden behind the objects casting them... which means that part of it is correct.
Is the light supposed to originate from somewhere else?
Is the light supposed to originate from somewhere else?
I'm not sure I understand... the light is supposed to be right in front of the camera, facing in the look direction, sort of like a flashlight. If I remove that x-flip in the texture coordinates that I mentioned, then the shadows shown in the screen shot disappear because they're behind the objects, which is correct. But the question is why aren't any pixels farther back, such as on the wall, in the shadow?
I'm using deferred rendering for this (and the original XNA code was not) and drawing the lights as full screen quads, would that be introducing some complication I'm not aware of?
I'm using deferred rendering for this (and the original XNA code was not) and drawing the lights as full screen quads, would that be introducing some complication I'm not aware of?
You mentioned: shadows disappear (will be behind the casters), so I don't understand what the problem is.
Hmmm... I put the light in a fixed position, so it doesn't move with the camera and it seems to be casting proper shadows now.
I just tried walking around, pointing a flashlight from eye-level and it is pretty difficult to get anything to cast a shadow... I guess you learn something new about the world every day :)
I just tried walking around, pointing a flashlight from eye-level and it is pretty difficult to get anything to cast a shadow... I guess you learn something new about the world every day :)
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement