Passing Matrix / array to shader


i want each vertex to have the ability to read a whole buffer.

I know i can pass a buffer, but a vertex can only read 1 spot currently (attribute vec4 allows to read only 4 spots from the buffer).

  1. idea 1: Lets try 16 components for each vertex.

    vertex.setupData(usage, 16, format, buf);

    java.lang.IllegalArgumentException: components must be between 1 and 4

    at com.jme3.scene.VertexBuffer.setupData(

  2. idea 2: dont know how is it implemented.

    is there a way to allow each vertex to have access to the whole buffer ? something like global data buffer.

    a) how do i declare it in the shader.

    b) how do i pass it.

a texture is an array and yes, thats what people do

1 Like

it seems complicated, any test example will be welcome. I haven’t done something similar before.

the data i want to pass are floats,

  1. do i convert floats to another format: ints / bytes ?
  2. how do i store them in the texture (image constructor requires bytes).
  3. in the shader how do i convert them back from bytes to float.

You cannot pass such data per vertex. Use uniforms or VTF (vertex texture fetch). This doesn’t really have anything to do with jME3 as much as it has to do with shaders.

1 Like