Jump to content
  • Advertisement
Sign in to follow this  
Yours3!f

Instance culling theory

This topic is 1937 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi,

 

I've implemented instance culling using instance cloud reduction described here:
http://rastergrid.com/blog/2010/02/instance-culling-using-geometry-shaders/

This technique works by storing the instance positions in a VBO, then using a vertex shader to cull them (basically render them), then using the transform feedback mechanism and a geometry shader only store those in an output vbo that passed the visibility testing. Now this way the geometry shader outputs GL_POINTS (vec4). This way only position is considered.

Now in my app I'd like to use rotation and scaling as well. As far as I know, this can be best described by a matrix. My question is: how can I output these matrices with the geometry shader? Should I output more than one vertices (more EmitVertex();)? How do they get stored in the output vbo?

Plus how would the culling be done? should I just transform the bounding box by this matrix? then check that?

 

Best regards,

Yours3!f

Edited by Yours3!f

Share this post


Link to post
Share on other sites
Advertisement

Write to 4 out vec4 varying attribs. One for the x axis, y axis, z axis, and position. Make sure you set each one before calling EmitVertex().

out vec4 xaxis;

out vec4 yaxis;

out vec4 zaxis;

out vec4 CulledPosition;

 

So basically, you can still use a single vertex, but the varying attribs for that vertex will include a full matrix (which will be combined into your instanced modelview matrix attrib).

Edited by RobTheBloke

Share this post


Link to post
Share on other sites

Write to 4 out vec4 varying attribs. One for the x axis, y axis, z axis, and position. Make sure you set each one before calling EmitVertex().

out vec4 xaxis;

out vec4 yaxis;

out vec4 zaxis;

out vec4 CulledPosition;

 

So basically, you can still use a single vertex, but the varying attribs for that vertex will include a full matrix (which will be combined into your instanced modelview matrix attrib).

 

thanks I'll try this. And what about the culling?

Share this post


Link to post
Share on other sites

What about it? Unless you want to use a more elaborate scheme (OBB<->Frustum, OBB tree<->Frustum) it should be the same no? If you do want to use something else, then you'll be passing in more in varying attrs to your geometry shader (for the rest of the matrix axes, and possibly an extents vector, or radius). The high level approach isn't going to change, just the tests you're using within the geometry shader

Share this post


Link to post
Share on other sites

What about it? Unless you want to use a more elaborate scheme (OBB<->Frustum, OBB tree<->Frustum) it should be the same no? If you do want to use something else, then you'll be passing in more in varying attrs to your geometry shader (for the rest of the matrix axes, and possibly an extents vector, or radius). The high level approach isn't going to change, just the tests you're using within the geometry shader

 

oh ok, I thought it would change radically.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!