How To Create Animated Plants With Shaders

Поделиться
HTML-код
  • Опубликовано: 19 ноя 2024

Комментарии • 238

  • @paulbunyangonewild7596
    @paulbunyangonewild7596 10 месяцев назад +246

    The extra triangles trick is GOLDEN

  • @JMO-
    @JMO- 8 месяцев назад +62

    I love it when channels like this just randomly pop up in my recommendations! These types of channels are the very reason why the games I'm making are even playable lol. Thank you for the videos!

    • @Vercidium
      @Vercidium  8 месяцев назад +3

      Thank you so much!

  • @VerMishelb
    @VerMishelb 11 месяцев назад +131

    This channel has randomly appeared in my recommended feed and damn glad I am that it did. You have so much cool stuff here!

    • @Vercidium
      @Vercidium  11 месяцев назад +15

      Thank you so much! And I have even more videos planned

    • @matthewzeller5026
      @matthewzeller5026 10 месяцев назад +2

      ​@@Vercidium I just found your channel too and I'm really excited, really great context and explanations. Thanks for sharing these techniques.

    • @Vercidium
      @Vercidium  10 месяцев назад +1

      @@matthewzeller5026 no worries, thank you for the kind words!

    • @ADEPS.
      @ADEPS. 8 месяцев назад +1

      Yeah me too. I watch a lot of Blender and OpenGL tutorials

  • @lesheq85
    @lesheq85 11 месяцев назад +22

    I am surprised nobody is talking about the Netflix logo at 3:55
    Anyway, great video, don't know if if till ever help me, but at least it is something new

  • @ding-hobba
    @ding-hobba Год назад +119

    Mann this is extremely polished and well produced

  • @lenargilmanov7893
    @lenargilmanov7893 Год назад +419

    This is cool, but you can also precompute all vertex positions so that the shader doesn't have to do it every frame.

    • @Vercidium
      @Vercidium  Год назад +133

      Where would the precomputed data be stored? It’s performed every frame as it’s animated / blows in the wind

    • @Genebriss
      @Genebriss Год назад +84

      @@Vercidium in the fbx file 🙃

    • @Vercidium
      @Vercidium  Год назад +425

      @@Genebriss I tried writing an FBX parser once and ended up destroying half of downtown New York

    • @SimonBuchanNz
      @SimonBuchanNz Год назад +101

      ​@@Vercidiumnormally you have a "wind strength" vertex weight attribute or the like. It has the nice effect that you can reuse the same vertex shader for lots of different plants.

    • @Vercidium
      @Vercidium  Год назад +117

      @@SimonBuchanNz I see, I like it. The UV coordinates could be used as the weight attribute as it gives the top of the leaf a value of 1 and the base a value of 0

  • @unitrader403
    @unitrader403 9 месяцев назад +38

    “Go back and look at that fern. Stanley, this fern will be very important later in the story. Make sure you study it closely and remember it carefully.”

  • @bslayerw
    @bslayerw День назад +1

    This video series is very informative, I want more! I know it's been over a year since you made one, but if you make more I'll be back. RUclips needs more game dev content like this instead of another 10,000 videos on how to get started with Unity haha.

  • @js3671
    @js3671 9 месяцев назад +4

    As I am just beginning to learn about shaders I am really glad these videos popped up in my reccomended! Incredible stuff really looking forward to using some of these techniques in my own projects!

  • @negretedev
    @negretedev 11 месяцев назад +18

    I love this, your visualizations are so clear! Hope you will keep making more like this!

  • @Partickkkkkkk
    @Partickkkkkkk Год назад +12

    Amazing video, super informative, saving this for later!

  • @SillyOrb
    @SillyOrb 8 месяцев назад +1

    4:16 This is known as a degenerate triangle. Degeneracy in this context means that a portion of a shape is arranged in a collinear way. In the case of a triangle, when two or all three of its vertices overlap, the effective area becomes zero, so rasterisation is skipped. Using degenerate triangles in this way used to be called "stitching," but the term has multiple uses and the more general "batching" is more common these days. It was a form of batching triangle strips and (separately) fans back in the early days of OpenGL and hardware accelerators.

  • @mohammadalaaelghamry8010
    @mohammadalaaelghamry8010 10 месяцев назад +4

    This channel is a gem, great content. Thank you.

  • @DireWolfAirstrike
    @DireWolfAirstrike 10 месяцев назад +4

    The lighting in your fancy fern montage reminded me of a lighting trick that seems up your alley.
    You can bake animated shadows for any object-light pair where neither element's motion can be influenced by the player. Great for day-night cycles.

    • @Vercidium
      @Vercidium  10 месяцев назад +2

      Ooh how does that work?

    • @DireWolfAirstrike
      @DireWolfAirstrike 10 месяцев назад +2

      It's similar to existing methods of baking shadow maps, but you need some more metadata at compile time, and the process results in animated textures.
      Quick primer on shadow maps cuz I don't know who reads these:
      If you mark all the lights and objects that don't move in a scene, you can precompute the shadows for those things and save them as image textures. That way you don't have to do that expensive lighting math every frame for those objects. Nice!
      If you have moving lights or objects, they're traditionally excluded from this method, but they don't have to be, as long as you know what the movement is going to be. Take for example the position of the sun in a day/night cycle. Give the shadow baker a reference to the movement loop, and it should be able to do its normal process for every frame of that movement. Poof! Animated shadow map!
      If you have multiple lights or objects on loops, you have some options:
      1: You could bake a texture for each object-light pair, but then you'll undo all your hard work un-bottlenecking the cpu-gpu data pipeline.
      2: You could do #1, then extend the loops of each animated texture on a mesh to the least common multiple of their runtime, then squash down to a single animated texture. Unfortunately, that texture's loop could be as long as the longest loop times the number of lights in the scene.
      3: You could bake, for example, just the day/night cycle, expecting that should save you the most runtime computation.
      4: You can do something clever I haven't thought of to solve this problem.

    • @DireWolfAirstrike
      @DireWolfAirstrike 7 месяцев назад +1

      Update to the above: I'd probably just handle looping lights and stationary objects, since the kind of game that cares about this level of graphics optimization probably doesn't have many objects that move on loops anyway.

  • @fylkasalitheias
    @fylkasalitheias 11 месяцев назад +4

    Love your presentation. Even though I am not into video game development, I find this quite interesting.

  • @OmniMC
    @OmniMC 7 месяцев назад +1

    This is such a well explained video that now I feel I can read shader code no problem. Next step would be to learn to write it

  • @nycrea
    @nycrea 11 месяцев назад +6

    Great video, editing is great and your explanations are also very intuitive without getting into too much complexity right away.

  • @TheTimeshadows
    @TheTimeshadows 6 месяцев назад +1

    I love this!
    If i weren't unemployed, I would join your Patreon at a pay tier.
    Please do continue to share these with us here.

  • @sincog2010
    @sincog2010 11 месяцев назад +4

    Just discovered your channel. I recently got into game engine development, and the last few videos of yours have been interesting to watch, I love your approaches to optimization. Thank you, and I hope you continue to do tutorials and tips like this!

  • @coffzor123
    @coffzor123 10 месяцев назад +2

    Totally unvaluable knowledge being put out here for free, absolutley incredible tips and tricks.
    You popped up in my recommended and I wish you the best on youtube. :) Too good to miss a single video, subbed and notifications on. Keep up the good work! :D
    Hats off to you good sir.

    • @Vercidium
      @Vercidium  10 месяцев назад

      Thank you so much, I’m glad you like the videos!

  • @anzhel3268
    @anzhel3268 11 месяцев назад +2

    i love vertex instancing so much!

    • @Vercidium
      @Vercidium  11 месяцев назад +2

      It has so many applications! I try to use it wherever possible

  • @IamSH1VA
    @IamSH1VA 11 месяцев назад +2

    This is so cool, looks so natural & realistic.
    Thanks for detailed explanation & tutorial 🙏

  • @SeanStClair-cr9jl
    @SeanStClair-cr9jl 11 месяцев назад +4

    Loving the presentation quality of these videos so far! Excited to see where you take the channel!
    Also, I must say the terrain at 1:13 is bizarrely striking. I don't know what it is that seems so stylish and cohesive about it, but it's more mysterious and enticing than a lot of upcoming AAA game terrain lol.

  • @anilaxsus6376
    @anilaxsus6376 11 месяцев назад +2

    Amazing video man, amazing, good looking and infomative, gg.

  • @ImNotGam
    @ImNotGam Год назад +3

    Damn okay I didn't know you had editing skills as well as game dev skills.
    On the other hand, I'll be taking notes for when I continue messing around with OpenGL.

  • @Mark_Rober
    @Mark_Rober 11 месяцев назад +1

    Love the outro song dude! So nice to meet a fellow Punch Deck fan! Totally gotta sub.

    • @Vercidium
      @Vercidium  11 месяцев назад

      LOVE Punch Deck! We commissioned the whole Sector's Edge soundtrack from him and he did an amazing job. It's on Spotify :)

    • @Mark_Rober
      @Mark_Rober 11 месяцев назад +1

      @@Vercidium Oh so YOURE who made sectors edge!
      Halt State, Flow state, Fluid Dynamics are al some of my favourite songs of all time but The Vibe has achieved legendary status for having the best use of LFO's ive ever heard.

    • @Mark_Rober
      @Mark_Rober 11 месяцев назад +1

      @@VercidiumIf you like Punch Deck you might like Exyl, he has a similar style of music with really good dynamics with a sort of crisp ethereal sound. The only difference is that Exyl mostly makes dubstep:
      ruclips.net/video/EEnzDZFy5oY/видео.html

  • @maatte7093
    @maatte7093 7 месяцев назад +1

    you deserve 1 million sub no cap

  • @meanmole3212
    @meanmole3212 11 месяцев назад +2

    Nice stuff! I think twisting a leaf around an axis that goes parallel the leaf would add even more realism.

    • @sciencecompliance235
      @sciencecompliance235 11 месяцев назад +1

      Was thinking the same thing.

    • @Vercidium
      @Vercidium  11 месяцев назад

      I hadn't considered that! I'll give it a go

    • @sciencecompliance235
      @sciencecompliance235 11 месяцев назад

      @@Vercidium Honestly, I think even something like a vec3 wind uniform that includes x direction, y direction, and magnitude would improve this, too. Then you can bias the oscillations in the direction the wind is blowing ( and greater at the tips) and use a trig function composed of multiple sine functions with different periods to make it appear a bit gusty.

  • @koool56
    @koool56 11 месяцев назад +2

    Absolutely amazing video

    • @koool56
      @koool56 11 месяцев назад +2

      Looking forward to more videos! I just recently finally grasped OpenGL enough to understand what the hell is going on and got basic project going in Zig, really looking forward trying these things out! This channel will become big, especially if you keep making videos like these, just a question of time until algorithm picks you up. Thank you

    • @Vercidium
      @Vercidium  11 месяцев назад +2

      @@koool56 you are too kind, thank you! Nice work setting up your first project, you now have a canvas where you can create anything.
      Let us know if you have any specific questions, or if you’d like a video to cover something in detail.
      I also recommend learnopengl.com, I knew nothing about 3D rendering 6 years ago and this site taught me so much

  • @KevysNotHeavy
    @KevysNotHeavy 9 месяцев назад +1

    I just realized you 're the guy who made Sector's Edge (Love that game)

  • @Pockeywn
    @Pockeywn 11 месяцев назад +1

    i’m keeping an eye on your channel i feel like you’re gonna get big

  • @tobzdaman619
    @tobzdaman619 10 месяцев назад +1

    Instant sub. Thank you for this.
    You and Acerola are godsends to me at a time like this!

    • @Vercidium
      @Vercidium  10 месяцев назад +2

      That means a lot, I’m glad I can help!

  • @noahlederer8587
    @noahlederer8587 7 месяцев назад +1

    good fern montage at the end. I enjoyed my stay

    • @Vercidium
      @Vercidium  7 месяцев назад

      Thank you, I’m glad you did :)

  • @gokkiyoutube
    @gokkiyoutube 9 месяцев назад +1

    I was hoping you could render the leaves without textures, but this is cool!

    • @Vercidium
      @Vercidium  9 месяцев назад +2

      Might be able to replicate the texture procedurally one day, I’d love to try it!

  • @nameno7032
    @nameno7032 7 месяцев назад +1

    no word to describe, genius

  • @hannah42069
    @hannah42069 Год назад +15

    What's the advantage of doing this? Presumably mesh data only gets sent once at startup anyway, so shouldn't be too big of an impact?

    • @Vercidium
      @Vercidium  Год назад +26

      There’s a few advantages:
      - Each fern can have a different amount of leaves with varying sizes and orientations, making scenes look less repetitive. This can also be changed on the fly (no need to re-import from Blender or upload a new mesh to the GPU)
      - There's no vertex bandwidth. Each vertex shader can run without waiting for vertex data (model data) to be read from memory
      - One less matrix4 multiplication (64 multiplications and 48 additions) is performed per vertex, since it’s positioned and rotated using sin/cos instead

    • @gonderage
      @gonderage 11 месяцев назад +3

      ​@@VercidiumThat third explanation now makes your use of multiple trig functions make sense. I thought it was weird that you'd be using something expensive multiple times, but it turns out to be the cheaper alternative at scale.

    • @jnevercast
      @jnevercast 11 месяцев назад +1

      @@Vercidium Point 2: "Each shader can run without waiting for model data". Is this because each instance is using the same buffer? I presume there is _some_ buffer? or can you issue a draw call with no buffer and a number of verts?

    • @Vercidium
      @Vercidium  11 месяцев назад

      @@jnevercast there is a tiny buffer with 1 byte per vertex that’s unused. Unfortunately a vertex buffer still needs to exist to render N vertices

  • @AgeOfTheJoshua
    @AgeOfTheJoshua 11 месяцев назад +1

    Wow dude is all the mograph done by you? Well done

    • @Vercidium
      @Vercidium  11 месяцев назад

      Thank you! Yes all done in C# and OpenGL. It was a ton of work but I've built up an animation system that I can re-use for the next videos

  • @skope2055
    @skope2055 10 месяцев назад +1

    Great and useful content!

  • @jeanmahmoudventilateur3480
    @jeanmahmoudventilateur3480 11 месяцев назад +1

    Great channel, I'll come back later if I'm making games lol

  • @TomDevYT
    @TomDevYT Год назад +3

    Really well presented video! Super inspiring, though i just wish the title wasnt as misleading.

    • @daveycoleman
      @daveycoleman 11 месяцев назад

      What did you feel was misleading about it? I think it did what it said on the tin.

    • @TomDevYT
      @TomDevYT 11 месяцев назад +2

      @@daveycoleman hahah well you changed the title you rascal! This title is much better imo ❤️

  • @Terreurhaas
    @Terreurhaas 8 месяцев назад +1

    Hey Mitch, great channel. Subbed after watching like two videos. The fern still looks a little bit as if it is breathing and not really affected by wind. I believe you should be able to walk across the leaves you generated from last and first (or really any index you fancy) to simulate a more direct wind. (disclaimer: I am not a game developer, just a boring software developer)

    • @Vercidium
      @Vercidium  7 месяцев назад

      Thanks for the feedback, good point. I've since set up a basic wind system that moves ferns / trees / grass in the same direction, but it's tricky as the triangles are being stretched/compressed. Keen to solve it though because realistic wind looks awesome

  • @camelCased
    @camelCased 11 месяцев назад +2

    3:55 - hey, who invited the Netflix logo? 😀

    • @argi4141
      @argi4141 10 месяцев назад

      yeah netflix go away! get your own youtube channel

  • @syikoosu
    @syikoosu 2 месяца назад +1

    I LOVE THIS SO MUCH XD

  • @vibk2744
    @vibk2744 Год назад +3

    This is amazing

  • @atomictraveller
    @atomictraveller Год назад +2

    keen, i've been using opengl in win32 without glm so my models are generated procedurally.
    i can guarantee you one thing tho, all the people raised on video games would never recognise actual non motile plants.

  • @vihannes3
    @vihannes3 11 месяцев назад +5

    When using triangle strips, isn't there a special index (like 0xffffffff) for starting a new strip within the same call, so you wouldn't need to do the hack with the invisible triangle?

    • @Vercidium
      @Vercidium  11 месяцев назад +3

      Yes there is, that’s called Primitive Restart. But unfortunately I’m not using an index buffer and don’t have access to it :(

    • @vihannes3
      @vihannes3 11 месяцев назад

      @@Vercidium Ah, I see... thanks!

  • @bonmas14
    @bonmas14 9 месяцев назад +1

    Very cool video! I have question, how does this work on cpu side? (buffers/vertex arrays) I trying to make something simillar for sprite rendering, just writing glDrawArray doesn't work. I already have shader like here 5:58. But I don't understand how to prepare data on the cpu side

  • @viniciusnoyoutube
    @viniciusnoyoutube 11 месяцев назад +1

    It only missed the wind strength so the leafs move more or less.
    Maybe wind direction if you really need perfection.

  • @e4zyphil
    @e4zyphil 11 месяцев назад +4

    Hey I find your videos really interesting. You made the wind more realistic with a few tweaks. I think syncing the leaves to an external wind is needed tho, this endresult wouldn't fly in a real game. That would also interest me.

    • @Vercidium
      @Vercidium  11 месяцев назад +3

      Yes that's essential and is something I'm keen to try. I've added it to my ideas list, watch out for future videos!

    • @star-di3wx
      @star-di3wx 10 месяцев назад

      I'm thinking for a simple wind direction implementation:
      Add a constant(around 4 or so) to wind, to move the range to all positives
      multiply wind by cos(windDirection - yaw)
      adjust the constant for totalPitch

  • @bakamund
    @bakamund 10 месяцев назад +1

    this would be applied for stylized games i'm assuming?
    it doesn't seem to have the direct artistic control that DCC applications provide, and when optimization is mentioned we can see from AAA games (tlou, rdr2, cod mw, horizon, etc) that the game can run at 60fps at recommended hardware specs

  • @redgek
    @redgek Год назад +9

    If I understood correctly you load N vertecies large buffer to a GPU, and then modify the verts in a vertex shader. Instead of loading the exact amount of verticies to a GPU that you're gonna change anways, you coulld look up geometry shaders and tesselation shaders to generate meshes on the fly. But, for the specific fern/grass example I think it's better (perfomance wise) to have load a model once, then instance it, and have a shader that adds the wind animation based of some properties of the vertices (like vertex colors) and uniforms (like wind direction vector (or a texture)).

  • @puddlejumper3259
    @puddlejumper3259 10 месяцев назад +2

    Imagine an entirely procedurally generated game environment made using only shaders. Geometry, textures, animation.

  • @kaansouth8789
    @kaansouth8789 11 месяцев назад +1

    😮mind blown!!!

  • @biglittledude496
    @biglittledude496 10 месяцев назад +1

    You are a genius

    • @Vercidium
      @Vercidium  10 месяцев назад

      Haha not quite but thank you!

  • @Fadil_mn
    @Fadil_mn 6 месяцев назад +1

    if ppl played a mobile game that uses that same optimization as you and playing in a high frame rates they would so much so that they don't focus on the game loop

  • @me_owe_ski
    @me_owe_ski Год назад +1

    > Cheated and Created Plants with No Geometry
    > Proceeds to use geometry

  • @danielsantos3254
    @danielsantos3254 10 месяцев назад +2

    How much does the transparent texture affect performance? I remember reading/watching somewhere (might’ve been the StylizedStation channel) that too many transparent textures can slow things down. Something to do with potentially having to calculate the color value for each pixel multiple times for each texture it passes through, I think.

    • @Vercidium
      @Vercidium  10 месяцев назад +1

      That’s right, transparency is a performance killer. I use discard statements in the fragment shader here instead of blending, to avoid the blending cost

  • @YannMetalhead
    @YannMetalhead 10 месяцев назад +1

    Good video.

  • @Shkvarka
    @Shkvarka 10 месяцев назад +3

    It's genius... Im ML engineer and trying my skills in gamedev. Would you make some 2d physics tutorials? I'm trying to make some 2d ballistic sim in python. And to me it looks like I can't do a lot to optimize it (I decided to simulate not only ballistic part but also wind friction and make rocket 2-stage (reactive+ballistic)). But after your videos, I'm sure - I'm wrong=) Best regards from Ukraine, Odesa!

    • @Vercidium
      @Vercidium  10 месяцев назад +2

      If there's one thing I can't do, it's physics! I can't help there sorry, but I enrolled in this course last year and it explains everything very well: pikuma.com/courses/game-physics-engine-programming

    • @Shkvarka
      @Shkvarka 10 месяцев назад +2

      @@Vercidium wow! Never heard of this website! Will take this course along with game engines! Thank you very much!!

  • @TheRealKuif
    @TheRealKuif 7 месяцев назад +2

    Another pro tip to make things look more natural: don’t make your objects (such as plants) perfectly symmetrical with maths

  • @luminous2585
    @luminous2585 9 месяцев назад

    That bit of code with the triangle vertices you showed made me wonder something. Are shading units capable of speculative execution? That is if that code is actually run by those. I know extremely little of the topic. Since the branches are always accessed in a fixed order it seems like that would be very speedy if it was able to go to the right line of code ahead of time.

  • @yazata7540
    @yazata7540 11 месяцев назад +1

    keep up!!!

  • @changecraft6354
    @changecraft6354 11 месяцев назад +1

    Damn the gpu gonna be happy about rendering so many transparent textures on top of each other for sure :)

    • @Vercidium
      @Vercidium  11 месяцев назад +2

      Haha as long as they’re not filling the screen, it’s not too bad
      I looked at a few other games and they all seem to use 2D planes with a transparent leaf/branch texture on them
      I’d love to figure out a better system, possibly convert the texture to a mesh with minimal transparency

    • @changecraft6354
      @changecraft6354 11 месяцев назад +2

      @@Vercidium modern gpu's can easily handle tons of vertices with optimized draw calls. You can easily model every leaf with a handful of vertices and get the additional benefit individual animations for each leaf and get better performance than having a bunch of these transparency bushes...

    • @Vercidium
      @Vercidium  11 месяцев назад

      @@changecraft6354 sounds like an idea for a future video! For trees and plants in the distance, would it fall back to a 2D billboard?

  • @doltBmB
    @doltBmB 7 месяцев назад

    remember, drawcalls are not expensive, state switching is, if all your drawcalls use the same state it will be fast

  • @kyoai
    @kyoai Год назад +8

    Pardon me, but where exactly are you generating new geometry? For all I can see, you still have to create an equal number of vertices/polygons beforehand that you are going to work with. You still are taking existing vertices, and for each existing vertex you set a single render position, as is common with current plant render solutions. Granted, it's a very clever way of rendering a single straight strip of several polygons by cleverly rearranging vertex positions, but it's still not done without requiring pre-existing geometry, let alone, as your video title wrongly claims, "no geometry".

    • @Vercidium
      @Vercidium  Год назад +4

      You’re right, there is still an underlying vertex buffer that’s filled with zeroes.
      Rather than containing multiple floats for position/normal/UV data, each vertex in the buffer is a single byte.
      This means for a fern with 24 leaves and 12 vertices per leaf, it’s allocating 288 bytes of vertex data, but not using it.

    • @SimonBuchanNz
      @SimonBuchanNz Год назад +4

      In WebGPU you can completely avoid allocating any vertex buffers, and just draw an arbitrary number of polygons.

    • @Rafale25
      @Rafale25 Год назад +2

      @@SimonBuchanNzDon't need webgpu, you can set glDrawArrays count to the number of vertices you need, no need to bind any buffer

    • @kyoai
      @kyoai Год назад

      @@Vercidium That doesn't change the fact that you are still creating geometry by rendering a texture along a polygon, making the video title a lie.

  • @r2d2vader
    @r2d2vader Год назад +9

    Next video: How I cheated and rendered a 3D game with no triangles

    • @Vercidium
      @Vercidium  Год назад +9

      Now that sounds like a fun chal- *8 years down the drain*

    • @bits360wastaken
      @bits360wastaken Год назад +3

      Akshually its faster to render directly with voxels and/or primitives (but is WAY harder to work with and requires many changes to artstyle)

    • @hiiambarney4489
      @hiiambarney4489 Год назад

      Always remember: "Switching to Default Cube is always faster than rewriting main Shader-Code" or something like that.@@bits360wastaken

    • @quintussilenius4324
      @quintussilenius4324 Год назад +6

      there are, in fact, ways to make 3d graphics without triangles (such as distance fields), and they can actually do some pretty impressive things... but of course, they have their own limitations; not sure if anyone ever used such things for games (outside of some volumetric effects, that is)

    • @Vercidium
      @Vercidium  Год назад

      @@quintussilenius4324 interesting! I’ll have to look this up

  • @Iona_Roe_Deer
    @Iona_Roe_Deer 10 месяцев назад

    3:58 accidentally creating new Netflix logo. 😁

  • @NickEnchev
    @NickEnchev 11 месяцев назад +3

    I'm curious if you would be able to handle the separation of the individual leaves by using a geometry shader and EndPrimitive()?

    • @Vercidium
      @Vercidium  11 месяцев назад +1

      That would work! Someone also suggested using an index buffer and a Primitive Restart, to start a new strip every N vertices.

    • @NickEnchev
      @NickEnchev 11 месяцев назад +2

      ​@@VercidiumThat sounds like a good approach as well. I would imagine though that using the tessellation/geometry hardware would work better and make the vert shader less "branchy" (no pun intended).

  • @SeitanSurKick
    @SeitanSurKick Год назад +3

    🙌

  • @sickomode6440
    @sickomode6440 11 месяцев назад +2

    all these lines of code just for a player to completely ignore it.

  • @ДанилаПахомов-п1х
    @ДанилаПахомов-п1х Год назад +5

    🌿🌿🌿

  • @TheUltimateBlooper
    @TheUltimateBlooper 9 месяцев назад

    That plant may be optimized, but artistically it just looks like it's "alive" and about to eat me, not like a plant xD

  • @axiarubin8750
    @axiarubin8750 10 месяцев назад +1

    I know very little about coding and 3d modeling, so all I have is just my assumptions.
    As I understand creating an object with code rather than 3d modeling software is harder, but pays off in reducing memory used. How hard would it be to create an object fit for the current AAA games? Let's take Geralt from Witcher for example. Would it even be possible to recreate this level of quality with this method?

    • @Vercidium
      @Vercidium  10 месяцев назад +1

      It would be possible to generate more complex models in a vertex shader, but it would take a lot of code and at some point it’ll be quicker to just load the model from a buffer.
      The models that suit this approach are ones that are repetitive or follow patterns that can easily be recreated in a shader, like plants, terrain and particles

    • @axiarubin8750
      @axiarubin8750 10 месяцев назад

      @@Vercidium Interesting. Is it possible to combine the two for an optimal performance?

  • @JuddSamurai
    @JuddSamurai 11 месяцев назад +1

    This is absolutely amazing! I do wonder about those shadows at the end though, how are they done. I've tried implementing different forms of shadows into my own engine but they are always pretty pixelated so how do you do your shadows, as they look really good.

    • @Vercidium
      @Vercidium  11 месяцев назад +2

      Shadows are the bane of my existence haha, for this video I just increased the shadow resolution. I've started my shadow implementation from scratch and I'm looking into better Cascaded Shadow Mapping techniques.
      I don't fully understand the matrix maths behind shadows, I need to take a step back and figure out what's going on. MJP has a few great resources about shadows but they are super technical, I'm yet to wrap my head around most of it

  • @pixobit5882
    @pixobit5882 Год назад +7

    What program did you use to animate the code snippets?

    • @Vercidium
      @Vercidium  Год назад +7

      Hey I wrote my own in C# using SkiaSharp, with RichTexKit for syntax highlighting. I was originally using tweetlet.net/code for static images but it was tedious to export them

  • @2animatez156
    @2animatez156 11 месяцев назад +1

    While reading the comments I noticed there was a lot of mentions of 'loading vertex data into the shader each frame'/'vertex bandwidth'.
    Why is there no bandwidth? Aren't a buffer of 1-byte zeroes being sent, meaning there would be reduced but not zero bandwidth, or am I thinking about this incorrectly?

    • @Vercidium
      @Vercidium  11 месяцев назад +1

      Hey that’s right, there’s a tiny amount of bandwidth but for a buffer that small it’s likely it will fit in the cache before being sent to each shader.
      I’m curious if GPUs optimise this further by detecting if the mesh data is used in the shader, and if not skips loading mesh data entirely

  • @ShigekiMiyakeStoner
    @ShigekiMiyakeStoner 11 месяцев назад +1

    Wow.

  • @araujoPr
    @araujoPr 9 месяцев назад +1

    Hello friend, hope you are having a great day! A genuine question: when you started programming your engine, did you use something like openGL , directX or Vulkan or did you program this type of resources too? I want to start making an engine, but i don't know if i need( or can ) make the base of the graphics only using language resources. By the way, I wish to use c++ . Thank you for your videos, they are genuinely interesting and very inspiring!

    • @Vercidium
      @Vercidium  9 месяцев назад +1

      I started with OpenGL and still using it for these demos. It will work great with C++ or C#. Thank you!

    • @araujoPr
      @araujoPr 9 месяцев назад +1

      @@Vercidium Thank you for the awnser!

  • @flowfrog101
    @flowfrog101 11 месяцев назад +1

    Very professional video. What software do you use for your videos?

    • @Vercidium
      @Vercidium  11 месяцев назад +1

      Thank you, it’s all done in code with C#, SkiaSharp and OpenGL

  • @muuubiee
    @muuubiee 2 месяца назад +1

    Won't the renderer still try to render the "invisible" triangle, and waste some time on rendering nothing?

  • @perialis2970
    @perialis2970 5 месяцев назад

    rdr2 does this on another level

  • @pier3d278
    @pier3d278 11 месяцев назад

    This is really cool, thanks for sharing! I wonder what is the advantage of using a method like this, over the normal modeling. Can anybody explain please?

  • @farianderson168
    @farianderson168 8 месяцев назад

    i remember we had to use POSITION symantic in unity shaders ( written mostly in cg ) in order to get position data from the mesh in the vertex shader. something like this:
    float4 position : POSITION;
    now i wonder if this will produce an error or not when there's no position data in the mesh.

  • @Rokannon
    @Rokannon 4 месяца назад

    When he proposes to use vertex id to generate its position, does that mean that the draw call occurs without any array/element buffer?

  • @zyad48
    @zyad48 11 месяцев назад +2

    Obviously it isn't like plants don't move even a little while at rest, however I'm curious, would this implementation be able to work with animating simulated wind or player interaction?

    • @Vercidium
      @Vercidium  11 месяцев назад +2

      That’s my next goal for this renderer :) first dynamic wind and then player interaction

    • @zyad48
      @zyad48 11 месяцев назад +2

      @@Vercidium MAN RUclips has been bad about serving me my notifications, I only found that you responded by checking the video again randomly haha, thanks much for answering my question! I can't wait to see progress done on this :D

  • @S0lfur
    @S0lfur Год назад +4

    hey.. Hey wait. HEY WAIT! THATS CHEATING!

  • @michaelbuckers
    @michaelbuckers 11 месяцев назад +2

    How does this compare against regular 3d models performance-wise? Can't imagine calling so many trig functions is computationally cheap.

    • @JD_Mortal
      @JD_Mortal 11 месяцев назад

      Honestly, the results could be stored in a simple array to be "plugged-in", like the other values. They should only need to be "calculated" once, for the whole army of computed-models. Each could actually, also, be offset, so clones have unique timings and starting offsets. (Or adaptive timings, like a rush of wind moving more, faster, based off whatever external factor would control that.)
      Also, that the formula can also be extended to auto-create LOD too... On demand, per instance, based off multiple factors. Unlike hand-made or nasty "auto-decimated" LOD maths. Going in reverse, you ADD LOD, which yields better results than the best auto-tessellation formulas can offer, faster. (Auto-tessellation has to evaluate and "think" about each surfaces angles/normals and calculate interpolations. As opposed to a literally formulated point-product of a curved line and edges. Also, no need to "remap" the surfaces, which tessellation has to do, once it breaks-up the triangles into smaller triangles. Which has to be done, per-object, per surface, with auto-tessellation. Which is why it is such a horribly taxing novelty, and not a real-world "in production" component. Except in real rare cases, if you have a top-of-the-line GPU that has cycles to spare already. A total waste for distant objects, which are trying to down-grade, to fit more in view, against close-up objects trying to show more than is actually there, in a fake way.)

    • @Vercidium
      @Vercidium  11 месяцев назад +1

      To recreate this as a regular animated model with bones (skeletal animation) it would need two matrix multiplications - one to rotate + position the leaf's bone, then another to convert it to screen space.
      The trig functions aren't cheap, but we can use them to skip that first matrix multiplication (64 multiplications and 48 additions), which makes it run a bit quicker

    • @michaelbuckers
      @michaelbuckers 11 месяцев назад +1

      @@Vercidium Would switching out trig functions for texture lookup incur too much memory bandwidth vs removing core load? The sine can be encoded in the same texture as the leaf.

    • @Vercidium
      @Vercidium  11 месяцев назад +1

      @@michaelbuckers it would need to be benchmarked, my gut feel is a texture would be slower. A uniform array or UBO or SSBO could also be used to store the precalculated sin wave

  • @MrRSM0
    @MrRSM0 11 месяцев назад +1

    That thing is breathing

  • @mati4193
    @mati4193 11 месяцев назад +2

    This is cool and all, but wouldn't it be faster and easier to make a model like this in blender? What benefit do you get by using code to make 3d objects, wasn't 3d software made specifically so people didn't have to do that? If this is something made purely for novelty that's cool also I'm just curious on if there are any actual benefits for this process

    • @sciencecompliance235
      @sciencecompliance235 11 месяцев назад +2

      3D software doesn't care about real-time rendering performance and even if it did wouldn't know enough about the use context to optimize properly.

    • @Vercidium
      @Vercidium  11 месяцев назад +2

      It would be easier, but it wouldn't run as quickly because the mesh data must be loaded into the shaders each frame before they can begin executing. In this example the shaders can begin running instantly

  • @galvinvoltag
    @galvinvoltag 11 месяцев назад +1

    *F E R N*

  • @weltraumimport
    @weltraumimport 9 месяцев назад +1

    i did not understand the extra triangles trick, why do they disappear

    • @weltraumimport
      @weltraumimport 9 месяцев назад +1

      nevermind i rewatched it i understand now. we are not optimising the draw calls but just make those connecting verticies disappear

  • @Psychx_
    @Psychx_ 11 месяцев назад +1

    Don't these "if" and "else if" blocks in the vertex shader cause a lot of lane masking on the GPU?

    • @Vercidium
      @Vercidium  11 месяцев назад +3

      It’s good practice not to use ifs, but I’ve never noticed a performance hit, especially when vertex shaders aren’t the bottleneck
      The one time I noticed branching issues was on an AMD card, where I had about 6 of them in a nasty setup (some nested, some one after another)
      I reworked the logic into a set of ternaries and it fixed the issues, but can’t say for sure as it was on another user’s GPU. I profiled it on my NVIDIA GPU and didn’t notice a performance difference either way

  • @namrog84
    @namrog84 Год назад +4

    What application are you using to write the script/code in and view the generated models?

    • @Vercidium
      @Vercidium  Год назад +10

      I was using tweetlet.net/code to begin with, but it was tedious to update them and I couldn’t animate them.
      I ended up writing my own in C# and rendering them in game, then screen recorded it. I feel like I can create a whole other devlog about how I created this devlog!

    • @r2d2vader
      @r2d2vader Год назад +4

      @@Vercidium Devlogception!

    • @Vercidium
      @Vercidium  Год назад +3

      @@r2d2vader I’ve seen quite a few of them! Seems to be a popular thing

  • @mike64_t
    @mike64_t 11 месяцев назад

    All nice and good until you need artist control. Yes, memory bandwidth is precious, but the moment you slapped that high res texture on top I started laughing because those precious few floats just got drowned in comparison - unless that texture is procedural too, in which case I would be impressed.

  • @finesseandstyle
    @finesseandstyle 9 месяцев назад

    how performant is this compared to a more traditional way to render animated plants?

  • @fleity
    @fleity 11 месяцев назад +1

    Aren't sin and cos trigonometry function rather expensive on the gpu?

    • @Vercidium
      @Vercidium  11 месяцев назад +2

      That’s true, but it means I can perform one less matrix4 multiplication (64 multiplications and 48 additions) per vertex, since it’s positioned and rotated using sin+cos instead

  • @Tingleton11
    @Tingleton11 11 месяцев назад +1

    I will likely never use this information (I will be binging every video)

  • @MaiconMatos08
    @MaiconMatos08 4 месяца назад

    How Can We Use Your Game Engine?

  • @hugofoltin5647
    @hugofoltin5647 11 месяцев назад +2

    is this done with only one draw call?

    • @Vercidium
      @Vercidium  11 месяцев назад +1

      It is :) that's made possible using the glMultiDrawArraysIndirect function in OpenGL 4.3+

  • @narrativeless404
    @narrativeless404 10 месяцев назад

    Rockstar Games should be taking notes lmao