Blending in OpenGL

  Рет қаралды 69,960

The Cherno

The Cherno

Күн бұрын

Пікірлер: 125
@lahusa_
@lahusa_ 6 жыл бұрын
These presentations are actually really good (Maybe you could stylize them according to your video/channel color palette)
@diontryban5645
@diontryban5645 6 ай бұрын
😊
@rynho7255
@rynho7255 6 жыл бұрын
Damn those slides are so good man. Keep them up, they really help us understand better than just showing pieces of code.
@ucmRich
@ucmRich 6 жыл бұрын
The "way" you designed your ppt presentation to coincide with how you teach is brilliantly on target. My brain gets it! thank you! ** also thank you for everyone helping to support him!
@PenguinMaths
@PenguinMaths 5 жыл бұрын
Love the powerpoint! As some others have pointed out, I'm confused why layering a semi transparent color over a fully opaque color would yield a semi transparent color, as shown in the alpha channel of the last slide. Great series.
@no5x937
@no5x937 3 жыл бұрын
This is your most professional presentation/tutorial. Having a written power point presentation greatly improves your presentation style, keeps you focused on top in the correct sequence, and helps eliminate the unnecessary meanderings and ramblings. I strongly recommend you create a PPT presentation as a reference to your future tutorial videos. Keep up the great work!
@789blablajaja
@789blablajaja 6 жыл бұрын
Wow, about half a decade ago I learned Java from your videos. Now I am doing it professionally and when I search for an opengl problem I stumble across this. Huge nostalgia wave crushing over me.
@789blablajaja
@789blablajaja 6 жыл бұрын
Also, amazing video! Powerpoint was used so well, and your explanations were so simple yet precise.
@ZyklonV
@ZyklonV 6 жыл бұрын
That was a nice and concise presentation. It’s a good initiative and makes it clearer. Plus you can pause the video to think. A presentation + live coding is what most teachers do at university.
@Gettingitfiguredout
@Gettingitfiguredout 5 жыл бұрын
Thought the power point was really helpful, thank you for taking the time.
@Wout680
@Wout680 5 жыл бұрын
10:55 Does this mean that the overlap of the white square with the magenta rectangle has an alpha of 0.75? Seems weird how the opaque rectangle with the semi-opaque square creates a semi-opaque result. Or am I interpreting this wrong?
@PluginEverything
@PluginEverything 5 жыл бұрын
This confuses me too.
@goldenlava1019
@goldenlava1019 4 жыл бұрын
yeah
@taufiqulalam2035
@taufiqulalam2035 4 жыл бұрын
Imagine three glass shards on top of each other. This alpha value function was designed to simulate that. Kind of. But it can't really properly. but it's fairly accurate.
@cyqry
@cyqry 2 жыл бұрын
@@taufiqulalam2035 Its not fairly accurate when one of them should be fully opaque.
@alexandrosmoysi7140
@alexandrosmoysi7140 8 ай бұрын
Presentation is definetly a great tool for you, it lets you take your great explaining skills for code, and use them on non coding topics. Best course ever!
@davidhall7275
@davidhall7275 3 жыл бұрын
I love this quote : It is really quite simple once you understand how it works.
@aura-audio
@aura-audio 4 жыл бұрын
Loved the powerpoint presentations! I understand this concept very well now!
@ibrahimrashwan
@ibrahimrashwan 2 жыл бұрын
Totally in with the that new style of using presentations simple & strait to the point and it's easy to understand
@polaris911
@polaris911 6 жыл бұрын
I've been reading various guides online about this for the last couple days, I shoulda just watched this 12 minute video because you explained it better than any of them. Thanks for posting this, it really helps that you explained *conceptually* what is happening.
@koungmeng
@koungmeng 5 жыл бұрын
8:14 why do we need to calculate alpha value if we dont need that? we need only the RGB values to determine the color, the alpha value is meaningless to us because we use it to find the RGB.
@SuperKarlFriedrich
@SuperKarlFriedrich 4 жыл бұрын
you might use the blended color to calculate yet another blend behind that
@billypersistent6127
@billypersistent6127 4 жыл бұрын
Yeah, there's no destination alpha variable in any of the RGB equations.
@Neran280
@Neran280 4 жыл бұрын
Well actually we do not need the alpha value of the frame buffer in that case. There is no dst alpha variable for the RGB values involved. Because we specified SRC_ALPHA and ONE_MINUS_SRC_ALPHA it means that we just look at the shaders output alpha value (SRC_ALPHA) + are only interested in the RGB values of our current frame buffer to compute the final color not the alpha value in the current frame buffer. However we can only do this because we assume that the alpha value in the frame buffer is always 1, which makes sense in a game environment because you will always have something behind an object (IN THE END). In our case this is the black clear color or in a game you will have sky/background or something similar so your framebuffer will never have a non 1 alpha value. For example unity engine with its new renderer uses by default a destination buffer without alpha channel. If you use certain multipass effects you will have to store a new alpha value. One example in which you want to do this is if you want to do direct volume rendering by raycasting in your fragment shader. If you traverse your volume from front to back you can do early ray termination if your accumulated alpha is >= 1. Although you do not need to perform an actual OpenGL blending operation (because the blending is computed in your shader in this case) this accumulated alpha is equivalent to the dest_alpha. however the new alpha value computation is wrong because it does not make sense that an opaque color + an semi transparent color results in a semi transparent color. So in the last example A should equal to 1 and not 0.75. A_out = A_src + (1 - A_src) * A_dest The RGB values are correct.
@vectork3
@vectork3 4 жыл бұрын
Thanks Cherno! I really like this new presentation style. Its really easy to understand. Love from Nepal :D
@victorlucki8586
@victorlucki8586 6 жыл бұрын
The slides were a really good addition! They help visualize all the theory quite a bit. Please, so continue with them, if it's not too much work, of course.
@michaldvorak2230
@michaldvorak2230 6 жыл бұрын
Really a fan of this presentations style of teaching, would definitely be delighted to see it in your future videos!
@clem494949
@clem494949 6 жыл бұрын
In the last example: something semi-transparent (a=0.5) on top af something opaque (a=1) gives you something a bit transparent (a=0.75) ?
@micheleabruzzese4499
@micheleabruzzese4499 6 жыл бұрын
The equation is wrong for alpha channel, it should be: out_alpha = src_alpha + dest_alpha * (1 - src_alpha) If dest_alpha equals 1, then out_alpha also equals 1
@Mugistan
@Mugistan 4 жыл бұрын
@@micheleabruzzese4499 I'm not sure if that's true 0.5 + 1 * (1 - 0.5 ) = 1.5 * 0.5 giving 0.75
@micheleabruzzese4499
@micheleabruzzese4499 4 жыл бұрын
@@Mugistan multiplication has priority over addition so it first multiplies dest_alpha times the parentheses, then adds src_alpha
@Mugistan
@Mugistan 4 жыл бұрын
@@micheleabruzzese4499 oh I misread I thought it as like this (0.5 + 1) * (1 - 0.5) sorry my mistake
@tomneijman4212
@tomneijman4212 4 жыл бұрын
I noticed that too, but that's how the function in the example works (apart from if this is what you want). Cherno's calculation is right, see the OpenGl documentation: docs.gl/gl4/glBlendFunc.
@jonathanorr5878
@jonathanorr5878 4 жыл бұрын
This really helped thanks a lot for making these videos
@bjornbork7650
@bjornbork7650 6 жыл бұрын
I liked the powerpoint presentation, very professional, and hope to see more of them in the future.
@jutuootv590
@jutuootv590 3 жыл бұрын
thank you so much, this really helped me creating a 2d lighting system for my project :D
@Puddlestomps
@Puddlestomps 6 жыл бұрын
The presentation was nice. Helps illustrate the concept.
@RX7GSLSEowner
@RX7GSLSEowner 4 жыл бұрын
I like the powerpoint presentation. Thumbs up!
@yuchen3587
@yuchen3587 6 жыл бұрын
Fantastic slides!
@jeroenkoffeman9402
@jeroenkoffeman9402 4 жыл бұрын
And thanks for a very clear explanation video as always!
@tarasuzy00
@tarasuzy00 3 жыл бұрын
It's easy to understand. Very helpful!
@may007ank
@may007ank 6 жыл бұрын
That was very informative. I finally learned something I've been using for a long time, apparently, without understanding.
@jlewwis1995
@jlewwis1995 2 жыл бұрын
4:29 can't you technically do binary blending by discarding fragments with alpha < some.value in your fragment shader? The opengl wiki certainly says so, so I wouldn't say that literally *nothing* will happen if you disable blending, it's just that the blending that is still available isn't going to be all that useful unless you can specially get away with only having either solid or completely transparent pixels
@abcxyz5806
@abcxyz5806 Жыл бұрын
You can, but this is normally not called blending. Unity e.g. calls that Alpha Clipping. As you said, you cannot mix colors with this. However some engines can fake blending by using dithering, which has the benefit that the usual problems with transparency like front to back sorting do no apply.
@De_Cain
@De_Cain 4 жыл бұрын
Love this format, I understood your explanations much better with a pp.
@senser1o76
@senser1o76 3 жыл бұрын
12:19 dangerous gest :D
@emanuelkokovics
@emanuelkokovics 3 жыл бұрын
SO I thought about testing the program without: GLCall(glEnable(GL_BLEND)); GLCall(glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)); Expecting something distorted to render, but it renders the same, with same problem (rendering just bottom left corner).
@rudejehlici5425
@rudejehlici5425 4 жыл бұрын
Big like for the presentation! :D
@shruikan123456789
@shruikan123456789 6 жыл бұрын
awesome slides!
@brod515
@brod515 6 жыл бұрын
if by default it use 1 for the source and destination is 0 shouldn't the image with these settings just look like the cherno logo but with a black background? Why did the image with the default blending settings look very strange as though the actual image was corrupted in some way?
@hls333555
@hls333555 5 жыл бұрын
I am confused about that too...
@charlesz88
@charlesz88 2 жыл бұрын
I LOVE the PowerPoint style.
@ty_teynium
@ty_teynium 6 жыл бұрын
This is similar to the siggraph class lecture presentations, but from your own home, I did actually pick up a lot of what you were explaining this way, but it can be a lot of work that’s why I just wait for the code parts so that I can see what works and where to put them.
@arget9272
@arget9272 6 жыл бұрын
I really like the PowerPoint presentation in an explanatory video like this one 👍🏻🤓
@mkgamesartvisuals
@mkgamesartvisuals 3 жыл бұрын
Thanks a lot!
@landrypierce9942
@landrypierce9942 6 жыл бұрын
Can you do a video about using SPIR-V in OpenGL?
@eythimis
@eythimis 4 жыл бұрын
Awesome thx!!!!
@mukeshpareek5414
@mukeshpareek5414 6 жыл бұрын
Hi Cherno, First of all Thanks for making such awesome videos. Secondly, In my code if i comment out those two lines for blending. Still my texture is rendered perfectly. Can you explain that?
@haykav
@haykav 6 жыл бұрын
Mine is too, I don't know what's the deal with that.
@eriksimon6567
@eriksimon6567 6 жыл бұрын
are you using pngs? I used a jpeg and it worked fine because jpgs don't support transparency.
@yanko694
@yanko694 6 жыл бұрын
Loved the presentation! Have you got any plans to do a turn on glTF 2.0 integration?
@mngmn
@mngmn 9 ай бұрын
amazing series , kind of confused about 1 thing though, if the default when not blending is just 1 on all channnels of the source , then it should just nuke the existing buffer data, doesnt that mean that the texture you tried to use (the cherno logo) should just work and replace the old buffer?
@user-kq4fk9bl6d
@user-kq4fk9bl6d 6 жыл бұрын
Are you going to post a video on order independant transparency? I think its kinda hard to implement correct and i coulnt find anything on the internet.
@mayankshigaonker7725
@mayankshigaonker7725 4 жыл бұрын
I like this style
@joaopedrovoga5497
@joaopedrovoga5497 2 жыл бұрын
Nice explanation.
@fountainwindmill
@fountainwindmill 6 жыл бұрын
I really like the new powerpoints since I'm a visual learner. I get what you mean by just listening to you, but i had to concentrate less to achieve the same result using your powerpoint. But you can skip them if they take too long to make, they're not necessary, just preferable.
@ty_teynium
@ty_teynium 6 жыл бұрын
Also you should have the slide available for download, for reference!
@gregd6022
@gregd6022 4 жыл бұрын
cryptic explanation ... it simply "mixing" two inputs to get the output, each input has an "amount" coefficient (volume control). output is written to the buffer. (amount coefficients used are selected from a list of available options during setup). done.
@fencer9055
@fencer9055 3 жыл бұрын
I'm following along in Java, and when I tested a transparent texture without blending, it worked just fine. Why is that the case?
@user-dh8oi2mk4f
@user-dh8oi2mk4f 3 жыл бұрын
Does it still work if you manually disable blending?
@regbot4432
@regbot4432 3 жыл бұрын
So underrated episode...
@benedikt7846
@benedikt7846 2 жыл бұрын
Think I might just pass my exam thanks to this one
@pierre.vieira
@pierre.vieira 5 жыл бұрын
THANKS BRO
@emilasplund4462
@emilasplund4462 6 жыл бұрын
Powerpoint idea = perfect!
@webgpu
@webgpu 6 жыл бұрын
wkr? authors use cliffhanging to "force" viewers to watch the next video. But your videos are already interesting, we will certainly watch them as they come:) That presentation is great. Visual aids are very helpful to better understand the concepts you talk about.
@Влад-э7в2ь
@Влад-э7в2ь 3 жыл бұрын
Awesome!
@aljosaskorjanc1475
@aljosaskorjanc1475 6 жыл бұрын
Hello there Cherno! I have been trying to get a hold of LWJGL3 for quite some time now. Honestly, I find the learning confusing, due to the fact that there are just so many different sources. So my request is: Can you please make a video in which you explain how to learn OpenGL/LWJGL so that the learning curve is at it's optimum? Should we prefer to read books rather than follow "do this, do that" video tutorials on youtube? If so, which books do you advise us to read (and please, reference us to some good LWJGL books if there even are any because I have found none so far)? Should we follow online articles, blogs and tutorials about OpenGL? Should we study the OpenGL API in depth? (and if so, how?). Please, give us an overview of what way you think is the most productive to learn OpenGL/LWJGL. Yours sincerely, Aljoša
@Tetsujinfr
@Tetsujinfr 4 жыл бұрын
Thanks for that, but I think that if viewers are familiar with rgba components already then they should already understand blending and stuff like linear interpolation of alpha * src + (1-alpha) * dest. So good to know how to do it in opengl but I think a rgba basics separate video might be a better option (so that I can skip it and those lost can watch it). Just my 2 pennies here.
@jingluntang7479
@jingluntang7479 4 жыл бұрын
OMG first time seeing a ppt
@ben-nh9sn
@ben-nh9sn 6 ай бұрын
holy fuck the powerpoint is actually insane
@pranjalkhatri5631
@pranjalkhatri5631 5 ай бұрын
thank you!!!!!!!!!!!!!!
@chiyungchu9463
@chiyungchu9463 3 жыл бұрын
WOW, your powerpoint background color so cool, how u blend that.
@sukhmandersingh4306
@sukhmandersingh4306 3 жыл бұрын
When are we gonna enable blending on logo on laptop's back?
@MrStarTraveler
@MrStarTraveler 10 ай бұрын
This tutorial needs at leas one video on shader language. Last lesson new stuff was added to our shaders but I don't understand what that stuff is and where it comes from.
@chinmayanand896
@chinmayanand896 6 жыл бұрын
Hey cherno love you bro
@vertigo6982
@vertigo6982 5 жыл бұрын
What song is that in the intro? It's silky smooth.
@brod515
@brod515 6 жыл бұрын
I think this is great but I don't think the example you gave about see through a red and a blue glass will look purple is a good example. i think in a real life situation (not sure) the color you would see would be black. I feel like what were doing here in OpenGL with blending should refer to mixing colors as opposed to anything relating to lighting.
@Wout680
@Wout680 5 жыл бұрын
Would it be a dark-ish purple, the red followed by blue window? How could you achieve subtraction of colours when light is additive?
@wirosk2916
@wirosk2916 4 жыл бұрын
@@Wout680 Less amount of light is passing through each layer of glass making it appear darker. Maybe...
@philmsproduction
@philmsproduction 4 жыл бұрын
I was thinking the same thing. I think the glass would actually multiply the colors rather than adding/averaging them.
@raf.nogueira
@raf.nogueira 6 жыл бұрын
How its possible to find a internship or a job with Opengl and game engine development if have so many engines already made out there ? I learning very much, but i live in poor country there are no possibilities for me to work with this here, but i want so much.
@slurpeesauce1750
@slurpeesauce1750 3 жыл бұрын
Why does ``` layout.Push(2) layout.Push(2) ``` work but ``` layout.Push(4) ``` does not
@pipding4368
@pipding4368 3 жыл бұрын
It's because each time you call layout.Push(), you're telling your VertexBufferLayout about a new 'attribute' of your vertex. At this point, each of our vertices have 2 attributes - a position (which is made up of 2 floats) and a texture coordinate (which is also made of 2 floats). By calling layout.Push(4), you're telling your VertexBufferLayout that your vertices have 1 attribute, which is made up of 4 floats. This causes a problem when your shader tries to read the data from the buffer, since it's expecting 2 attributes but you only defined 1
@dirtyblasion15
@dirtyblasion15 6 жыл бұрын
More than helpful
@MichaelYoussry
@MichaelYoussry 6 жыл бұрын
No more waving hands! 😢 jk, awesome presentation
@knayder42
@knayder42 6 жыл бұрын
Are you going to make video about Order Independent Transparency?
@aryesegal1988
@aryesegal1988 6 жыл бұрын
Aiii Cherno bruh, where are you flying to at the end of each video tho'? ;)
@rhodexa
@rhodexa 4 жыл бұрын
I'm pretty sure that if you put a red glass in front of a blue one, the result color would be black... because the red glass will remove any blue light, letting only the red light to pass through. When it hits the blue glass, the red light will be absorbed (or reflected) and no light will be seen on the other side xD
@War4est
@War4est 4 жыл бұрын
Probably you didn't assume that the light could come not only from one direction.
@user-sl6gn1ss8p
@user-sl6gn1ss8p 3 жыл бұрын
@@rhodexa I think you can get something closer to that setting the source parameter to be the destination's color and the destination to zero. That way I think you "filter" the original color with the new one - if the red is pure red and blue is pure blue you get zero, but if they have common components those survive.
@rhodexa
@rhodexa 3 жыл бұрын
@@user-sl6gn1ss8p You're right. My point was that the 'real-life filter' wasn't a good analogy to what computers do to colors. • What filters do is subtract data from a source. (Passing red light through a blue filter will give nothing, cause no light was blue) • What OpenGL is doing is ‹combining›, adding data from two different sources. (you have a red light source, and a blue one. When mixed, produce a different light: magenta) Just a pedantic comment :D
@user-sl6gn1ss8p
@user-sl6gn1ss8p 3 жыл бұрын
@@rhodexa true : )
@gliese436-b5
@gliese436-b5 6 жыл бұрын
The PowerPoint was a great idea in my opinion.
@paulhorbenko9560
@paulhorbenko9560 2 жыл бұрын
In real life, if we put blue and red glass in front of each other, we won't have any color coming through at all(I believe). Since red glass only lets through the red light, and blue - blue.
@flusher84265
@flusher84265 5 жыл бұрын
Turning off blending yields the Charno logo
@adamodimattia
@adamodimattia 4 жыл бұрын
Great video, I wish I could have seen it when I was learning Unity’s HLSL, would have helped me a lot.
@lizzyfleckenstein9837
@lizzyfleckenstein9837 3 жыл бұрын
"When talking about graphics programming you actually have to tell the computer what you wanna do" Well, this pretty much goes for anything related to computers. Not only programming.
@bor_is_lov
@bor_is_lov 9 ай бұрын
bro switched from normal tutorials to practice only ones, only to switch then to powerpoint presentations
@bor_is_lov
@bor_is_lov 9 ай бұрын
this is good tho, i like theory
@deesrexcoding3564
@deesrexcoding3564 4 жыл бұрын
For some reason, it doesnt matter if I enable blending or not......
@c1337
@c1337 6 жыл бұрын
Hi can you make a tutorial about calloc, malloc, realloc and free functions in c++
@shruikan123456789
@shruikan123456789 6 жыл бұрын
This is C style
@mycollegeshirt
@mycollegeshirt 5 жыл бұрын
That's a lerp, no?
@TheNeoxpert
@TheNeoxpert 6 жыл бұрын
Why you're not using Linux?
@slaincow4032
@slaincow4032 6 жыл бұрын
I’m only here for entertainment purposes 😂
@Behiri
@Behiri 6 жыл бұрын
I'm hearing openGL is deprecated is that true?
@XxAl3X3IxX
@XxAl3X3IxX 6 жыл бұрын
couldn't find anything about that. Are you sure you can trust the sources that say that?
@SketchpunkLabs
@SketchpunkLabs 6 жыл бұрын
You only hear that because the Khronos Group now have the vulkan API, so at some point OpenGL will fade away. Last I read is that Khronos will continue to develop the OpenGL Api. But in all honestly, there is going to be a point where they can not dedicate resources to developing two different Graphic APIs. I believe android is looking to make vulkan their preferred api, windows never supported OpenGL passed version 1, anything afterwards are AMD / nvidia making their own drivers to use modern versions of opengl for windows. Then you have valve which is still developing SteamOS even though they stopped selling the hardware, they're big push is to improve Vulkan support on linux. You can also use vulkan to make games on the Nintendo switch. So its not deprecated but the writing on the wall is that when vulkan is mature enough, opengl will no longer be needed.
@leonardomarinovic3492
@leonardomarinovic3492 6 жыл бұрын
Eeeeyyyyy wazzup guys chern0 here
@vixellar7933
@vixellar7933 6 жыл бұрын
#notificationsquad
@devashish0312
@devashish0312 6 жыл бұрын
Please start uploading game engine series
@malharjajoo7393
@malharjajoo7393 Ай бұрын
This could have been explained in a much shorter video.
@ren69ade
@ren69ade 6 жыл бұрын
LIke the power point, better than waving hands and drawing imaginary boxes, and also better than live drawing in some drawing program.
Maths in OpenGL
18:07
The Cherno
Рет қаралды 87 М.
Projection Matrices in OpenGL
20:10
The Cherno
Рет қаралды 106 М.
黑天使被操控了#short #angel #clown
00:40
Super Beauty team
Рет қаралды 61 МЛН
We Attempted The Impossible 😱
00:54
Topper Guild
Рет қаралды 56 МЛН
1% vs 100% #beatbox #tiktok
01:10
BeatboxJCOP
Рет қаралды 67 МЛН
Shader Abstraction in OpenGL
21:56
The Cherno
Рет қаралды 78 М.
How Shaders Work in OpenGL
17:37
The Cherno
Рет қаралды 236 М.
Textures in OpenGL
31:44
The Cherno
Рет қаралды 175 М.
Creating Tests in OpenGL
22:46
The Cherno
Рет қаралды 41 М.
Model View Projection Matrices in OpenGL
15:53
The Cherno
Рет қаралды 89 М.
Is C BETTER than C++ for beginners? // Code Review
31:16
The Cherno
Рет қаралды 82 М.
Index Buffers in OpenGL
16:54
The Cherno
Рет қаралды 137 М.
Google’s Quantum Chip: Did We Just Tap Into Parallel Universes?
9:34
The Math behind (most) 3D games - Perspective Projection
13:20
Brendan Galea
Рет қаралды 428 М.