Physically Based Rendering // Intermediate OpenGL Series

  Рет қаралды 9,432

OGLDEV

OGLDEV

Күн бұрын

This video is (hopefully) a gentle introduction to Physically Based Rendering (PBR) using OpenGL. The topic itself is complex and relies on many years of research (by other people ;-) ). I tried to explain the mechanics and give some intuition into why they work this way.
Resources:
* 'OpenGL Shading Language Cookbook - 3rd Ed' by David Wolff
* learnopengl.com/PBR/Lighting
Timecodes:
0:00 Intro
0:49 What is PBR?
1:56 Simplified PBR equation
2:58 The BRDF
4:25 The Diffuse BRDF
6:47 The Specular BRDF
8:03 The Normal Distribution Function (GGX)
10:26 The Geometry Function (Schlick GGX)
12:11 The Fresnel Function (Schlick approximation)
14:23 Last two pieces of the PBR equation
14:44 Fragment shader code review
17:00 Outro
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_43_PBR.
OpenGL 4.6 specification: www.khronos.org/registry/Open...
Credits:
Images:
* kordula vahle from Pixabay (lago federa)
* Pau Llopart Cervello from Pixabay (ring)
* www.codinglabs.net/article_phy...
* Clker-Free-Vector-Images from Pixabay
* OpenClipart-Vectors from Pixabay
* blog.selfshadow.com/publicati...
* www.codinglabs.net/article_phy...
* Anja-#pray for ukraine# #helping hands# stop the war from Pixabay
Videos:
* • Sansar : Phong Materia...
* • • CryEngine - Physical...
* • PBR texture in Blender...
* • Turning Images into PB...
Music:
"Sweet Heat" from tunetank.com/
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
Enjoy,
Etay Meiri
#opengl #ogldev #opengtutorials

Пікірлер: 49
@claymans2731
@claymans2731 Жыл бұрын
I must say this is the most clear PBR explanation with actual working code. How about add IBL in the next video~
@OGLDEV
@OGLDEV Жыл бұрын
Thank you! IBL is on the roadmap but will take some time because I have other topics planned.
@liorsky
@liorsky 5 ай бұрын
Im finding researching the topic with papers so difficult and this is just the perfect gateway for the subject
@OGLDEV
@OGLDEV 5 ай бұрын
Thanks :-)
@furkanunsal5814
@furkanunsal5814 Жыл бұрын
very clear and applicable, great work! I had to read the book for it in my project.
@OGLDEV
@OGLDEV Жыл бұрын
Cool, thanks!
@asimovf77
@asimovf77 Жыл бұрын
Great content as usual !!!!! Keep going and thanx for sharing!!!!!
@OGLDEV
@OGLDEV Жыл бұрын
You bet!
@maheshmahindrakar1884
@maheshmahindrakar1884 Жыл бұрын
Very well simplified explanation...👍
@OGLDEV
@OGLDEV Жыл бұрын
Thank you :-)
@roness6749
@roness6749 3 ай бұрын
Amazing tutorial, thank you so much for making this.
@OGLDEV
@OGLDEV 2 ай бұрын
You're very welcome!
@xphereSpz
@xphereSpz Жыл бұрын
nice tutorial and great explanation!! :)
@OGLDEV
@OGLDEV Жыл бұрын
Thanks!
Ай бұрын
Great video, thanks!
@OGLDEV
@OGLDEV Ай бұрын
You're welcome!
@CodeParticles
@CodeParticles Жыл бұрын
@OGLDEV, Thank you for this upload. I have a question on the reflection of objects you briefly mentioned @ 12:53? How would you reflect other objects when using PBR? When I was working on blinn-phong, I had to render a framebuffer object of my scene and then use that as a texture for my reflective objects to simulate reflection. Is it the same for PBR too or is it much easier to do? I've done PBR as well, but couldn't figure out how to reflect objects only the skybox, thank you!
@OGLDEV
@OGLDEV Жыл бұрын
I haven't done this yet but perhaps you mean something like: learnopengl.com/PBR/IBL/Diffuse-irradiance ?
@hajjex_9086
@hajjex_9086 9 ай бұрын
Hey, i have a question Now, usually when calculating the reflection We usually dont have the "light" vector We would have a reflection vector, but that doesn't necessarily mean that the reflected ray would bounce of toward a light source. Is it still what you meant by "light" vector? Or do i have to somehow calculate the direction of the closest emitting material or something? Thanks in advance!
@OGLDEV
@OGLDEV 9 ай бұрын
Reflecting and reversing (or negating) the light direction are two different things. When you want to calculate diffuse lighting you have to do a dot product between the normal and the light direction, but the light direction must be pointing from the surface and "up", same as the normal. For example, if the light hits the surface at maximum strength it means that the original light vector is perpendicular to the surface but is opposite to the normal (which is also perpendicular ofcourse). So you multiply the light direction by -1 and when you do the dot product with the normal you get 1 which means maximum strength. Reflecting is when you want to calculate the specular effect. Let's say that the light hits the surface at 45 degrees angle. To calc the reflection you call reflect(LightDirection, Normal) and this will give you the a vector which point 45 degrees on the "other side" of the normal. The original light vector is pointing at the surface and the reflection is pointing back up. This allows it to hits the camera and the specular effect increases as the reflection and pixel to camera vector become aligned. So you don't need to reverse in the specular case, just use reflect() with the original light direction.
@hajjex_9086
@hajjex_9086 9 ай бұрын
@@OGLDEV thanks! My question was just wanting to know if I can replace the "light" in your video with just the incoming ray, whether it was from a light source or an object Because, as you know, that's how raytracers work Thanks again! Really underrated channel. Keep it up.
@OGLDEV
@OGLDEV 9 ай бұрын
Oh, I see, I think you can. Thanks!
@progfix
@progfix Жыл бұрын
How does shadow mapping work with PBR? Where do you apply the shadow value?
@OGLDEV
@OGLDEV Жыл бұрын
I guess it should work the same as the regular Phong model, since PBR only deals with the color of the object. Compare CalcDirectionalLight with CalcPBRDirectionalLight. The non-PBR version calculates a shadow factor which depends only on the light direction and the normal. You need to multiply it with the PBR color.
@DasAntiNaziBroetchen
@DasAntiNaziBroetchen 9 ай бұрын
You can just multiply the light color/intensity with the shadow factor.
@sumitmakkar7199
@sumitmakkar7199 10 ай бұрын
Hi, First of all thanks a lot for providing us these videos. I have a doubt in half vector calculation. Taking the direction of light vector into consideration, shouldn't the equation for calculating half vector be: half = normalize( view-light). As light + view would be more horizontal. Or the direction of the light vector should be opposite ( by which I mean that it should be multiplied with -1).
@OGLDEV
@OGLDEV 10 ай бұрын
The light direction is provided by the application in the natural order - down towards the earth. I believe it's more intuitive for the developer to think about it like that. It is reversed in the fragment shader.
@hajjex_9086
@hajjex_9086 9 ай бұрын
​@@OGLDEVso for me to apply it to my case, I have to reverse it like he said? *-1?
@OGLDEV
@OGLDEV 9 ай бұрын
@hajjex_9086 Depends on how you send in your light direction. The shader assumes that it is the original direction so it has to reverse it for the diffuse calculation because the dot product needs the direction from the surface back to the light source. But you can also optimize somewhere between the application and shader and reverse the light direction before it goes in and then the shader can use it as-is without extra ops.
@hajjex_9086
@hajjex_9086 9 ай бұрын
@@OGLDEV I actually send my rays from the camera And that's it So in reality It's actually pointing toward the light source at some point So does that need reversing?
@hajjex_9086
@hajjex_9086 9 ай бұрын
​​​@@OGLDEValso, by original direction, u mean that it's from light to surface. This means we will simply do light vector + view? This confused me a little.
@MrFacciolone
@MrFacciolone Жыл бұрын
one thing I don't understand, you say that alpha(roughness) = 0 means a perfectly smooth surface, that means it reflects all light, but when alpha is 0 than the whole normal distribution function D computes to 0 (since the numerator is 0*0), hence making the whole BRDF specular equal to 0, since D is multiplied for G and F .. Something I'm missing here?
@OGLDEV
@OGLDEV Жыл бұрын
It's a good question. Obviously when alpha is zero the BRDF is zero so we don't get specular lighting. I think that zero here serves as kind of a limit to which we are not supposed to reach and realistically the roughness values will be much higher (I consider 0.1 to be "much higher" ;-) ). Here's an interesting experiment you may want to try: plug the GGX equation into a spreadsheet. Set an input column for alpha and have it start at zero and continue with small increments. NdotH can be constant for the entire spreadsheet. A good example is 1 where the light ray is reflected directly at the eye but you may want to play with different values. When NdotH=1 and alpha=0.1 you are already getting 3183 which is very high and alpha=0.01 is really crazy. So I guess alpha=0 should return infinity but the equation simply doesn't work that way. I'm pretty sure the people who invented this were well aware of this corner and the papers may have addressed this already. Infinity is not very useful in practical applications so I guess they just ignored it. This is just my intuition. Joey De-Vries has a web based example in learnopengl.com/PBR/Lighting which you can also play with. When alpha is very low you get a very concentrated specular reflection and when it is zero there is nothing.
@MrFacciolone
@MrFacciolone Жыл бұрын
@@OGLDEV aaah thank you this clarifies it! I got stuck on that believing I wasn't undertanding some relatively simple math! Indeed thinking on it the stronger specular reflection is, the smaller the area that is seen reflecting. So alpha must be non zero or the area reflecting gets infinetely small, On the source you linked in the code alpha seems to start at 0.2. Thanks!
@ToPGoP
@ToPGoP Жыл бұрын
Hello, can you update the link to source please?
@OGLDEV
@OGLDEV Жыл бұрын
Done.
@ToPGoP
@ToPGoP Жыл бұрын
@@OGLDEV thanks
@divyakunwar6992
@divyakunwar6992 3 ай бұрын
can you share the cpp file for this code
@OGLDEV
@OGLDEV 3 ай бұрын
github.com/emeiri/ogldev/blob/master/tutorial43_youtube
@hajjex_9086
@hajjex_9086 9 ай бұрын
This is literally an irl cheat code
@OGLDEV
@OGLDEV 9 ай бұрын
OMG! Is it a good thing or a bad thing??
@hajjex_9086
@hajjex_9086 9 ай бұрын
@@OGLDEV I'm saying that this is wonderful Because it makes a hard topic very accessible Thanks!
@OGLDEV
@OGLDEV 9 ай бұрын
You're welcome :-)
@alakhaggarwal6315
@alakhaggarwal6315 Жыл бұрын
For an ideal perfectly smooth surface, alpha=0. This makes D=0 because D is proportional to alpha^2. That makes SpecularBRDF=0. But I thought for smooth surface, Specular BRDF should be high
@OGLDEV
@OGLDEV Жыл бұрын
Hi, I'm on vacation. Will get back to you next week.
@OGLDEV
@OGLDEV Жыл бұрын
I'm back and turns out I already answered this question three months ago 🙂 Please see my response to @MrFacciolone below (kzbin.info/www/bejne/jnzCoWWDrax1h9U&lc=Ugz-W5xSJlCgSFO60EV4AaABAg.9jzRGRPKpap9k1dX8vgJdG)
GPT-4o - Takeaways and NEW Insights
12:06
AI GROWTH GUYS
Рет қаралды 494
ISSEI funny story😂😂😂Strange World | Pink with inoCat
00:36
ISSEI / いっせい
Рет қаралды 25 МЛН
НЕОБЫЧНЫЙ ЛЕДЕНЕЦ
00:49
Sveta Sollar
Рет қаралды 7 МЛН
одни дома // EVA mash @TweetvilleCartoon
01:00
EVA mash
Рет қаралды 6 МЛН
Эта Мама Испортила Гендер-Пати 😂
00:40
Глеб Рандалайнен
Рет қаралды 9 МЛН
OpenGL Low-Poly Terrain Tutorial
16:53
ThinMatrix
Рет қаралды 95 М.
Introduction To Tessellation in OpenGL
16:57
OGLDEV
Рет қаралды 4,5 М.
Giving Personality to Procedural Animations using Math
15:30
t3ssel8r
Рет қаралды 2,3 МЛН
An introduction to Shader Art Coding
22:40
kishimisu
Рет қаралды 887 М.
OpenGL - PBR (physically based rendering)
12:47
Brian Will
Рет қаралды 29 М.
quarkGL - PBR OpenGL renderer
10:06
voithoz
Рет қаралды 3,2 М.
ISSEI funny story😂😂😂Strange World | Pink with inoCat
00:36
ISSEI / いっせい
Рет қаралды 25 МЛН