Soft Shadows - PCF & Random Sampling // OpenGL Tutorial #41

  Рет қаралды 8,501

OGLDEV

OGLDEV

Күн бұрын

In this video we will explore two techniques for creating soft shadows in OpenGL - Percentage Closer Filtering (PCF) and Soft Shadow Edges with Random Sampling.
Time codes:
0:00 Intro
0:29 Percentage Closer Filtering
4:32 Configurable sized filter
5:31 PCF deficiencies
6:08 Soft Shadow Edges with Random Filtering
15:32 Conclusion
Dragon model available from: casual-effects.com/g3d/data10...
Article by Yury Uralsky on soft shadows with random sampling: developer.nvidia.com/gpugems/...
Make sure to watch all the previous tutorials in the "OpenGL For Beginners" playlist at • OpenGL for Beginners
Please visit ogldev.org to see more of my tutorials on modern OpenGL.
Link to source: github.com/emeiri/ogldev/blob...
If you want to get the same version that was used in the video checkout the tag TUT_41_SOFT_SHADOWS.
OpenGL 4.6 specification: www.khronos.org/registry/Open...
Feel free to comment below.
Email: ogldev1@gmail.com
Instagram: @ogldev1
GIthub: github.com/emeiri/ogldev.git
Twitter: @ogldev
One time donations (Paypal): ogldev.org/donate.html
Patreon: / ogldev
Credits:
* Sound effects and music obtained from www.zapsplat.com
* Image by 13smok from Pixabay
* Image by Clker-Free-Vector-Images from Pixabay
Enjoy,
Etay Meiri
#opengl #ogldev #opengtutorials

Пікірлер: 36
@AHsiao112
@AHsiao112 24 күн бұрын
Your tutorials are top-notch. It's a shame I only just found your channel.
@OGLDEV
@OGLDEV 24 күн бұрын
Better late than never - glad to have you on board :-)
@GGodis
@GGodis Жыл бұрын
Thanks for the very detailed explanation about the soft shadows. Will be really useful. Hope to see more great tutorials like this.
@OGLDEV
@OGLDEV Жыл бұрын
You're welcome :-)
@Iridium.
@Iridium. 5 ай бұрын
Such a well explained and informative video. Thank you for the time spent to make it. Shaders are a complex topic , but you are doing great at explaining.
@OGLDEV
@OGLDEV 5 ай бұрын
Glad it was helpful!
@paulschlusser1085
@paulschlusser1085 Жыл бұрын
There is an elegant way to express a backward iterating loop which can be used for the u and v. Use "for (int i = loop_count; i--;) { ... }, This has the exact same effect as in the example shown around 11:45 in the video. Once you are used to it, you'll always immediately recognise it as a backward counting loop from loop_count - 1 through 0.
@OGLDEV
@OGLDEV Жыл бұрын
Thanks, cool tip!
@n-man6964
@n-man6964 Жыл бұрын
I have not yet entered the realm of shadowmapping. Though, the first method looks pretty simple. As always, nicely explained 👌
@OGLDEV
@OGLDEV Жыл бұрын
Thanks!
@kylebowles9820
@kylebowles9820 Жыл бұрын
If you liked how that works, you'll also like how corner detectors in computer vision work. Some use that same ring approach. Happy coding everyone :)
@thehambone1454
@thehambone1454 Жыл бұрын
Thank you so much for making these! Not enough OGL resources! Do you have PBR planned for the future?
@OGLDEV
@OGLDEV Жыл бұрын
You're welcome :-). PBR is in the todo list.
@_jose_antonio_
@_jose_antonio_ Жыл бұрын
this shadow maps technique is very cool and sustainable, but I wanted something more geometric, like shadow volume, could you make a tutorial video about it?
@OGLDEV
@OGLDEV Жыл бұрын
I've added this topic to my todo list. In the meantime you may want to check my web based tutorial on stencil shadow volumes: ogldev.org/www/tutorial40/tutorial40.html
@TheJGAdams
@TheJGAdams Жыл бұрын
Thank you very much! Random Sampling was interesting for me. I was able to smooth shadow with only 4 samples, each taking it's own 4 samples for a bilinear interpolation. This is done using sampler2DShadow. Which require setting it on over the texture settings. The problem is, it would have a blocky edges like a pixel. and there are no depth interpolation. I wonder if random sampling fixed both issues?
@OGLDEV
@OGLDEV Жыл бұрын
I think that it does but you will need to try it out and tune the parameters.
@edu_rinaldi
@edu_rinaldi Жыл бұрын
Great tutorial! Link to source (in description) seems to be broken. It's not a big problem, I just found it manually, but I thought that pointing it out to you would be useful :)
@OGLDEV
@OGLDEV Жыл бұрын
Thanks for the feedback! I fixed it.
@dameck9570
@dameck9570 Жыл бұрын
I am interested in how effective the check for if the fragment is completely in or out the shadow is in your soft-shadow implementation. I read in a couple sources, that graphics cards are horrible at branching and therefore just run all if-branches at the same time and then pick the result from the correct one. Wouldn't that mean, that the first for loop in your fragment shader to check the sum to be all 0 or 1 is just twice the work necessary?
@OGLDEV
@OGLDEV Жыл бұрын
According to the original article by NVIDIA (see link in the video description) there is true dynamic branching since the Geforce series 6. The GPU processes thousands of pixels in parallel as long as they run the same piece of code so if some pixels take path A while others take path B they cannot be processed together so this hurts parallelism but the assumption is that in a local neighborhood all pixels will take the same path so the effect on parallelism will be negligible. Please see the article for more details.
@dameck9570
@dameck9570 Жыл бұрын
@@OGLDEV Thank you!
@user-mu8kp6mm4q
@user-mu8kp6mm4q Жыл бұрын
wonderful!
@OGLDEV
@OGLDEV Жыл бұрын
Many thanks!
@mertcanzafer9901
@mertcanzafer9901 4 ай бұрын
Can you do more advance rendering series?
@OGLDEV
@OGLDEV 4 ай бұрын
Yes, every once in a while there will be a tutorial like that.
@cheerwizard21
@cheerwizard21 5 ай бұрын
Hi! Great tutorial! Are you planning to make a tutorial on cascaded shadow mapping? It would be also a useful tutorial 🙂
@OGLDEV
@OGLDEV 5 ай бұрын
It's on the road map... In the meantime you can try the CSM tutorial on my website: ogldev.org/www/tutorial49/tutorial49.html
@cheerwizard21
@cheerwizard21 5 ай бұрын
@@OGLDEV Great, thanks again! 🙂
@mikefakoukakis9228
@mikefakoukakis9228 Жыл бұрын
Great video like always. I have a problem with the second approach though. The more I increase the radius the more I get a border around the shadow darker than the rest of the shadow and the sharp points of the mesh appear duplicated. Do you know why I get this? Once more thanks for the video!
@OGLDEV
@OGLDEV Жыл бұрын
What values did you use for the windows size, filter size and radius?
@mikefakoukakis9228
@mikefakoukakis9228 Жыл бұрын
@@OGLDEV Thanks for the reply! Here is what I've tried so far : window 8, filter 4, radius 7 & window 16, filter 8, radius 15 as you suggested. On the second (radius 15) the problem is more obvious. I only get the normal shadow with radius = 1. I could make a screenshot and post it somewhere if that helps
@OGLDEV
@OGLDEV Жыл бұрын
I can't reproduce the problem with these settings. Can you please send me a screenshot at ogldev1@gmail.com? Thanks.
@mikefakoukakis9228
@mikefakoukakis9228 Жыл бұрын
@@OGLDEV Thanks a lot for taking the time to look at the problem. I've sent you 2 screenshots and my fragment shader code
@brumm3653
@brumm3653 Жыл бұрын
Shadows in real life are sharper close to the shadowing object, and get blurrier and blurrier away from the object. Would that be hard to implement?
@OGLDEV
@OGLDEV Жыл бұрын
You can make the radius of the circle dependent on the distance from the object. In the case of shadow mapping we have the depth of the pixel and the depth in the shadow map. Quickest way is to make the radius a function of the delta between them. Or extrapolate the original depth and do something similar.
Physically Based Rendering // OpenGL Tutorial #43
17:31
OGLDEV
Рет қаралды 10 М.
SHADOWS! // Hazel Engine Dev Log
26:09
The Cherno
Рет қаралды 64 М.
Don’t take steroids ! 🙏🙏
00:16
Tibo InShape
Рет қаралды 72 МЛН
CAN YOU HELP ME? (ROAD TO 100 MLN!) #shorts
00:26
PANDA BOI
Рет қаралды 35 МЛН
Get Structured Output from LLMs with Outlines Locally
13:49
Creating an Instance // Vulkan For Beginners #2
18:02
OGLDEV
Рет қаралды 3 М.
Introduction To Tessellation // OpenGL Tutorial #47
16:57
OGLDEV
Рет қаралды 4,7 М.
Basic Shadow Mapping // OpenGL Tutorial #35
16:54
OGLDEV
Рет қаралды 19 М.
How I Implemented Shadows in my Game Engine
7:45
ThinMatrix
Рет қаралды 93 М.
DJ! Swap that chain!!! // Vulkan For Beginners #7
13:53
OGLDEV
Рет қаралды 1,5 М.
Optimize Your Meshes! // OpenGL Tutorial #48
19:41
OGLDEV
Рет қаралды 4,9 М.
Basic Lighting And Materials // OpenGL Tutorial #19
23:33
OGLDEV
Рет қаралды 14 М.
Don’t take steroids ! 🙏🙏
00:16
Tibo InShape
Рет қаралды 72 МЛН