Basic Lighting And Materials // OpenGL Beginners Series

  Рет қаралды 13,828

OGLDEV

OGLDEV

Күн бұрын

In this video I will introduce you to a basic lighting model in OpenGL called the 'Phong Reflection Model'. We will review the components of this model and implement ambient lighting. We will also start adding material support to our basic mesh and a base light class that we will expand over the course of the next few episodes.
The model of the demo in this tutorial is polyhaven.com/a/wine_barrel_01 by James Ray Cock.
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_19_MATERIALS.
OpenGL 4.6 specification: www.khronos.org/registry/Open...
Timecodes:
0:00 Intro
0:57 Phong Reflection Model
1:38 Diffuse lighting
2:59 Specular lighting
3:43 Ambient lighting
4:55 Materials
6:40 Todo list
7:33 The lighting equation
9:52 Code review
10:08 The Technique class
11:18 The LightingTechnique class
13:56 Changes to the main application code
14:51 The light source
15:26 The material
18:15 The fragment shader
19:01 Handling uniforms of structures
19:56 The demo model
20:45 The format of OBJ material files
21:35 Test the code
22:12 Fix the Assimp import problem
22:33 A couple of experiments
23:00 Conclusion
Feel free to comment below.
Email: ogldev1@gmail.com
Facebook: / ogldev-188319114585587
GIthub: github.com/emeiri/ogldev.git
Twitter: @ogldev
One time donations (Paypal): ogldev.org/donate.html
Patreon: / ogldev
My gear (Amazon affiliate links):
Camera - Canon EOS M50: amzn.to/3duVIOh
Camera mic - Rode Videomic: amzn.to/3dsGVDs
Desktop mic - Rode NT-USB-Mini: amzn.to/3giMoif
Credits:
Image: computingthehumanexperience.c...
Music: "Photo Album" from bensound.com
Enjoy,
Etay Meiri
#opengl #ogldev #opengtutorials

