Skip to content

Indirect addressing #2

Description

@fred1024

Hello !
As we are moving all our shaders from agal to ogsl, we encountered a little shortcoming.
In AGAL, we use a vector of constants to store some infos (ex: bones matrices) and then in the shader, we would select the needed constant(or matrix) depending on a vertex attribute.
The vertex attribute would be an index in this vector.
Something like this:

ft0 = fc[va1.x]

We noticed 2 issues :

• You do not allow using a variable as an index, the following code is not valid:
var index:float = 3;
constant[index].x; // <= this line would fail in ogsl

• There is no array/vector type with an arbitrary (but fixed on initialisation of course) number of elements, it would be great if you could add a vecXX type.

With theses 2 additions, our needs would be 100% covered.

What do you think ?

Here's a part of the agal (which is actually Easy Agal) prog i'd like to convert to ogsl (OGSL is so cool and powerful) to give you an idea of our troubles:

We store about 16 matrixs from vc40 to vc(40 + 16 * 4)

// matrix average
add(TEMP[7], TEMP[5], CONST[23]); // +40 for matrices
multiply4x4(TEMP[1], TEMP[0], CONST_byIndex(TEMP[7].x)); // vrt * bone matrix 0
multiply4x4(TEMP[2], TEMP[0], CONST_byIndex(TEMP[7].y)); // vrt * bone matrix 1
multiply4x4(TEMP[3], TEMP[0], CONST_byIndex(TEMP[7].z)); // vrt * bone matrix 2
multiply4x4(TEMP[4], TEMP[0], CONST_byIndex(TEMP[7].w)); // vrt * bone matrix 3

multiply(TEMP[1], TEMP[1], TEMP[6].x); // * weight 0
multiply(TEMP[2], TEMP[2], TEMP[6].y); // * weight 1
multiply(TEMP[3], TEMP[3], TEMP[6].z); // * weight 2
multiply(TEMP[4], TEMP[4], TEMP[6].w); // * weight 3

add(TEMP[1], TEMP[1], TEMP[2]); // TEMP[1] = vrt * bone matrix 0 * weight 0 + vrt * bone matrix 1 * weight 1
add(TEMP[1], TEMP[1], TEMP[3]); // + vrt * bone matrix 2 * weight 2
add(TEMP[1], TEMP[1], TEMP[4]); // + vrt * bone matrix 3 * weight 3

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions