Passing Shader Parameters VB
Hi!
I'm using OpenGL shading language, and there is need to pass a large amount of data as an Uniform Variable.
Currently I pass this uniform variable as an array, with this command:
void glUniform3ivARB(GLint location, GLsizei count, const GLint *value)
However, that implies to move a lot of data from my App to the GPU. The cuestion is:
Can I use glUniform3ivARB with VertexBuffers? how to pass info with VB?
really you shouldnt be changing it that often that it should be a problem.
Long and the short of it however is no, i'm pretty sure you cant.
Long and the short of it however is no, i'm pretty sure you cant.
Thanks Phantom. So, for passing arguments to a Vertex Shader, the only way is using Vertex Attributtes?
What is it actually you want to do? if the data you want to make available is large and doesn't change very often you can always pass it in as a texture instead. Feel free to explain a bit more about what you are trying to do and we should be able to help out better.
Thanks Rollo, That's great!
Using a texture sampler for passing additional data is a great Idea!
Currently, I'm writing a Vertex Skinning program, which must receive an array of vertex-to-bone assignment like this:
struct VERTEXBONE_ASSIGNMENT
{
REAL m_boneindex;
REAL m_boneweight;
};
The problem is that this element cannot be attached to each vertex; each vertex-to-bone element has independecy of vertices. Also, the vertex bone array info has more elements that model vertex array.
Each vertex has attributes that addressing to VERTEXBONE_ASSIGNMENT elements, F.E. The vertex declaration would be:
struct MY_VERTEX
{
float3 vertice;
float3 normal;
float2 texcoords;
///address to bone assignment array
float m_vb_assignment_offset;
float m_vb_assignment_count;
};
There is needed to treat vertex-to-bone array as an alternative stream source.
Textures may help
Using a texture sampler for passing additional data is a great Idea!
Currently, I'm writing a Vertex Skinning program, which must receive an array of vertex-to-bone assignment like this:
struct VERTEXBONE_ASSIGNMENT
{
REAL m_boneindex;
REAL m_boneweight;
};
The problem is that this element cannot be attached to each vertex; each vertex-to-bone element has independecy of vertices. Also, the vertex bone array info has more elements that model vertex array.
Each vertex has attributes that addressing to VERTEXBONE_ASSIGNMENT elements, F.E. The vertex declaration would be:
struct MY_VERTEX
{
float3 vertice;
float3 normal;
float2 texcoords;
///address to bone assignment array
float m_vb_assignment_offset;
float m_vb_assignment_count;
};
There is needed to treat vertex-to-bone array as an alternative stream source.
Textures may help
Disclaimer: I havent actually implemented skinning in a shader, so take my comments with a big cup of salt...
From what I understand your plan is to support a variable number of bones per vertex. Unfortunatly textures wont help you much unless you are using a SM3 card (texture sampling in vertex shader). If you have that capability it would be interresting to see your results.
How about:
1) set a big uniform array like you suggested (you might run out of uniform space here maybe?)
2) fixed (N) maximum amount of bones affecting each vertex. Pass in N weights and bone indices per vertex. Have separate shader versions for different amounts and when you need to render the skinned object pick the best fit shader and use zero weights for bones you dont need.
[Edited by - rollo on December 4, 2005 8:51:41 AM]
From what I understand your plan is to support a variable number of bones per vertex. Unfortunatly textures wont help you much unless you are using a SM3 card (texture sampling in vertex shader). If you have that capability it would be interresting to see your results.
How about:
1) set a big uniform array like you suggested (you might run out of uniform space here maybe?)
2) fixed (N) maximum amount of bones affecting each vertex. Pass in N weights and bone indices per vertex. Have separate shader versions for different amounts and when you need to render the skinned object pick the best fit shader and use zero weights for bones you dont need.
[Edited by - rollo on December 4, 2005 8:51:41 AM]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement