I have recently been experimenting with a “grass” opengl vertex shader that allows the player to move smoothly though a patch of grass with the blades flowing around the player. The file seems promising but i’m not sure if its just a dead end because the fps drops significantly. I read about VBO’s and Geometry shaders. They seem to be key to opptimizing the blend. I’ve looked into other builds that have geometry shader support. Builds like Harmony, and moguri’s old gsoc build. I even found some patches some other BA users have made. I cant get a single one to work. If somone who has experience with this please help me with a most recent build of blender with a working geometry shader. Also if it isnt to much to ask a working passthough shader in order to get an idea of the setSource() api, if needed.
here is an image of my grass blend. i will post the file soon. i want to make a good example blend.
The BGE doesn’t support geometry shaders, although there were some early attempts. Technically, BGE has VBOs implemented but by default they are disabled. Keep in mind, geometry shaders are more expensive than both vertex and fragment shaders.
Since we’re talking modern OpenGL, another alternative for rendering lots of similar objects is OpenGL’s instancing extension (ARB_instanced_arrays): http://sol.gfxile.net/instancing.html
how would u set up the ARB_instanced_arrays extension? If u could show me how to impliment it at its basic level i would be so happy.
right now i’m reading about the ARB instancing. I had never come across this, so any other ideas good are encouraged. i’ll be studying more till then.
thanks Mahalin
Implementing it in the BGE would require C++ and being familiar with the Rasterizer etc. Off the top of my head, you’d need to enable VBOs, and then modify code in RAS_StorageVBO.cpp and probably other related areas.
how does one go changing blender around? and like agoose said enable gl_ex_MAGIC. what is that and where do u get information on this? I am very intrested in doing this, but I never made a build of blender and dont know where to start.
@ Agoose i’m so lost that i cant tell if ur comment is sarcasm. lol
@Mahalin where would i find RAS_StorageVBO.cpp? also how do u change it? I do know some c++. and i’m very motivated.lol
What Agoose is referring to is geometry shaders are part of modern OpenGL (specifically 3.2?). Currently, BGE primarily uses legacy OpenGL (1.x/2.x) so you need to load the extensions, request the proper context, etc. I must warn you of the long and bumpy road ahead. You could wait for the Viewport FX work to make its way into the BGE.
This is hella cool
From looking at the .blend, I have a suggestion for you right off the bat: Name your scripts, objects, textures, materials and functions all according to their purpose, and comment wherever you can. This will save a hell of a lot of confusion in the future.
It looks really cool, but I only get like 17fps on my hexacore dual-gpu system, so I can see why optimization is needed here
Also, there are some strange artefacts near the cursor object:
I get a really smooth, playable 25 frames per second for some reason. I’ve only got an AMD HD 7750; I’m pretty sure they’re not even manufactured anymore. Though with a little optimisation (like lowering the amount of edges in a blade of grass, I would think 2 bends ought to be fine) this could be a really nice resource. Keep it up, yo.
Newer GPUs are configured to be better optimized for tessellation and is very optimised in comparison to older GPUs such as mine (AMD tends to forget about older cards in their awful drivers). Since this is a pretty repetitive task for the GPU to process, your mid-range 7xxx series “value-oriented” card will handle it better. They aren’t manufactured still, but are still fairly new and available for purchase about everywhere.
I, personally, wouldn’t consider anything under 500fps in this demo to be anywhere near playable. If you think about it, in an actual completed scene there would be way more blades of grass plus additional objects, particle effects and shaders (for the rasterizer), then CPU-intensive tasks which would potentially bottleneck the GPU’s calculations further, such as logic and physics.
Either way, I’m sure that using instancing, VBOs, imposters and a tonne of LoD would certainly be enough to get this running post-60fps in a “real-world” situation.
Also, calculating each and every individual blade of grass is a bad idea. I would imagine that this is going to be done the same way that CryEngine 3 does it by using billboards with grass textures?