Тёмный

OpenGL Tutorial 21 - Instancing 

Victor Gordan
Подписаться 13 тыс.
Просмотров 20 тыс.
50% 1

Опубликовано:

 

15 окт 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 42   
@rileycampbell5691
@rileycampbell5691 6 месяцев назад
I cannot tell you how awesome this video series is. Thank you so much!
@Fabian-jw5ih
@Fabian-jw5ih 3 года назад
Very nice, perfectly solved my uniform problem as including the same mat4 for each vertex was huge waste of resources as well!
@VictorGordan
@VictorGordan 3 года назад
Glad I could help! :) Yeah, glVertexAttribDivisor is extremely helpful!
@rohanagarwal4569
@rohanagarwal4569 8 месяцев назад
Hi. It worked well for mw, but I have a question. We are linking attribute for location 4,5,6,7 but in the vertex shader we only access location 4 of the type mat4 so how does the shader know that it has to look further?
@LynJuice
@LynJuice 3 года назад
we need Animation mini-series and A video or two on user interface (buttons text etc)
@VictorGordan
@VictorGordan 3 года назад
I'll likely make an animation video in about 2 weeks. For UI you'll have to wait a few more months sadly, since I'll do Physics first after I'm done with OpenGL.
@VictorGordan
@VictorGordan 3 года назад
So it looks like I lied... I won't be making an animation tutorial this week since I am having compatibility issues between glm and the glTF format due to different standards for rotation related things. And I just can't figure out what the problem is and how to fix it. So I'll probably do like you said, and make an animation mini-series after the OpenGL series. Sorry :(
@LynJuice
@LynJuice 3 года назад
@@VictorGordan its ok
@oh-facts
@oh-facts 11 месяцев назад
Hi. This worked perfectly for me! I have a question. How would I go about updating the model matrices every frame? One way is to create a new vbo and bind it to the vao every frame. Is this the best way or would you suggest something else? Thank you!
@VictorGordan
@VictorGordan 11 месяцев назад
You should be able to simply update the VBO if I remember correctly
@maxencedupont5523
@maxencedupont5523 2 года назад
Hi Victor, great video as always ! I tried to implement instanciation into an hexagonal map, but I'm confronting several problems : - I need to associate an unique color to each hex in order to read correctly a framebuffer, but it's complicated to modify the VBO without a loop, as I have an unique big model. - Basic hexes will have the same model (a simple hexagon) with different textures, but some won't. Do I have to use, for each different model, an instanciation which groups all the hexagons using this model ? - Navigating around the map is very fast with this system, but modyfing the map with a mouse for example is very slow, because I have to recreate the full map for a single modification. Overall, I feel like instancing is powerful, but not very suitable for quickly modifying the generated objects., but I don't know if I am using this tool well. Should I try to implement it anyways ?
@VictorGordan
@VictorGordan 2 года назад
I don't really see why modifying the position/scale/rotation of a hex would be slow... you would just have to modify the part of the array corresponding to that hex. Same with uniqueness, just make an array with all the colors are send them as uniforms to the shader. I hope you know what I mean by an array, basically the same thing I did in the video with the translations. But yeah, I think it would be worth integrating it. Especially if you have hundreds of hexs. My guess is that it would help in the long-run. And it never hurts to practice something new ;)
@maxencedupont5523
@maxencedupont5523 2 года назад
@@VictorGordan I get the theory, but for the color uniqueness, when can I attribute the color to each hex, as the program is drawing the model once (I was changing the color with uniforms in the drawing loop)
@VictorGordan
@VictorGordan 2 года назад
I don't really understand your question 🤔
@maxencedupont5523
@maxencedupont5523 2 года назад
@@VictorGordan My bad, my structure made no sense. It works now :)
@VictorGordan
@VictorGordan 2 года назад
Good to hear!
@saranh1687
@saranh1687 3 года назад
victor,will you also include making game with opengl ,like what thinmatrix did,in jis opengl tutorials,but he did with java,and i need c++?can you later include opengl c++ game tutorial?no one has ever post any tutorial of it in c++
@VictorGordan
@VictorGordan 3 года назад
As far as I am aware he simply did tutorials on aspects of OpenGL, which is exactly what I am doing. But I won't be making a tutorial on how to make a specific game because I think that cookie-cutter game tutorials are useless. I cover different general aspects for graphics, and u create the game logic behind them, that's the idea behind my tutorials ;)
@saranh1687
@saranh1687 3 года назад
@@VictorGordan ok that would be nice too.thank you very much
@EMB3D-du6zn
@EMB3D-du6zn Год назад
what about shader buffer object in gl 4.2, instead of vertex attribs for the instance matrix?
@VictorGordan
@VictorGordan Год назад
That can work
@dmitrykolesnikovich
@dmitrykolesnikovich 2 года назад
Do you have strong understanding on why number of draw calls is a number one thing in a list of reasons that causes reduce of performace?
@VictorGordan
@VictorGordan 2 года назад
This might answer your question: stackoverflow.com/questions/4853856/why-are-draw-calls-expensive
@dmitrykolesnikovich
@dmitrykolesnikovich 2 года назад
@@VictorGordan am i get it correctly that real performance issue is with `bufferData` rather then with `drawElements`? So one should not be afraid to use much `drawXXX` stuff in his code?
@VictorGordan
@VictorGordan 2 года назад
I believe so, but I think it really depends from case to case. So just try stuff out and see what works best
@billybaloop
@billybaloop 29 дней назад
This is useful but it might be easier to follow if you use PPT/block diagrams instead of sped up code displays
@maxencedupont5523
@maxencedupont5523 2 года назад
Hi Victor, sorry to bother you again but I have some questions about the rotation matrix. I don't really understand how glm::mat4-_cast works, and I'm trying to rotate an hexagon horizontally with a 60° angle, then a 120° angle, then 180°, etc.. I assumed glm:::quat(1.00, 0.00, 0.00, 0.00) represents the absence of rotation and after many tests I found out sending glm::quat(0.87f, 0.0f, 0.5f, 0.0f); to the glm::mat4_cast function outputed (almost) a 60° horizontal rotation. But I don't get the formula behind it. Could you explain it to me ?
@VictorGordan
@VictorGordan 2 года назад
First of all, be careful since quaternions are sometimes written as xyzw, and sometimes as wxyz where w is the scaling factor, so just keep that in mind as a possible source of bugs. As for how they work, they are quite weird, give this a watch ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-d4EgbgTm0Bg.html
@maxencedupont5523
@maxencedupont5523 2 года назад
@@VictorGordan Thanks for the video, it works now! I used glm::quat(glm::radians([ glm::vec3 ofEuler Angles ])) for the conversion. Only problem I have is that the direcLight() fonction in the default shader applies after the rotation, so it looks bad...
@MrAkeboshiWind
@MrAkeboshiWind 2 года назад
I'm still kind of confused here. Isn't it super cumbersome if not impossible to update the model matrices per frame?
@VictorGordan
@VictorGordan 2 года назад
I mean yeah, in a real situation you would not want to send them every frame. But the main thing I wanted to show in this tutorial was how instancing works, not how to send data to the GPU effectively ;)
@starklosch
@starklosch 3 года назад
Better than UE xd. Btw, are you going to make a video for emissions? I'd like to see that
@VictorGordan
@VictorGordan 3 года назад
Thank you haha Yeah, I might do a video on emissions in the future!
@fudgeracoon2529
@fudgeracoon2529 3 года назад
So basically, batch rendering right?
@VictorGordan
@VictorGordan 3 года назад
No. Though they have similar effects in a way. The biggest difference is that batch rendering can have multiple models while instancing can only use one model. You can read about some more differences here: www.reddit.com/r/opengl/comments/gvsamp/batch_rendering_vs_instancing_when_to_use_which/? ,and here: www.gamedev.net/forums/topic/511579-batch-vs-instancing/511579/ Hopefully that clears things up! :)
@fudgeracoon2529
@fudgeracoon2529 3 года назад
@@VictorGordan Awesome, thanks for clearing it up!
@yeeteronipizza
@yeeteronipizza 3 года назад
Particle system time!
@CSShera
@CSShera Год назад
can different models be loaded to this project? If so how?
@VictorGordan
@VictorGordan Год назад
I use a pretty shitty model loader that I made in this series (it's quite limited in what it can do). I think it can load multiple models though... hence the Jupiter and asteroid models. If by your question you meant instancing multiple models, then for that you have two options. You either simply instance an extra model the same way as we did with this one, or you create "clusters" of models which basically means you combine multiple models into a single model in code and then instance that. Hope that helps ;)
@CSShera
@CSShera Год назад
@@VictorGordan Nice and thank you for your amazing tutorials!
@HrushikeshNaik1650763n73
@HrushikeshNaik1650763n73 2 года назад
I didn't understand a single thing
@VictorGordan
@VictorGordan 2 года назад
Sorry haha 😅
Далее
OpenGL Tutorial 22 - Anti-Aliasing (MSAA)
4:29
Просмотров 15 тыс.
Wildest 10 SECONDS OF HIS LIFE 🤯 @TomIsted
00:14
Просмотров 2,7 млн
Mübariz İbrahimovun atası vəfat etdi
00:14
Просмотров 103 тыс.
I Made a Graphics Engine
6:42
Просмотров 257 тыс.
Advanced OpenGL - Crash Course
49:51
Просмотров 69 тыс.
I tried coding my own graphics engine
4:23
Просмотров 206 тыс.
Batching in OpenGL
6:30
Просмотров 20 тыс.
OpenGL Tutorial 15 - Stencil Buffer & Outlining
8:20
Getting Started With Godot's Scene Instances
8:35
Просмотров 82 тыс.
Modern OpenGL Tutorial: Rendering a Colored Cube
11:47
Textures in OpenGL
31:44
Просмотров 172 тыс.