[font="arial, verdana, tahoma, sans-serif"][font="arial, verdana, tahoma, sans-serif"][font="arial, verdana, tahoma, sans-serif"][font="arial, verdana, tahoma, sans-serif"][font="arial, verdana, tahoma, sans-serif"]Hi everybody
There are some topics in gamedev forum, but none of those describe my situation
After some time of working with matrix stuff I thought I am finally really good in it. Well of course I was wrong.
I was playing a lot with skeletal animations cascaded shadow maps and other stuff which require matrix math, but when I tried do simple shadow mapping deferred using two depth textures I got stuck.
What am I trying to achieve is to make correct shadow mapping using two depth textures (light and camera).
I can represent texture UV as X,Y and value (depth) as Z and that is basically how the shadow mapping works. It is just about moving vector from one space to another, so where is the problem? I've quickly make a formula and generate texture matrix. And guess what. It doesn't work.
My idea of compare was simple
[/font][font="arial, verdana, tahoma, sans-serif"]Data stored in camera depth texture will be used for vertex world position reconstruction.
Grab depth value at UV and generate postion vector with UV*2.0-1.0 (from [0,1] into [-1,1]) and depth. Using inverse camera projection I should get position in camera space so multiplying camera matrix with inverse camera projection multiplied by vertex i should get vertex in world position (modelMatrix * vertex). On the rest I should use basic formula known from camera transformation but instead of camera I will use light.
[/font][/font]
[font="arial, verdana, tahoma, sans-serif"][font="arial, verdana, tahoma, sans-serif"]ModelMatrix = CameraModelMatrix x CameraProjectionMatrix[sup]-1[/sup] [/font][/font]
[font="arial, verdana, tahoma, sans-serif"]ViewMatrix = LightModelMatrix[sup]-1[/sup]
ProjectionMatrix = LightProjectionMatrix[/font]
[font="arial, verdana, tahoma, sans-serif"]
ModelViewMatrix = LightModelMatrix[sup]-1 [/sup]x CameraModelMatrix x CameraProjectionMatrix[sup]-1[/sup]
ModelViewProjectionMatrix = LightProjectionMatrix x LightModelMatrix[sup]-1 [/sup]x CameraModelMatrix x CameraProjectionMatrix[sup]-1[/sup]
VertexCameraSpacePosition = U*2-1,V*2-1,depthFromCameraSpace at UV position
VertexLightSpacePosition = LightProjectionMatrix x LightModelMatrix[sup]-1 [/sup]x CameraModelMatrix x CameraProjectionMatrix[sup]-1[/sup] x VertexCameraSpacePosition
So If I now compare VertexLightSpacePosition.z with depthFromLightSpace (value of depth texture stored form light space) at VertexLightSpacePosition.xy I should know if fragment is in shadow[/font][/quote][font="arial, verdana, tahoma, sans-serif"]
It is not a big deal because I can make correct light shadow texture in forward render, store it (another render target with MRT) and compare/smooth it deferred without need of camera depth texture.
Recently I found this method right here at gamedev: [color="#2810EE"]above method
But I am curious guy so I would like to know how to do the whole process deferred (if there is an easy solution to deal with this).
I am not asking directly for answer, but rather for some resource(I was googling a lot but I didn't find any good resource for deferred shadow mapping).
Of course someone who can describe his solution will be welcome.[/font][/font][/font][/font][/font][/font]