OpenGL Tutorial 25 - Shadow Maps (Directional Lights)

preview_player
Показать описание
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*

*OpenGL Documentation*

*Discord Server*

*Patreon*

*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*

#opengl #opengltutorial #computergraphics #cpp #visualstudio #3dgraphics #shadows
Рекомендации по теме
Комментарии
Автор

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.

radoslavl
Автор

Keep going! Need more advance computer graphics concepts! Thank you 🙏

RGBguy
Автор

Very well explained and easy to follow. Great Job.

thenospeak
Автор

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

aaron
Автор

At 6:40 when softening the shadow, wouldn't it cause problems to compare the depth of the current fragment to the depth values of the surrounding if the plane the shadow is cast on is at an angle to the light? Because it's just the depth of the *current fragment* being compared with the depths in the depth buffer of surrounding pixels?

If there is an angle, then I imagine that the neighboring depth buffer value could be closer than the "current_depth" value even if it's still in shadow and give a bad value to average.

undeadpresident
Автор

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?

shoaibmehmood
Автор

This video is helpful, thanks a lot. I just got a question, how can I render the shadow map on the screen?

asunawu
Автор

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

noname-nihp
Автор

How to dynamic(no static) calculate the projection matrix correctly? Thanks in advance for your reply )

ДенисА-ли
Автор

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

rohitaryan
Автор

First! I never did it. I had to do it. Xd

starklosch
Автор

So I suppose that when you draw to depth buffer and there's no fragment to draw in a location, that the Z value for that location in the depth buffer still changes to some sort of max depth value? Because otherwise it would be the clear color? Is this correct?

undeadpresident
Автор

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.

menghanzhang
Автор

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.

张昊晨-ws
Автор

Can you first do physics tutorials and then continue with the opengl series please?

shinystick
Автор

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

MARIODILONARDO
Автор

What else will you cover in this opengl series?

shinystick