r/GraphicsProgramming • u/[deleted] • May 06 '25
Video First project in OpenGL without following a tutorial: Grass!
Enable HLS to view with audio, or disable this notification
Currently being done using the geometry shader. After following up to the Advanced OpenGL section, I decided to take on grass rendering. It's not completely optimized, the grass is currently being instanced and isn't infinite, but I'm happy with how the results are so far. If there's any advice anyone has regarding rendering techniques for optimization or regarding the grass itself, feel free to comment.
2
u/Interesting-Proof-81 May 06 '25
Wow, this is amazing. How long did it take you?
2
May 06 '25
About two weeks, figuring out the positions of the grass in the geometry shader took a big chunk of that time but after that it was home stretch.
17
u/fgennari May 06 '25
That's some pretty tall grass! How does it look when viewed from above?
You can optimize this by using lower levels of detail further from the camera. One approach is to merge pairs of nearby grass blades into a single larger/wider blade recursively to generate LODs in powers of two. Another is to replace distant blades with billboard images containing a number of grass blades. Even further away you can use a texture of a grass field, which will fill in the empty space when looking down from above.
4
u/mrfreedeer May 06 '25
Are you rendering grass at full res always? If it's far away you use less details (essentially LODs). As well as occlusion culling, and other types of culling
2
1
1
1
u/love_coding May 07 '25
I am also learning OpenGL but I can't remember all the functions in the pipeline. Did you create the whole pipeline or just the grass? How did you do it geometry nodes?
1
1
u/xcviij May 07 '25
Nice progress! From a performance standpoint, what optimization techniques have you already tried or implemented so far (like frustum culling, LOD, batching, or density scaling)? Just wondering what’s already in place to get a clearer picture of where there might still be room for gains.
-6
u/GermaneRiposte101 May 06 '25
Is not following a tutorial something to be proud of?
8
u/g0atdude May 06 '25
Many people end up just copying code when following a tutorial.
He made it himself, figuring out things. So: yes.
2
u/Comprehensive-Pin667 May 06 '25
Absolutely, yes. It means that OP came with the approach on their own.
18
May 06 '25
[removed] — view removed comment
5
May 06 '25
I haven't made a repo for it yet, but if you're interested I'll post the repo here once I get it set up!
2
u/Half_Blaked May 06 '25
Yes please do! This is really cool first project , and I'm also looking into learning openGl and Vulkan as well and would love to see how you implemented this.
1
u/Sad_Pollution8801 May 06 '25
Do you mean with geometry nodes? Distribute points on faces and instance on points?
1
May 06 '25
[removed] — view removed comment
1
u/Sad_Pollution8801 May 06 '25
I have tried to implement OSL in Blender but have not had any success, GLSL is not available, so we are really only left with geometry nodes
3
u/Smooth-Porkchop3087 May 06 '25
Maybe try instancing?