Skip to main content
34 events
when toggle format what by license comment
Jun 5, 2011 at 19:26 comment added Maik Semder Anytime @Olhovsky :)
Jun 5, 2011 at 19:16 comment added Olhovsky Hmm, although I guess I can create a matrix that is the inverse of the view matrix multiplied by the light matrix.. then I only have to do one multiplication by that matrix, which is equivalent to the other way anyway! I hope this works :) Thanks Maik, +1 for talking this through with me.
Jun 5, 2011 at 19:14 comment added Olhovsky Perhaps yes, but this computation will then be done millions of times per frame. If I don't have to do that multiplication, that would be better. I guess I'll try that for now, and see if I can just get it working first :)
Jun 5, 2011 at 8:48 comment added Maik Semder Then a transformation with the inverse of the camera-matrix should do it and you should have it in world-space, right?
Jun 5, 2011 at 5:21 comment added Olhovsky I think I discovered what the problem is. I was treating pos as the world space position of the pixel, after this line float3 pos = float3(TanAspect*(screenPos*2 - 1)*depthValue, -depthValue); in the function PointLightMeshShadowPS, but actually this is the position of the pixel in the camera's view space. I'm not sure how to fix this yet.
Jun 5, 2011 at 2:03 comment added Olhovsky In short, the paraboloid projection is a copy-paste of the DPM paper's code. It works. The problem is figuring out how to set it up to work with deferred rendering. I have displayed how a spot light with shadows is done in the deferred set up, in the question. And we can see how a point light is done using forward rendering. This should be enough to figure out how to implement the point light with deferred rendering.
Jun 5, 2011 at 1:57 comment added Olhovsky I was trying to point out that the paraboloid projection is built into the other parts of the code, you can't isolate it and test "paraboloid projection" by itself easily. If I remove the paraboloid projection, that won't tell me anything useful. Even if I used a planar projection for the point light shadow, how do I know which shadow map to sample from (there's two, one per hemisphere), and how would I know what a "correct" result looks like? You'd be wrapping a single plane (that is meant to represent a hemisphere) around a sphere.
Jun 4, 2011 at 22:35 comment added Maik Semder I will check that part here tomorrow
Jun 4, 2011 at 22:33 comment added Maik Semder It will tell you whether the bug is in that part of the code or not. But I didn't know you were already sure that the problem is there. However, if you are sure I would take that piece of code and investigate it in a simPle test app, completely without shaders and other stuff, only checking if the projection works as expected, plus it has the nice side effect to understand that part better.
Jun 4, 2011 at 22:21 comment added Olhovsky If you look at the ~10 lines of shadow code, you'll see what I mean hopefully :)
Jun 4, 2011 at 22:19 comment added Olhovsky I guess I wasn't clear. The paraboloid projection is fine. When you say "paraboloid projection", I don't really know what you're talking about specifically though, because finding the position in the shadow map is part of doing the "paraboloid projection". The paraboloid projection consists of computing the depth value (in my shader ourdepth) and finding the shadow coordinates. If I replace these two things with the same type of projection used in the spot lights, then what would that tell me?
Jun 4, 2011 at 22:18 comment added Maik Semder Regarding the lot of code, its a lot of code given the time here, its midnight ;)
Jun 4, 2011 at 22:16 comment added Maik Semder Shouldn't it only be used in 2 places? Once writing the shadow-buffer and once reading it in 2 pixel-shaders? Putting it in a separate function would solve the problem and it could easily be changed. But I might underestimate the problem, didn't really check it.
Jun 4, 2011 at 22:15 comment added Olhovsky You mentioned earlier that there's a lot of code to read, but really, there's only maybe 10-15 lines of interest in my point light shader. I will try to separate out the important code in the question, give me a few minutes to do that.
Jun 4, 2011 at 22:14 comment added Olhovsky The way to find the position in the shadow map is given by the simple pixel shader in the DPM sample: gamedevelop.eu/en/tutorials/downloads/… The way I look up a shadow map depth value in my spot light is in my simple pixel shader here (note I said spot light, the spot lights work, and they use planar shadows): olhovsky.com/shadow_mapping/Lights.fx So all that remains really is to fix the way I'm wrongly converting from a forward to deferred setup.
Jun 4, 2011 at 22:12 comment added Olhovsky What I'm trying to say is that replacing the paraboloid projection with a planar projection is a big change. When you say "the paraboloid projection", we're not talking about a matrix multiplication.
Jun 4, 2011 at 22:03 comment added Maik Semder So you are sure the problem is that parabloid projection? I didn't mean to remove the entire calculation of the shadow map coordinates, only the parabloid part, projecting onto a normal plane. However, if you are already sure its the parabloid it shouldn't be too hard to fix
Jun 4, 2011 at 21:51 comment added Olhovsky Computing the paraboloid projection is part of computing the shadow map coordinates. Removing it would not tell me very much, because it is part of what I'm trying to debug in this question.
Jun 4, 2011 at 21:10 comment added Maik Semder But again, generally I would try to test each calculation step separately, removing the parabloid projection is such a steps.
Jun 4, 2011 at 21:08 comment added Maik Semder Ok, so it should be easy to remove the parabloid-part and test if it works with a normal plane, right? Sorry its too late for me here to jump into the code and theres too much of it :)
Jun 4, 2011 at 21:07 comment added Olhovsky That projection is done after the line /* shadow stuff */.
Jun 4, 2011 at 21:03 comment added Olhovsky There is no such matrix. The paraboloid projection is done in the pixel shader manually.
Jun 4, 2011 at 21:02 comment added Maik Semder Ok, in which matrix did you put the parabloid projection? Can't find something with a quick look.
Jun 4, 2011 at 21:01 comment added Olhovsky I have simplified my shader to make it easier to see what's going on: olhovsky.com/shadow_mapping/PointLight.fx If you compare my vertex and pixel shader to the DPM paper's shaders here gamedevelop.eu/en/tutorials/downloads/… Then it might make my mistake more clear. I'm pretty sure I'm not transforming into light space correctly, as a result of needing to apply the deferred principles to the forward rendered example, if you understand my meaning.
Jun 4, 2011 at 20:57 comment added Olhovsky g_mDPView in the DPM paper's sample, is the same as my LightViewProj, and it is just the identity 4x4 matrix, with the bottom left 3 entries replaced with the light's position.
Jun 4, 2011 at 20:56 comment added Olhovsky There are no g_mDPView or g_mDPWorldView in my shader. That is the DPM paper's shader that you're looking at. I can't use that shader directly, since he assumes forward rendering, which I'm not using. This is the source of the trouble. I have a working spot light with shadows here: olhovsky.com/shadow_mapping/Lights.fx (Look at SpotLightMeshShadowPS.) And my point light shadows are here: olhovsky.com/shadow_mapping/PointLight.fx (Look at PointLightMeshShadowPS.)
Jun 4, 2011 at 20:55 comment added Maik Semder I would start removing the parabloid projection from those matrices and see if it works with a simple plane as shadow map. If it works, there is something wrong with the parabloid projection.
Jun 4, 2011 at 20:49 comment added Maik Semder Ok, I don't have XNA and C# running here.
Jun 4, 2011 at 20:47 comment added Maik Semder I was refering to g_mDPView and g_mDPWorldView. Can you show how they are calculated.
Jun 4, 2011 at 20:44 comment added Olhovsky The paraboloid transformation is in the pixel shader I linked in the question. My C++ skills are too limited to drum up a quick C++ project that encapsulates the entire deferred rendering pipeline I think :) However, if you're proficient with C++, then I think it shouldn't be too hard to read my C# code. Especially since most of the concern is really in the pixel shader, and perhaps with the matricies passed to it.
Jun 4, 2011 at 20:39 comment added Maik Semder Can you make a simple C++ project with it? There should also be the parabloid transformation involved right?
Jun 4, 2011 at 20:33 comment added Olhovsky If you're interested, send me an email at [email protected], and I'll reply with a copy of my project. Otherwise: The CameraTransform matrix is actually the world matrix of the camera currently viewing the scene. The LightViewProj matrix is actually just the world matrix of the light, as the view matrix of the light is just the identity matrix.
Jun 4, 2011 at 20:30 comment added Maik Semder Just seeing the shadow map is a Parabloid, that makes it even harder to debug and the idea to put the camera at the lights position to compare current pixel position and position in the shadow-map won't work, nevermind :)
Jun 4, 2011 at 20:17 history answered Maik Semder CC BY-SA 3.0