Recently I was able to render shadows using depth maps writing a depth buffer to a frame buffer.
All I used was a single light and single .obj file with a sphere on top of a plane. Everything is good.
Now I’m building a scene which has multiple .objs and different textures for each. I have a floor, three walls, windows, chairs and table
all brought into my renderer as different objs. Now I want to render the shadows of the table and chairs on the floor object all of which are different objects.
Is there a best way to approach this as I’m confused to get the shadows casted on a different object that will be drawn on a different draw call.
Thanks in advance
There really isn’t anything different about using shadow maps when the rendering is split into multiple draw calls. Render the entire scene (all objects) from the light’s perspective into a depth buffer. Then render the scene normally using the depth buffer to calculate shadows.
Thanks for your reply.
So I tried the way you said and it seems to work fine with this one. I just used simple basic shapes with primitive meshes.
But when I used the same shaders and kinda similar uniforms(except the scaling) I am not getting shadows. These are not super heavy meshes but large in scale.
I am not getting the shadows. I tweaked the orthogonal frustum from the lights view to print the whole scene. I’m kinda not really sure how the light view frustum and the viewport
shadow mapping works.
I greatly appreciate any help.
Thanks in advance.
If the different objects have their own transformations, my first guess would be that you aren’t using the same overall transformations in both passes. The technique requires using the same light-space coordinates in both passes.
Well, I suggest re-reading whatever tutorial or article you used (and possibly some others) until you do understand it. You aren’t going to get very far simply by copying code which you don’t actually understand.
Thanks for your reply again! I appreciate it much!
So here’s exactly what I’m doing. Both the objects have the same transformations and light view matrices are the same for both the depth and shadow passes.
Both the objects have a scaling of 0.003 in all three axes making the two big objs smaller to render in the screen and there is no translation or rotation.
Now my light view matrices are the same for both the passes. Now I’m wondering as in my object render pass, should I apply the same scaling transformation to the light view
model matrix as well.
Anyway, I’m gonna ready some theory and watch couple more tutorials and dig my code. Still if you have any advise for what I said above, would welcome it.
Any object transformations need to be included in the overall transformations for both view-space and light-space. Otherwise, you’ll be calculating shadows for a different scene than the one you’re rendering.
Thank you so much sir!!
I was finally able to crack it!! Its a silly mistake on my part wherein I was doing a double Model transformation both in application and in shader which was causing the issue. Sorry about
And here’s what I got!
Once again, I thank you very much for your inputs!!!
This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.