OpenGL Tutorial 25 - Shadow Maps (Directional Lights)
Vložit
- čas přidán 1. 07. 2024
- In this tutorial I'll show you what shadow maps are and how you can implement them in your scenes with directional lights!
Source Code
github.com/VictorGordan/openg...
OpenGL Documentation
www.khronos.org/registry/Open...
Discord Server
/ discord
Patreon
/ victorgordan
Timestamps
0:00 Introduction & Theory
1:10 Shadow Map Framebuffer
1:45 Light Matrices
3:03 Shadow Map Shaders
3:21 Shadow Map Program
3:31 Shadow Map Rendering
3:48 Shadow Map Debugging
3:58 Normal Scene Rendering
4:14 Modifying the Default Vertex Shader
4:24 Modifying the Default Fragment Shader
5:19 Shadow Acne
6:23 Softening the Shadows
6:43 Discord & Patreon
References
learnopengl.com/Advanced-Ligh...
#opengl #opengltutorial #computergraphics #cpp #visualstudio #3dgraphics #shadows
Keep going! Need more advance computer graphics concepts! Thank you 🙏
Thank you for making this tutorial! I had so much trouble making shadow mapping work in my project. Turns out I had mistyped the code where I have to make FragLight be in the range of 0 and 1. I also made my shadows look nicer after rewatching your video.
Phenomenal explanation! Thanks!!!!
I've been trying to figure out how shadows work in games for a while but I could never think of solution and never got the chance to google it. But DAMN this is genius, I kind of feel bad that I couldn't figure this out but still
Sadly, now that you know, they will be a lot more visible (in a bad way). Before knowing this I thought the difference between low and high quality shadows was just how blurry they were. Now I know they are blurry cause they just blur low quality shadowmaps so they don't look that bad haha. And u'll start noticing the res of shadowmaps especially when they don't blur them haha
Very well explained and easy to follow. Great Job.
Thx :)
I love your videos
Thank you :,)
Finally
It's here ;)
@@VictorGordan Are you going in that order?
learnopengl com
Yeah, 90% of the time I follow the order on learnopengl.com
Hi, your series on OpenGL is really great!!! Just having a small issue, in 3:48 where you were running depth map from light's perpective, the code is unable to preview it in the window and we get a large upscale version of the crow model with camera in origin, but later when the same matrices used making the shadows in the end it works. At the end, the entireity of the code works but not able to see the depth map from light perspective is what I am finding trouble from what I wrote code from your video
Very strange you can't see the depthmap while having it work... if it works it should be correct, therefore if you just display the depth map on two triangles covering the screen, you should be able to see it
This video is helpful, thanks a lot. I just got a question, how can I render the shadow map on the screen?
Look at my framebuffer tutorial and render the shadowmap texture instead of the framebuffer texture ;)
why i feel the shadow is weird like there some places in mid of the light there is shadow and my shadow is not soft at all
Hey Victor, I'm a 2D character artist with a deep obsession with video games and computer graphics. However I was never into much programming and coding but more attracted to the creative and art sides of the projects like how shadows are implemented, light sources. Like I want to just know how it works without getting into the detail of the maths involved. I haven't been able to find simpler explainations of this. I have a question about how facial shadows are working in Forbidden West as the character of Aloy has poor facial deep facial shadows being casted on Aloy's face on the PS5 version in the prologue but get very good as we get into the game like advertised in the State of Play 21. Can you please help me with a little a bit of information?
I don't know much about facial shadows. I presume they work the same way all other shadows do though. Having bad depth early in the game vs late in the game seems more of an environment related thing rather than anything to do with the shadows themselves. Certain types of environment and lighting can affect the looks of things a lot. In this case we're probably talking about harsh lighting vs soft lighting. So it probably looks like it has less depth because of soft lighting which might be caused by a cloudy setting or smth like that
Late comment but I think what you're referring to are "contact shadows". Those are done by raymarching in the shader rather than shadow maps.
I would like to ask a question. If I want to add a shadow map to the imported model in the program in tutorial 19 (keep the skybox), are the steps the same as in this tutorial? I tried the same way as in the tutorial (before 3:23) and no error was reported, but the window was all black.
Tbh I'm not sure. I don't really remember exactly what I did in the tutorials. But it sounds like you might have some problems with your shaders or your textures, specifically how you bind your textures and how many you have ;)
Good luck!
@@VictorGordan Okay. Thank you very much!
How to dynamic(no static) calculate the projection matrix correctly? Thanks in advance for your reply )
I am not sure I understand your question 🤔
Is the matrix not being calculated correctly in the video?
Did you try to put the code of the matrices inside the while?
If the 3D model we render has a texture with alpha, how do we calculate the shadow properly? It will always be bad since only the mash is used to calculate the shadow
You render with textures on. Then it should work (assuming your renderer can handle transparent textures)
@@VictorGordan It worked great
Hello, thank you very much for your video tutorial. But I still don't understand how shadow maps are rendered. I used the project in your video and replaced the post map with a shadow map. It does show, but the background is red. Then I try to do this in my own project. It only shows the red background, and nothing else.
Thank you. I already know why there is no object in my shadow map. This is related to my light source coordinates. My light source is (0,0,0). But I still don't know why the shadow map I display is red, while the video is white.
Because you are getting RGB values from the map (a vector3). Just write ".r" or ".x" to only get the red part of the vector ;)
First! I never did it. I had to do it. Xd
Can you first do physics tutorials and then continue with the opengl series please?
Nope :p
What else will you cover in this opengl series?
The same things that are on learnopengl.com and perhaps more ;)
@@VictorGordan ok