Blending in OpenGL

  Рет қаралды 66,236

The Cherno

The Cherno

6 жыл бұрын

Patreon ► / thecherno
Twitter ► / thecherno
Instagram ► / thecherno
Discord ► thecherno.com/discord
Series Playlist ► thecherno.com/opengl
Thank you to the following Patreon supporters:
- Dominic Pace
- Kevin Gregory Agwaze
- Sébastien Bervoets
- Tobias Humig
- Peter Siegmund
- Kerem Demirer
Gear I use:
-----------------
BEST laptop for programming! ► geni.us/pakTES
My FAVOURITE keyboard for programming! ► geni.us/zNhB
FAVOURITE monitors for programming! ► geni.us/Ig6KBq
MAIN Camera ► geni.us/t6xyDRO
MAIN Lens ► geni.us/xGoDWT
Second Camera ► geni.us/CYUQ
Microphone ► geni.us/wqO6g7K

Пікірлер: 121
@lahusa_
@lahusa_ 6 жыл бұрын
These presentations are actually really good (Maybe you could stylize them according to your video/channel color palette)
@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.
@rynho7255
@rynho7255 5 жыл бұрын
Damn those slides are so good man. Keep them up, they really help us understand better than just showing pieces of code.
@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!
@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!
@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.
@789blablajaja
@789blablajaja 5 жыл бұрын
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 5 жыл бұрын
Also, amazing video! Powerpoint was used so well, and your explanations were so simple yet precise.
@Gettingitfiguredout
@Gettingitfiguredout 5 жыл бұрын
Thought the power point was really helpful, thank you for taking the time.
@michaldvorak2230
@michaldvorak2230 6 жыл бұрын
Really a fan of this presentations style of teaching, would definitely be delighted to see it in your future videos!
@vectork3
@vectork3 3 жыл бұрын
Thanks Cherno! I really like this new presentation style. Its really easy to understand. Love from Nepal :D
@davidhall7275
@davidhall7275 3 жыл бұрын
I love this quote : It is really quite simple once you understand how it works.
@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.
@aura-audio
@aura-audio 4 жыл бұрын
Loved the powerpoint presentations! I understand this concept very well now!
@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.
@ibrahimrashwan
@ibrahimrashwan Жыл бұрын
Totally in with the that new style of using presentations simple & strait to the point and it's easy to understand
@jonathanorr5878
@jonathanorr5878 3 жыл бұрын
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.
@alexandrosmoysi7140
@alexandrosmoysi7140 2 ай бұрын
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!
@Puddlestomps
@Puddlestomps 6 жыл бұрын
The presentation was nice. Helps illustrate the concept.
@may007ank
@may007ank 6 жыл бұрын
That was very informative. I finally learned something I've been using for a long time, apparently, without understanding.
@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.
@tarasuzy00
@tarasuzy00 2 жыл бұрын
It's easy to understand. Very helpful!
@yuchen3587
@yuchen3587 5 жыл бұрын
Fantastic slides!
@jutuootv590
@jutuootv590 3 жыл бұрын
thank you so much, this really helped me creating a 2d lighting system for my project :D
@jeroenkoffeman9402
@jeroenkoffeman9402 4 жыл бұрын
And thanks for a very clear explanation video as always!
@RX7GSLSEowner
@RX7GSLSEowner 4 жыл бұрын
I like the powerpoint presentation. Thumbs up!
@shruikan123456789
@shruikan123456789 6 жыл бұрын
awesome slides!
@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 4 жыл бұрын
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 Жыл бұрын
@@taufiqulalam2035 Its not fairly accurate when one of them should be fully opaque.
@De_Cain
@De_Cain 4 жыл бұрын
Love this format, I understood your explanations much better with a pp.
@arget9272
@arget9272 6 жыл бұрын
I really like the PowerPoint presentation in an explanatory video like this one 👍🏻🤓
@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.
@eythimis
@eythimis 3 жыл бұрын
Awesome thx!!!!
@rudejehlici5425
@rudejehlici5425 4 жыл бұрын
Big like for the presentation! :D
@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 5 жыл бұрын
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 3 жыл бұрын
@@micheleabruzzese4499 I'm not sure if that's true 0.5 + 1 * (1 - 0.5 ) = 1.5 * 0.5 giving 0.75
@micheleabruzzese4499
@micheleabruzzese4499 3 жыл бұрын
@@Mugistan multiplication has priority over addition so it first multiplies dest_alpha times the parentheses, then adds src_alpha
@Mugistan
@Mugistan 3 жыл бұрын
@@micheleabruzzese4499 oh I misread I thought it as like this (0.5 + 1) * (1 - 0.5) sorry my mistake
@tomneijman4212
@tomneijman4212 3 жыл бұрын
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.
@yanko694
@yanko694 6 жыл бұрын
Loved the presentation! Have you got any plans to do a turn on glTF 2.0 integration?
@mngmn
@mngmn 2 ай бұрын
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?
@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 4 жыл бұрын
I am confused about that too...
@landrypierce9942
@landrypierce9942 6 жыл бұрын
Can you do a video about using SPIR-V in OpenGL?
@user-ub7mi2ou6v
@user-ub7mi2ou6v 2 жыл бұрын
Awesome!
@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 5 жыл бұрын
Mine is too, I don't know what's the deal with that.
@eriksimon6567
@eriksimon6567 5 жыл бұрын
are you using pngs? I used a jpeg and it worked fine because jpgs don't support transparency.
@mkgamesartvisuals
@mkgamesartvisuals 3 жыл бұрын
Thanks a lot!
@vertigo6982
@vertigo6982 5 жыл бұрын
What song is that in the intro? It's silky smooth.
@ty_teynium
@ty_teynium 6 жыл бұрын
Also you should have the slide available for download, for reference!
@pierre.vieira
@pierre.vieira 5 жыл бұрын
THANKS BRO
@joaopedrovoga5497
@joaopedrovoga5497 2 жыл бұрын
Nice explanation.
@charlesz88
@charlesz88 2 жыл бұрын
I LOVE the PowerPoint style.
@mayankshigaonker7725
@mayankshigaonker7725 4 жыл бұрын
I like this style
@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?
@emanuelkokovics
@emanuelkokovics 2 жыл бұрын
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).
@koungmeng
@koungmeng 4 жыл бұрын
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.
@sukhmandersingh4306
@sukhmandersingh4306 3 жыл бұрын
When are we gonna enable blending on logo on laptop's back?
@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.
@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
@senser1o76
@senser1o76 3 жыл бұрын
12:19 dangerous gest :D
@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.
@MrStarTraveler
@MrStarTraveler 3 ай бұрын
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.
@emilasplund4462
@emilasplund4462 6 жыл бұрын
Powerpoint idea = perfect!
@regbot4432
@regbot4432 3 жыл бұрын
So underrated episode...
@chiyungchu9463
@chiyungchu9463 2 жыл бұрын
WOW, your powerpoint background color so cool, how u blend that.
@benedikt7846
@benedikt7846 Жыл бұрын
Think I might just pass my exam thanks to this one
@raf.nogueira
@raf.nogueira 5 жыл бұрын
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.
@jingluntang7479
@jingluntang7479 3 жыл бұрын
OMG first time seeing a ppt
@dirtyblasion15
@dirtyblasion15 6 жыл бұрын
More than helpful
@aryesegal1988
@aryesegal1988 6 жыл бұрын
Aiii Cherno bruh, where are you flying to at the end of each video tho'? ;)
@chinmayanand896
@chinmayanand896 6 жыл бұрын
Hey cherno love you bro
@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.
@gregd6022
@gregd6022 3 жыл бұрын
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.
@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.
@jlewwis1995
@jlewwis1995 Жыл бұрын
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 8 ай бұрын
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.
@knayder42
@knayder42 6 жыл бұрын
Are you going to make video about Order Independent Transparency?
@MichaelYoussry
@MichaelYoussry 6 жыл бұрын
No more waving hands! 😢 jk, awesome presentation
@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.
@gliese436-b5
@gliese436-b5 6 жыл бұрын
The PowerPoint was a great idea in my opinion.
@Tetsujinfr
@Tetsujinfr 3 жыл бұрын
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.
@flusher84265
@flusher84265 4 жыл бұрын
Turning off blending yields the Charno logo
@deesrexcoding3564
@deesrexcoding3564 3 жыл бұрын
For some reason, it doesnt matter if I enable blending or not......
@vixellar7933
@vixellar7933 6 жыл бұрын
#notificationsquad
@slurpeesauce1750
@slurpeesauce1750 3 жыл бұрын
Why does ``` layout.Push(2) layout.Push(2) ``` work but ``` layout.Push(4) ``` does not
@pipding4368
@pipding4368 2 жыл бұрын
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
@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 3 жыл бұрын
I was thinking the same thing. I think the glass would actually multiply the colors rather than adding/averaging them.
@bor_kor
@bor_kor 2 ай бұрын
bro switched from normal tutorials to practice only ones, only to switch then to powerpoint presentations
@bor_kor
@bor_kor 2 ай бұрын
this is good tho, i like theory
@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 : )
@TheNeoxpert
@TheNeoxpert 5 жыл бұрын
Why you're not using Linux?
@mycollegeshirt
@mycollegeshirt 5 жыл бұрын
That's a lerp, no?
@lizzyfleckenstein9837
@lizzyfleckenstein9837 2 жыл бұрын
"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.
@devashish0312
@devashish0312 6 жыл бұрын
Please start uploading game engine series
@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.
@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
@slaincow4032
@slaincow4032 6 жыл бұрын
I’m only here for entertainment purposes 😂
@leonardomarinovic3492
@leonardomarinovic3492 6 жыл бұрын
Eeeeyyyyy wazzup guys chern0 here
Maths in OpenGL
18:07
The Cherno
Рет қаралды 83 М.
WHY did this C++ code FAIL?
38:10
The Cherno
Рет қаралды 44 М.
Indian sharing by Secret Vlog #shorts
00:13
Secret Vlog
Рет қаралды 51 МЛН
СҰЛТАН СҮЛЕЙМАНДАР | bayGUYS
24:46
bayGUYS
Рет қаралды 738 М.
Bro be careful where you drop the ball  #learnfromkhaby  #comedy
00:19
Khaby. Lame
Рет қаралды 41 МЛН
Projection Matrices in OpenGL
20:10
The Cherno
Рет қаралды 101 М.
OpenGL - transparency (alpha blending)
16:43
Brian Will
Рет қаралды 11 М.
Textures in OpenGL
31:44
The Cherno
Рет қаралды 166 М.
Harder Than It Seems? 5 Minute Timer in C++
20:10
The Cherno
Рет қаралды 73 М.
Maya Namespace and Prefix tips and tricks
14:36
My Oh Maya
Рет қаралды 70 М.
Making colored glass and other cool transparency effects
14:32
Quantum Developer
Рет қаралды 5 М.
rust runs on EVERYTHING (no operating system, just Rust)
18:10
Low Level Learning
Рет қаралды 343 М.
How I Deal with Shaders in OpenGL
21:15
The Cherno
Рет қаралды 170 М.
Writing Code That Runs FAST on a GPU
15:32
Low Level Learning
Рет қаралды 534 М.
Indian sharing by Secret Vlog #shorts
00:13
Secret Vlog
Рет қаралды 51 МЛН