0

I am doing some LBS, and I need to use more than 4 weights, and indices (Let's say I need 60 float values, and 60 int values).

I am using GLSL version 1.30, so I cannot use Shader Storage Buffer Object. Since this weight, and index information will be different for each vertex, cannot use uniform, and I guess there is no way to define an array with a fixed size (for example float arr[16]) if you are not using uniform. Additionally, for attribute inputs, I can only use vec/mat 2,3 or 4.

So, do you have any idea how I can solve this problem?

4
  • So you need 120 different values for each vertex? Commented Jul 30, 2015 at 21:23
  • Yes, in the worst case scenario Commented Jul 30, 2015 at 21:29
  • 1
    How can you need 120 values for each one, a vertex? I mean, why? Commented Jul 30, 2015 at 22:10
  • It looks you need 1 weight for 1 vertex but you need at least 15 vertices(vec4) which are float vert[60] with float weight[60] and int indices[60] right? Commented Jul 30, 2015 at 22:22

1 Answer 1

2

A first approach would be to just pass them as normal vertex attributes. There is though a driver specific maximum number of vertex attributes.


A better approach, that should work with every driver and with an arbitrary amount of attributes (not infinite, but pretty many) is, to store the vertex attributes in a texture.

A simple setup would be to create a NxM texture, where N=#vertex_attributes and M=#vertices. Each vertex has then only one attribute, that indicates a line of the texture. In the vertex shader you can then read one line of the texture per vertex and have all your attributes.

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you, it is a good idea. But, could you give me a little more idea about how I can generate a texture, and iterate it in the shader?
Creating a texture can be done with the following comands: glGenTextures(...), glTexImage2D(...) You should find plenty of tutorial how to use them. Accessing a texture in shader can be done with texelFetch(...), texture(...) again, just look at basic texture tutorials.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.