NOTE: If you are having trouble loading in the models in this tutorial, it might be because the names of the textures are "diffuse" and "specular" instead of "baseColor" and "metallicRoughness" like in the previous tutorial. To fix this simply make the 'getTextures' function accept "baseColor" or "diffuse" and "metallicRoughness" or "specular" like this: if (texPath.find("baseColor") != std::string::npos || texPath.find("diffuse") != std::string::npos) else if (texPath.find("metallicRoughness") != std::string::npos || texPath.find("specular") != std::string::npos) Also note that in the Vertex Shader I removed the negative sign from the rotation matrix!
@SB-rf2ye3 жыл бұрын
massively underrated channel!!
@VictorGordan3 жыл бұрын
Thank you :,)
@PhamAnhKhoa1183 жыл бұрын
Hi Victor Gordan, there is one thing unclear in my mind about this equation in the fragment shader: FragColor = direcLight() * (1.0f - depth) + vec4(depth * vec3(0.85f, 0.85f, 0.90f), 1.0f); From what I see, the first part of the equation is about to adjust the strength of direction light. The depth value run from 0.0f to 1.0f, so this part will be between 0.0f and direcLight(). That means when we are close to the object (depth close to 0.0f), we get the object brighter - we see it clearer and vice verse. The second part is to adjust the strength of the background color. The principle is the same: we are close to the object, the background color seem to be brighter and vice verse. In short, the first part of the equation is for the object (trees and ground) while the other is for the surrounding color. Is that true???
@VictorGordan3 жыл бұрын
Hmmm, I wrote it like shit from a readability perspective 💀 I should have put the depth outside the vec4() to make it more clear that it is a linear interpolation. You got the first part right. When you are close to the object, you see its full color while when it's far away the object becomes black. The second part of the equation is there to not make the object black at a distance, but instead make it the color of the background so that it blends in with the background... 😅 I could also have written it like this: FragColor = mix(directLight(), backgroundColor, depth);
@PhamAnhKhoa1183 жыл бұрын
@@VictorGordan thank you bro!
@sephjfox7 ай бұрын
this video is an absolute lifesaver 🥰
@PhamAnhKhoa1183 жыл бұрын
I am learning OpenGL as well. When i first tried to lauch your codes in the 14 lesson, I faced an error on my computer with the fragment shader. That is: SHADER_COMPILATION_ERROR for:FRAGMENT ERROR: 0:113: '=' : syntax error syntax error I checked again and again but I didn't see any problem with the syntax but whenever I built, the error showed up, giving me a blank screen. Do anyone have any situation like me??? Anyway thanks a lot Victor Gordan for this useful tutorial!!!
@VictorGordan3 жыл бұрын
Glad you liked the tutorial! That error just looks like a syntax error for the Fragment Shader. Without seeing your code though, I can't really help you. But since it specifies an equal sign maybe you wrote "=" instead of "=="? Or you forgot a semicolon somewhere.
@PhamAnhKhoa1183 жыл бұрын
@@VictorGordan Thanks for replying me! I already figured out the root of my problem. That was this line in the fragment shader: float logisticDepth(float depth, float steepness = 0.5f, float offset = 5.0f) I don't know much about graphic programming, OpenGL and stuff around like GLSL you know. So I can not explain why this is helping me that when I removed the 2 default arguments in the above function (I actually place them in the function body) and It worked. I searched for some helps in "Stack Overflow" and there were some people already dealt with this error but no clear answers were given, maybe something with the graphic card that decide whether or not we can use default arguments in the GLSL function. English is not my mother language so please feel free if I had made any mistakes.
@VictorGordan3 жыл бұрын
The problem was that you tried to use default parameters, but GLSL doesn't support those sadly :/ Glad you figured it out in the end!
@PhamAnhKhoa1183 жыл бұрын
@@VictorGordan haha, one lesson to know about GLSL
@keithle_ Жыл бұрын
So how did you fix this problem? I tried copying Victor's code and it's still the same error Also, chào đồng hương
@victorchalamet1170 Жыл бұрын
Hey, i have an issue, when i load the ground and tree model, they are upside down. Any idea of how to fix this ?
@ksriharsha29113 жыл бұрын
Subbed,shared,liked,saved😷
@MooNDesigns3 жыл бұрын
Thanks!
@VictorGordan3 жыл бұрын
You're welcome! :)
@josiahgil5 ай бұрын
i've been wondering if it is possible to create a pixel depth offset effect in blender, like it is works in ue5, blender can do parallax occlusion, i just want to learn how pixel depth offset would work in blender.
@manpotato2954 ай бұрын
If you guys got flipped screen positionY: make -rotation -> rotation in default.vert curPos = vec3(model * translation * rotation * scale * vec4(aPos, 1.0f));
@notballai11 күн бұрын
Life saver
@davidmakowka922 Жыл бұрын
Thanks!!!
@md.mazharulislam34933 жыл бұрын
Thanks 👍.
@VictorGordan3 жыл бұрын
No problem haha
@maxencedupont55233 жыл бұрын
Hi Victor, great video as always ! I built a hexagonal map and I want to know if the mouse is on a particular hex, whatever the position of the camera, to be able to select the hexes in real time with the mouse. I think the best way to do that is to use the Depth Buffer, to detect if the mouse is over a particular hex or not. Should I try to consider the mouse as a 3D object ?
@VictorGordan3 жыл бұрын
You can do this in multiple ways. Using the depth buffer would be one way of doing it, but it seems a bit complicated. What I would do in this case is give each hex a unique color and render the scene in a framebuffer without any sort of fancy stuff, just the scene with pure colors. Then check the mouse position, and see what pixel is at the mouse's position. Then you'll know which hex you are on since they all have a unique color ;) Hope that helps!
@maxencedupont55233 жыл бұрын
@@VictorGordan Oh, I see ! I have no idea on how to make this framebuffer, but I'll try. Thanks !
@chingching954 Жыл бұрын
why is it upside down? i got upside down result. please help :(
@VictorGordan Жыл бұрын
You probably just made a typo somewhere by putting a minus where there shouldn't be one
@lanchanoinguyen2914 Жыл бұрын
Please help,my geometries have z buffer malfunction,when looking at a specific angle like 0 degree,the texture seem right but when multiply it with a rotation matrix,it become fail of depth testing at 180 degree.
@VictorGordan Жыл бұрын
Not quite sure what you just said, but if you have a problem with textures and rotation, then it sounds like you are applying a rotation matrix to your texture UVs
@lanchanoinguyen2914 Жыл бұрын
@@VictorGordan no,i mean the z value seems wrong.the object behind not being hidden.Basically,the z does not change when rotation happen,so that it only correct at half of the rotation cycle.When look back,the behind object still in front.
@VictorGordan Жыл бұрын
Oh ok, interesting. Sounds like something might be wrong with the projection matrix? I'm honestly unsure what could caude this. It does sound like some value should be negative but it becomes positive instead, or the opposite...
@lanchanoinguyen2914 Жыл бұрын
@@VictorGordan ok thanks for replying
@lanchanoinguyen2914 Жыл бұрын
@@VictorGordan hey man,i fixed my problem.it turns out that i need to set gl_fragdepth manually,assign it with z after transform matrices.This answer here may help some people in the future.
@NickProkhorenko4 ай бұрын
Depth test doesn't work for me...
@adityawildan7 Жыл бұрын
Can i use this for shadow map?, I working on android version and only this method possible to show depth.
@VictorGordan Жыл бұрын
Yeah, you can use this for shadow maps. I also have a tutorial on shadow maps ;)
@oscarbayton11182 жыл бұрын
has anyone had a problem where the ground and the trees are upside down?
@BryseMeijer2 жыл бұрын
Strange. My trees are upside down as well. The author provided a comment saying that he removed the inverse on rotation in the vertex shader. Before: currentPos = vec3(model * translation * -rotation * scale * vec4(aPos, 1.0f)); After: currentPos = vec3(model * translation * rotation * scale * vec4(aPos, 1.0f)); This fixed my upside down trees.
@lukasjetu977610 ай бұрын
for some reason, loading different models works, but it has the same texture as the sword, loading in just the ground and trees without the sword does work, but it has no texture, it's black; loading in the sword but not drawing it results in again, everything having the sword texture
@lukasjetu977610 ай бұрын
ohhh, i fixed it, it's in the comment from Victor Gordan, in Model class, at line 250 or something, you have to change "if (texPath.find("baseColor") != std::string::npos)" _to_ "if (texPath.find("baseColor") != std::string::npos || texPath.find("diffuse") != std::string::npos)" _and_ "else if (texPath.find("metallicRoughness") != std::string::npos)" _to_ "else if (texPath.find("metallicRoughness") != std::string::npos || texPath.find("specular") != std::string::npos)"
@ksriharsha29113 жыл бұрын
🔥🔥🔥🔥
@VictorGordan3 жыл бұрын
😎
@CaarabaloneDZN Жыл бұрын
Great video
@coinnerd96333 жыл бұрын
hey my name is also Victor and I also have a youtube channel! ahahha