Jump to content

  • Log In with Google      Sign In   
  • Create Account

Uniform arrays?


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
5 replies to this topic

#1 Kaptein   Prime Members   -  Reputation: 2180

Like
0Likes
Like

Posted 27 January 2014 - 02:45 PM

I have been thinking about how I need to send uniform values for every draw call.

I have several VBOs (they are pretty large) which contain subsets of meshes. As you can imagine each mesh is most likely rendered at a unique location for each and every draw call.

 

Is it possible with modern OpenGL (4.x) to (assuming same shader) provide an array of uniform values which are unique to the current frame rendered, so as to reduce the number of GL calls needed during rendering?

 



Sponsor:

#2 richardurich   Members   -  Reputation: 1187

Like
2Likes
Like

Posted 27 January 2014 - 05:09 PM

It sounds like you're looking for Uniform Buffer Objects.



#3 Kaptein   Prime Members   -  Reputation: 2180

Like
0Likes
Like

Posted 28 January 2014 - 02:28 PM

Maybe, but it doesn't seem like it will provide a unique uniform value for each successive render call (if that makes sense, I guess it doesn't).

So maybe I'm just stuck with vertex attributes for unique positions per call.



#4 Tocs   Members   -  Reputation: 679

Like
1Likes
Like

Posted 29 January 2014 - 10:01 AM

Sounds like you're maybe talking about Instancing?

 

glDrawElementsInstanced() will draw the same model several times. In order to position things differently you need to do one of a two things. 

 

A) Pass each transform and model specific data in via a Uniform Buffer Object

 

B) Pass each transform and model specific data in via a VBO with a vertex attribute divisor

 

You can draw many models (All the same) with a single draw call at different transformations and such.



#5 haegarr   Crossbones+   -  Reputation: 4587

Like
0Likes
Like

Posted 29 January 2014 - 10:55 AM


So maybe I'm just stuck with vertex attributes for unique positions per call.

But vertex attributes are meant to change per vertex. Using an attribute as constant is possible but seems me wasteful and an update time consuming, especially because you mentioned that the VBOs are big.

 

It seems me from the OP that there are several sub-meshes (presumably not instances of the same mesh), and for each one a draw call is made. Similar to setting the different VBO for each call, also the different set of uniforms has to be set. In such case using UBOs would be the correct way. It would not reduce the amount of draw calls, because the amount of sub-meshes does not change. But it would reduce the amount of calls for setting uniforms, because a single call would be sufficient to set all uniforms at once for a particular draw call.



#6 Kaptein   Prime Members   -  Reputation: 2180

Like
0Likes
Like

Posted 29 January 2014 - 02:46 PM

 


So maybe I'm just stuck with vertex attributes for unique positions per call.

But vertex attributes are meant to change per vertex. Using an attribute as constant is possible but seems me wasteful and an update time consuming, especially because you mentioned that the VBOs are big.

 

It seems me from the OP that there are several sub-meshes (presumably not instances of the same mesh), and for each one a draw call is made. Similar to setting the different VBO for each call, also the different set of uniforms has to be set. In such case using UBOs would be the correct way. It would not reduce the amount of draw calls, because the amount of sub-meshes does not change. But it would reduce the amount of calls for setting uniforms, because a single call would be sufficient to set all uniforms at once for a particular draw call.

 

Indeed, that is actually what i'm going to do. It doesn't solve my actual problem in reducing the amount of transformed matrix transfers to the shader for each object, but I'm going to look into what Togg* mentioned.


Edited by Kaptein, 29 January 2014 - 04:51 PM.





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