Geometry Shader using OpenGL Wrapper (bgl) [fix for Intel]

Could this work with a marching cubes algorithm?Could your character collide with the geometry made with this?

Could this work with a marching cubes algorithm?

Yes.

Could your character collide with the geometry made with this?

No. The modified geometry only exist in the graphic card.

I changed to all of them, they all do the same. I donā€™t know about geometry shaders. 6xx series are quite new, but I donā€™t have NVIDIA drivers. All I know is that latest OpenGL versions I can get are 3.30 and 3.00 ESā€¦

what about intances of game map rather then grass?

could I place copies of game items instead? and take advantage of instancing?

like 15-30 different sections that add up to a map? Wall sections, floor etc?

I got a rigged low poly object animated, but i cant get the projection correct for the doubles. any suggestions? the always point the cameras right.


@Adriansnetlis
Your graphic card should supports OpenGL up to version 4.5 and GLSL 4.50 (also depends on the driver). So Geometry shader should be sported. So I think it is an Linux driver problem. Try it with an actual Nvidia driver. Or try to use the compatibility mode #version 150 compatibility

@BluePrintRandom It is possible to duplicate objects. But the duplicates will have no physic.

@cuervo1003 I donā€™t know. May be you donā€™t have done the projections correct. http://www.geeks3d.com/20111117/simple-introduction-to-geometry-shader-in-glsl-part-2/

so what if the item they are replacing is the physics mesh graphics?

so any X - physics bounds gets replaced with a instance of instanced mesh object X?

this would be much faster then 1000 non instanced items right?

(like a city made of the same geometry over and over in different ways?)

i followed that link and have been at it for a while now. I hate to ask for help, but ur the only person i know thats done this.

I cant seem to get the View Data in correctly. still cant orient the object right. I hope u have time to help. here is the file.

Attachments

bird_geo_shader.blend (324 KB)

1 Like

Fantastic. This indeed is what weā€™ve looked for. It can help a lot, specially with clouds, stars, trees, sworms, rain, etc. All of them can be no physics, but I agree, that if we could make it easy to use, lots of us can benefit from it!

Keep up the good work!

Thatā€™s look really cool! I donā€™t realize exactly what we could do with but itā€™s fun! Iā€™ve got a question: Is it possible to pass uniform values to the geometry shader (like a timer)? Thanks!

@BluePrintRandom. I am sorry but I am not 100% sure what you mean. Basically the physic engine donā€™t know what the shader does. If you duplicate an object with the shader then only the original mash has a bounds all copies donā€™t have on.

@youle. Yes should work.

@torakunsama. You are welcome. Actually I want to spent my time more in bugfixing the BGE.

@cuervo1003. Here you are.

Attachments

bird_geo_shader2.blend (131 KB)

thank u so much. I ended up getting it early this morning been pulling all nighters lately on code. thanks so much for this resourse.


and here is the zip the file is shader 2.

https://www.mediafire.com/?0zwjmufyqnhskjf

here is my contribution a cool file with a working geo shader in full function. correct texture maps, and decent positioning. Now everyone can get the idea of what this can do. or at least a small fraction of it. THERE IS WAY MORE that can be done with the geo shaders.
plz tell me what u guys think. note that this is just a test file, and does not represent a final product. in fact this is just eyecandy for my mario game. soā€¦ give cred if used. thanks

1 Like

The textures are missing.

you fill a level with objects that are physics items,

then replace the meshes, (in openGL) with the instanced GFX mesh.

so 1000 ā€˜side walk sections Bā€™ are all the same mesh instanced over on to of each sidewalk physics object.

so in viewport = you see physics items

in game = you see instances of GFX mesh.

1 Like

Hi! I still donā€™t understand how to pass an uniform timer to the geometry shader. For example, in the file bird_geo_shader2.blend, how could I tell the geometry shader to remove one of the three birds 10 seconds after the beginning?

I made some tries, but without success (first I tried shader.setUniform1f(ā€˜timerā€™, own[ā€œtimerā€]), then I tried:

  • In the vertex shader:

varying float timer;
uniform float time;

void main()
{
timer = time;
}

  • And in the geometry shader:

#version 150

in float timer;

But it does not workā€¦

The second thing Iā€™m wondering: Is the geometry shader only useful to duplicate objects?

Also, we canā€™t get more than 3 copies? (EDIT: Fixed by increasing max vertices)

Thanks!

It looks great, I really like the wavy grass, i think that could look good as sludgy water.

Textures are missing though so i canā€™t really tell about the birds, I get this:


I think geometry shaders could be very useful, but donā€™t forget that not everyoneā€™s graphics card will support them, so it might be good to make them an optional thingā€¦

@BluePrintRandom. Basically you want to do the same as the replace mesh actuator is doing. Yes that is possible, but I donā€™t know if a geometry shader is much faster.

@youle. You can directly pass the uniform to the geometry sander. You donā€™t need to to pass it trough the vertex shader.
With an geometry sander you can draw face or vertex normals, duplicate objects (e.g. grass ), adding particles, generate a single outline stroke, tessellate objects, dynamic LOD, draw a wireframe over an object and so on.

Notes:

  1. If you want to pass pass trough a varying from the vertex shader to the geometry shader in you have to use a array (per vertex).
    Example: in float timer[]; You donā€™t need the iterator can get the value with timer[0] because the value is for every vertex the same.
  2. If you us an uniform and the geometry shader has a fault, not always an error will be generated, but you get an uniform error because the shader will not linked to the program and so the uniform is not used any where.
  3. Also check if the indention for the setUniform1f() is correct and if the shader is called with true pulse on to update the value.

@Smoking_mirror. It is possible to check the supported shader version and if the supported shader version is to low you simply donā€™t add the shader.

Does the BGE currently batch instanced draw calls?

If I use the same mesh on 1000 objects, then using openGL to do the same would not be any faster?

I already use 1 mesh and replace mesh for my LOD, but I was under the understanding that
the reason people use geometry shaders for instanced grass was because itā€™s much faster
than a mesh.

@HG1: Thanks very much for complete answer! I made an identation mistake :slight_smile:

The objectā€™s physics, AFAIK is calculated by the cpu in BGE. Unless we use openCL, which I believe uses the GPU for calculi, thereā€™s no way geometry shader will spawn physic objects.
In my understanding, a GS is used for graphical purposes, to ā€œfakeā€ abundant geometry. This way you can have lots of objects you dnt need to control or interact. Be it unreachable vegetation, flying birds, clouds, smoke, and other particles; if thereā€™s no physics to calculate it will be faster than rendering the usual way.