Jump to content

  • Log In with Google      Sign In   
  • Create Account


Instance culling theory


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 Yours3!f   Members   -  Reputation: 1312

Like
1Likes
Like

Posted 03 June 2013 - 11:51 AM

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, 04 June 2013 - 05:31 AM.


Sponsor:

#2 RobTheBloke   Crossbones+   -  Reputation: 2340

Like
1Likes
Like

Posted 04 June 2013 - 07:56 AM

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, 04 June 2013 - 07:58 AM.


#3 Yours3!f   Members   -  Reputation: 1312

Like
0Likes
Like

Posted 04 June 2013 - 03:44 PM

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?



#4 RobTheBloke   Crossbones+   -  Reputation: 2340

Like
1Likes
Like

Posted 04 June 2013 - 05:43 PM

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



#5 Yours3!f   Members   -  Reputation: 1312

Like
0Likes
Like

Posted 05 June 2013 - 01:13 AM

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.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS