problem when going deferred...
Hi guys,
I am performing some tests and implemented a traditional deferred pipeline in my engine.
I am experiencing some issues with my cascade VSM implementation, which worked flawlessly with the forward rendering pipeline.
Using the deferred pipeline, I get some artifacts at polygon edges, as shown below (screenshot showing the result of the shadow being applied, nothing else - no lighting, no texture, no postprocess):
Now, I have checked everything is reconstructed from the G-Buffers correctly: normals, view space position, etc...
The problem definitively comes from the shadow map not being sampled correctly. See the screenshot below, showing the result of the shadow map sampling (I modified the contrast to clearly show the error):
Now, I think this is due to the derivatives used for the texture sampling being wrong. The texture coordinates used for shadow map sampling are constructed in the pixel shader, using the view space position multiplied by shadow light view matrix.
However, the viewspace position is reconstructed using the linear view space depth, which is read from the G-Buffer in the PS.
Hence, the texture coordinates derivatives are not correct.
I am pretty sure I have to manually compute them, however I have no idea how to proceed.
Could anybody help me ?
Thanks,
Greg
[EDIT]:
I found some interesting method here
http://visual-computing.intel-research.net/art/publications/sdsm/ (Andy is everywhere
)
Now, one last question:
I can reconstruct the view space position of (x,y), of (x+1, y) and of (x, y+1) (x & y being pixels). Call them ViewPos, ViewPosdX, ViewPosdY.
So, I guess I have to transform these 3 coordinates into shadow light space, LightPos, LightPosdX, LightPosdY.
Then, what should I call SampleGrad with ?
I would say :
ddx = LightPosdX - LightPos
ddy = LightPosdY - LightPos
Am I right ?