For the final render submit code in 17:20, you need to make sure: 1. the transparent image should be rendered after the opaque image 2. If you follow the tutorial, then it should works. But if you add "glEnable(GL_DEPTH_TEST);" along with "glEnable(GL_BLEND);" in the init function in OpenGLRenderAPI.cpp file, then the position of the two images matter. The transparent image must be slightly in front of the opaque image to pass the depth test. Allow depth test is commonly used in 3D object rendering.
Thank you for this series Cherno! I have learned soo much as a programmer from learning to make this game engine. Code that used to confuse me, I now understand with ease! Thank you, thank you, thank you!!!
One minor thing to add is a technique called "Premultiplied Alpha" which achieves the same thing but without some artifacts you get from the standard alpha blending SRC_ALPHA and ONE_MINUS_SRC_ALPHA. This is very important for proper 3d alpha blend rendering, especially for foliage like grass. The problem is that due to mipmapping the GPU can interpolate pixels at the edge of transparent textures, which can create black fringes. You can fix this either by basically extending the texture outwards at the edge, so blending works as expected or you use the aforementioned technique premultiplied alpha. It works by using a blend mode of GL_ONE instead of SRC_ALPHA for the source color, but you have to do a preprocess step by premultipling every pixel by the corresponding alpha value. In fact the maths works out beautifully and you get the same result, without any artifacts and even slightly better performance due to one less multplication and possibly less state changes.
6:40 If you want to use bitwise operators, wouldn't the correct operator be OR? Since there might be a case where internalFormat and dataFormat might not be 0 but their bits don't overlap so the assert triggers. (I know what the GLenum values are for formats, and this problem will never come up, but better be safe)
I think that OR also can lead to incorrect results. And I think it's quite possible, if we extend API in future so API user can ask for specific format on GPU and assign it to internalFormat. Then we can and up with CPU data format RGBA, and GPU data format RGB. So in that case: internalFormat == 3 dataFormat == 4 3 == 0110 4 == 1000 0110 & 1000 == 0000 However if we use "OR", then we run in to problem if lets say API user asks for RGB, but loading texture fail, and we end up with: internalFormat == 3 dataFormat == 0 3 | 0 == 3
@@beaumanVienna This is old but I'll answer. Logically you want to make sure internalFormat and dataFormat are never 0. The code in the video is very basic and so you either set both or never set both; However, in the future you might want special cases and end up with one variable set to 0 (See previous comments). So boolean AND will cover those future cases. Honestly, it doesn't matter. Don't get too caught up in this piece of code. Just understand the implications.
Unfortunately I am late to vote, but why on earth would the majority vote for 2D vs 3D?! We get the opportunity to have this genius break down something complex (and arguably more useful in the industry) VS something less complex - and the majority voted for the latter? :(
That was my thoughts, the whole point of this shouldnt be "But I want to make a 2D game" it should be "I want to learn as much as possible" and 3D would be so much better for that. If people wanted to make 2D games, then they should make 2D games, not make a 2D game engine first.
Interesting, great work! I really wanna follow along but I’m confused right now as to what the current state of the engine, would be easier to follow through once it’s out completely. Any idea as to how long the completion of this would take Cherno? Anyone?
I missed the poll, but I am curious... did you poll Patreons only or your entire RUclips audience? I suppose it depends on why you are doing this all in the first place but I guarantee the vast majority of the people paying for this series want 3D exclusively and you are going to lose us all.
@@bies_moron4404 You're right, there'll always be something to gain from it. I'm just cut coz my implementation has diverged so far from stock Hazel and I was desperately waiting for Cherno to rein me back in. Now I'm just gonna write myself deeper and deeper into a 4D spaghetti wonderland.
I miss the voting as well, but I'm for 2D. At first I thought that I would prefere 3D. But then I reminded my self why I started watching this. We can learn doing 3D in OpenGL from almost any OpenGL tutorials, including on on this channel. But from this series I want to learn how to set up and organise everything for project as big as Game Engine ? How to create GUI for editor so it will be easy for game designed to work with and easy for programmer to improve ? How to name classes and namespaces so it will make sense ? And this is complicated topic by it self even without 3D. Belive me, I tried many times :) And 3D will be added later on any way.
For the final render submit code in 17:20, you need to make sure:
1. the transparent image should be rendered after the opaque image
2. If you follow the tutorial, then it should works. But if you add "glEnable(GL_DEPTH_TEST);" along with "glEnable(GL_BLEND);" in the init function in OpenGLRenderAPI.cpp file, then the position of the two images matter. The transparent image must be slightly in front of the opaque image to pass the depth test. Allow depth test is commonly used in 3D object rendering.
Man, making this series must be a challenge to you! Cause this is mind blowing good!!
It doesnt matter in this case, but binary AND can result in 0 even with two non-zero arguments.
Thank you for this series Cherno! I have learned soo much as a programmer from learning to make this game engine. Code that used to confuse me, I now understand with ease! Thank you, thank you, thank you!!!
Man as soon as I finish preparing for masters entrance exam I'm going through this series. It's so good
Can't wait to see Cherno integrating other renderer APIs (especially DirectX) :)
u probably meant Direct3D
any recommended DirectX books and videos?
@@hazzardmaddison4971 check out ChilliTomatoNoodle's tutorials
Thank you for making this series Yan. What you're creating is truly something awesome and useful, and there is so much I have learnt from it.
One minor thing to add is a technique called "Premultiplied Alpha" which achieves the same thing but without some artifacts you get from the standard alpha blending SRC_ALPHA and ONE_MINUS_SRC_ALPHA. This is very important for proper 3d alpha blend rendering, especially for foliage like grass. The problem is that due to mipmapping the GPU can interpolate pixels at the edge of transparent textures, which can create black fringes. You can fix this either by basically extending the texture outwards at the edge, so blending works as expected or you use the aforementioned technique premultiplied alpha. It works by using a blend mode of GL_ONE instead of SRC_ALPHA for the source color, but you have to do a preprocess step by premultipling every pixel by the corresponding alpha value. In fact the maths works out beautifully and you get the same result, without any artifacts and even slightly better performance due to one less multplication and possibly less state changes.
drinking game: take a shot each time he says "cherno logo"
Thanks! Really learning a lot!
thanks!
6:40 If you want to use bitwise operators, wouldn't the correct operator be OR? Since there might be a case where internalFormat and dataFormat might not be 0 but their bits don't overlap so the assert triggers. (I know what the GLenum values are for formats, and this problem will never come up, but better be safe)
I think that OR also can lead to incorrect results.
And I think it's quite possible, if we extend API in future so API user can ask for specific format on GPU and assign it to internalFormat. Then we can and up with CPU data format RGBA, and GPU data format RGB.
So in that case:
internalFormat == 3
dataFormat == 4
3 == 0110
4 == 1000
0110 & 1000 == 0000
However if we use "OR", then we run in to problem if lets say API user asks for RGB, but loading texture fail, and we end up with:
internalFormat == 3
dataFormat == 0
3 | 0 == 3
@@peterSobieraj That's why boolean AND is the safest, less hassle way.
@@jamesmnguyen Yes. I agree.
@@jamesmnguyen If we're always setting both at the same time, why do you want to AND them?
@@beaumanVienna This is old but I'll answer. Logically you want to make sure internalFormat and dataFormat are never 0. The code in the video is very basic and so you either set both or never set both; However, in the future you might want special cases and end up with one variable set to 0 (See previous comments). So boolean AND will cover those future cases.
Honestly, it doesn't matter. Don't get too caught up in this piece of code. Just understand the implications.
I love this series!I will activate the pettreon on 1 September
So GOOD! Keep it up bruder!
Unfortunately I am late to vote, but why on earth would the majority vote for 2D vs 3D?!
We get the opportunity to have this genius break down something complex (and arguably more useful in the industry) VS something less complex - and the majority voted for the latter? :(
I am thinking about the same thing
That was my thoughts, the whole point of this shouldnt be "But I want to make a 2D game" it should be "I want to learn as much as possible" and 3D would be so much better for that. If people wanted to make 2D games, then they should make 2D games, not make a 2D game engine first.
Hey cherno, what is the name of this cool song at the beggining of your videos?
What about blending in fragment shader?
Is this gonna be "real engine" like Godot ?
👍👍👍👍👍
why there is alpha blending only?
does alpha blend enough for flame effect?
and where is realization for Add, Subtract, Multiply, Overlay, etc?
Interesting, great work!
I really wanna follow along but I’m confused right now as to what the current state of the engine, would be easier to follow through once it’s out completely.
Any idea as to how long the completion of this would take Cherno? Anyone?
I missed the poll, but I am curious... did you poll Patreons only or your entire RUclips audience? I suppose it depends on why you are doing this all in the first place but I guarantee the vast majority of the people paying for this series want 3D exclusively and you are going to lose us all.
Entire RUclips
It seems like everyone is missing the point that he is still doing 3D. The poll was for which one to do first.
i am paying for knowledge (not for 2D/3D) :D
@@bies_moron4404 You're right, there'll always be something to gain from it. I'm just cut coz my implementation has diverged so far from stock Hazel and I was desperately waiting for Cherno to rein me back in. Now I'm just gonna write myself deeper and deeper into a 4D spaghetti wonderland.
I miss the voting as well, but I'm for 2D.
At first I thought that I would prefere 3D.
But then I reminded my self why I started watching this.
We can learn doing 3D in OpenGL from almost any OpenGL tutorials, including on on this channel.
But from this series I want to learn how to set up and organise everything for project as big as Game Engine ?
How to create GUI for editor so it will be easy for game designed to work with and easy for programmer to improve ?
How to name classes and namespaces so it will make sense ?
And this is complicated topic by it self even without 3D. Belive me, I tried many times :)
And 3D will be added later on any way.
I don't like your new style of thumbnails.
First