Question

Does it mean only a total of 8 float values can be passed per vertices's set of data?

Does this mean you can only have one of the following?

  • 2 inputs of FLOAT_4.
  • 4 inputs of FLOAT_2.
  • 8 inputs of FLOAT_1.
  • Any mixture that will add up to a total of 8 float values?

Is this the case? Because if it is, it's really misleading in their documentation to say 8 inputs can be used.

Maybe I'm having trouble because I haven't formatted my data correctly, but I'm trying to use 9 floats per vertices, as in:

  • va0 would be a FLOAT_4, offset set at 0.
  • va1 would be a FLOAT_4, offset set at 4.
  • va2 would be a FLOAT_1, offset set at 8.

But nothing appears on the screen with this experiment. Am I exceeding the VertexShader inputs limit?

Was it helpful?

Solution 2

Okay, so I found the problem.

If you define more values in your vertex-data (per vertices), such as making a modification from this format:

position: x  va0.x
          y  va0.y
          z  va0.z
          w  va0.w
color:    r  va1.r
          g  va1.g
          b  va1.b
          a  va1.a

to something like this:

position: x  va0.x
          y  va0.y
          z  va0.z
          w  va0.w
color:    r  va1.r
          g  va1.g
          b  va1.b
          a  va1.a
uv:       u  va2.x
          v  va2.y

Great... you added a new register to the mix. But what you have to do is:

  • Make sure to pass in the right values in:

    context3D.createVertexBuffer(numOfVertices, vertexDataLength); and...

    uploadFromVector(_vertexData, 0, numOfVertices);

  • Make sure you set the right offsets in your calls to:

    context3D.setVertexBufferAt(2, vertexBuffer, 8, Context3DVertexBufferFormat.FLOAT_4);

  • Last but certainly not least (exactly what I was missing)... make USE of that register in your shader!

If you added a new vertex-attribute but you don't use it in your AGAL code... it won't render!

Hopefully this saves others some time wondering where they went wrong with their shaders!

Note: I know, common sense - if you create something, why wouldn't you use it anyways? I was testing if the previous shader still worked with the extra data. It does, as long I don't assign my new vertex-attribute (va2) in the mix. So if you're testing, make sure to only use setVertexBufferAt(...) with the input registers you'll actually use.

OTHER TIPS

I believe the limit is not about the size of vertices, but about the number of vertex attributes in your GLSL shader.

I'm not too familiar with Stage3D, but this is more an OpenGL question. In pure OpenGL, you have to enable vertex attributes with the function glEnableVertexAttribArray(int). What this limitation means is that the only valid numbers for this method are 0 through 7.

In a way that is easier to check against your own code, this isn't allowed in a vertex shader:

attribute vec4 in_one;
attribute vec4 in_two;
attribute vec3 in_three;
attribute vec2 in_four;
attribute vec4 in_five;
attribute vec3 in_six;
attribute vec4 in_seven;
attribute vec2 in_eight;
attribute vec4 in_nine;
...
void main()
{
    ...
}

Note: size of attributes (vec2-4) don't matter, the fact that there are 9 attributes would be passing the limit.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top