Пікірлер: 22
@OGLDEV
@OGLDEV 19 күн бұрын
Notes and errata: 1. In the BasicMesh class I accidently reviewed the instanced version of the Render function but instead of the regular (non-instanced version). Both versions are the same from the material perspective.
@dimension-ji7xk
@dimension-ji7xk 2 жыл бұрын
Yes just what I've been waiting for
@OGLDEV
@OGLDEV 2 жыл бұрын
Mind reading again!
@mohammad-karbalaee
@mohammad-karbalaee 2 жыл бұрын
your tutorial is perfect. thanks. keep going
@OGLDEV
@OGLDEV 2 жыл бұрын
Thank you :-)
@yoonhakim2455
@yoonhakim2455 20 күн бұрын
Hi, I noticed that the name of drawing function got changed. In the last video it was glDrawElementsBaseVertex. Does it have something to do with adding materials and lighting? or perhaps I'm just distracted by irrelevant stuff?
@OGLDEV
@OGLDEV 19 күн бұрын
Wow! the video is more than two years old but because of your comment I now see that I used the wrong version of the Render function for the code review... The version in the video is for the instanced case (even though I haven't done a tutorial on instancing...) which is why glDrawElementsInstancedBaseVertex is used instead of the regular glDrawElementsBaseVertex. The file has changed a lot since then but you can simply take a look at the render function in 527 to see what I was supposed to review. The material stuff is basically the same in both versions so no problem. Thanks!
@leoncampbell6690
@leoncampbell6690 4 ай бұрын
Where do u add in the file for the textures and obj aka like /Users/source/wine_barrel_01_4k.blend/ then textures? and obj?
@OGLDEV
@OGLDEV 4 ай бұрын
A wavefront model (obj file) has an optional config for a material file: mtllib The material file can include the following: map_Kd This texture is considered the diffuse texture. See the wavefront specification for more texture types.
@leoncampbell6690
@leoncampbell6690 4 ай бұрын
so do i add the downloaded wine barrel file as a whole to the main.cpp or like tutorial 19 eg if (!pMesh->LoadMesh("/User/leonc/source/repos/All/Vid1/18/wine_barrel_01_4k.blend/barrel.obj")) { return false; } but if i add this how does it understand or get the textures? (if you dont understand my question i can try to explain it in a different way)@@OGLDEV
@OGLDEV
@OGLDEV 4 ай бұрын
Hmm, I can't find the obj file on polyhaven.com. There are different file types there now. In general, when you use an obj file you should also get the mtl file and all the textures and place them relative to the obj file according to how the path in the obj and mtl. So if you use my class you only need to load the obj and it should load the textures. If it can't find the textures it will tell you the missing texture path.
@OGLDEV
@OGLDEV 4 ай бұрын
I just remembered that I downloaded the 'blend' model and exported it from Blender to obj. Make sure to export the textures as well and set the texture path to relative. This will create the mtl file for you with the paths as I described.
@leoncampbell6690
@leoncampbell6690 4 ай бұрын
Perfect thanks I got that to work@@OGLDEV
@susobhandas6143
@susobhandas6143 2 жыл бұрын
Hello sir, I do not know your background - can you show, how to write - game engine editor, level building, animation system, asset loading, and building UI including - Game settings.
@OGLDEV
@OGLDEV 2 жыл бұрын
I'm not an expert on game engine design but I'm thinking about doing a few videos in the future about this topic, based on a few books that I'm reading. Are you familiar with the game engine series by The Cherno?
@susobhandas6143
@susobhandas6143 2 жыл бұрын
@@OGLDEV Maybe I would watch cherno's series again - too many overheads, I left the channel, instead of saying in short - too long unnecessary video. Yes - he have imgui editor video.
@OGLDEV
@OGLDEV 2 жыл бұрын
Yes, It's quite a challenge doing a game engine series because if you simply develop it in front of your audience you're going to have a lot of material which may not interest most people. Balance is key.
@giovannisolimeno5040
@giovannisolimeno5040 2 жыл бұрын
that would take something like a year of full time recording i gues. You might be interested in The Cherno though, he makes video about game engines dev
@kennedywee
@kennedywee 2 жыл бұрын
Hello sir, im new to programming but I must ask why do I get "Loaded diffuse texture 'D:/Downloads/wine_barrel_01_4k/textures/wine_barrel_01_diff_4k.jpg' Can't load texture from 'D:/Downloads/wine_barrel_01_4k/textures/wine_barrel_01_rough_4k.jpg' - Unable to open file"? I'm running on windows 11😅
@OGLDEV
@OGLDEV 2 жыл бұрын
I assume that you downloaded the wine barrel model using the link in the video description and extracted it under D:\Downloads, is that correct? Seems like the diffuse texture was loaded but the roughness texture was not. Can you please check whether D:/Downloads/wine_barrel_01_4k/textures/ has four textures?
@kennedywee
@kennedywee 2 жыл бұрын
@@OGLDEV Thank you for reply😄. It appears that the link provided is missing one texture file that I need to convert from EXR to JPG.
@OGLDEV
@OGLDEV 2 жыл бұрын
I checked the original zip from the website again and there are four textures there out of which we load two - wine_barrel_01_diff_4k.jpg as the diffuse texture and wine_barrel_01_rough_4k.jpg as the specular texture. There is a EXR file as well but it is currently not used in my implementation.
Diffuse Lighting // OpenGL Beginners Series
21:20
OGLDEV
Рет қаралды 7 М.
An introduction to Shader Art Coding
22:40
kishimisu
Рет қаралды 888 М.
McDonald’s MCNUGGET PURSE?! #shorts
00:11
Lauren Godwin
Рет қаралды 35 МЛН
Маленькая и средняя фанта
00:56
Multi DO Smile Russian
Рет қаралды 2,8 МЛН
ШЕЛБИЛАР | bayGUYS
24:45
bayGUYS
Рет қаралды 601 М.
Text to 3D is AWESOME now! - AI Tools you need to know
10:51
Olivio Sarikas
Рет қаралды 126 М.
Lights and Shadows in Graphics - Computerphile
8:49
Computerphile
Рет қаралды 160 М.
LIGHTS! // Hazel Engine Dev Log
12:36
The Cherno
Рет қаралды 31 М.
Interactive Graphics 08 - Lights & Shading
1:12:40
Cem Yuksel
Рет қаралды 9 М.
How Shaders Work (in OpenGL) | How to Code Minecraft Ep. 3
30:48
GamesWithGabe
Рет қаралды 106 М.
I Made a Graphics Engine
6:42
Zyger
Рет қаралды 237 М.
BASIC 3D GAME ENGINE based on Hazel! // Code Review
35:15
The Cherno
Рет қаралды 63 М.
Vertex Array Objects // OpenGL Beginners Series
12:11
OGLDEV
Рет қаралды 13 М.
ChatGPT’s Amazing New Model Feels Human (and it's Free)
25:02
Matt Wolfe
Рет қаралды 175 М.
Specular Lighting  // OpenGL Beginners series
23:00
OGLDEV
Рет қаралды 5 М.
McDonald’s MCNUGGET PURSE?! #shorts
00:11
Lauren Godwin
Рет қаралды 35 МЛН