Setting GLSL attribute variables per vertex with jitter


    Sep 24 2007 | 5:05 am
    Hello
    how does one set attribute variables *per vertex* within a shader or slab vertex program? Ideally I would like to be able to use a sampler2DRect *within* a vertex program, but I understand that this is not possible with the current opengl version (is this correct, at least, I get errors specifying I have 0 vertex texture buffers and am trying to allocate 1 from the debugger). Besides my ideal case of using a texture directly, I would like to set the attribute variables to offset geometry.
    Is this easily possible, to use a float 32 texture, use its values as attribute variables and pass them to a vertex program inbetween glBegin and glEnd, as per
    id like not to have to go a readback to a matrix and then jit.spill, - > back to the gpu as attribute data, or something like that.
    is this a time to use GLLua ?
    Id love to keep this 'strictly Jitter native', sans 3rd party solutions
    Wes, Andrew B? Randy J? ! Help, you are my only hope!
    :)
    v a d e //
    www.vade.info abstrakt.vade.info

    • Sep 24 2007 | 5:29 am
      > Wes, Andrew B? Randy J? ! Help, you are my only hope! > > :)
      Dear princess vade, Here you go: http://www.mat.ucsb.edu/~whsmith/Vertex_attr.zip
      There are other constans to access the data sent to other mesh inlets like TANGENT or NORMAL. I believe these are documented in the Jitter appendix.
      wes
    • Sep 24 2007 | 6:18 am
      ah, thanks! So attribute variables must come from CPU land, and it seems as though vertex_attr_matrix is only a jit.gl.mesh message?
      Is there a way to use texture data as a vertex attribute (besides readback -> upload to gpu again?)
      Think Id look good with those princess Leia hair buns?
      :D
      Thanks for the quick reply - its all beginning to make sense, ive already implemented something with vertex attributes and mesh that is about 4 to 5 times faster than my earlier method. Awesome. I love finding new functionality in areas I havent explored with Jitter, this rocks my socks.
      On Sep 24, 2007, at 1:29 AM, Wesley Smith wrote:
      >> Wes, Andrew B? Randy J? ! Help, you are my only hope! >> >> :) > > Dear princess vade, > Here you go: http://www.mat.ucsb.edu/~whsmith/Vertex_attr.zip > > There are other constans to access the data sent to other mesh inlets > like TANGENT or NORMAL. I believe these are documented in the Jitter > appendix. > > wes
      v a d e //
      www.vade.info abstrakt.vade.info
    • Sep 24 2007 | 6:32 am
      Technically it is possible to "render to vertex buffer object" but this hasn't been exposed in Jitter or actually in jit.gl.lua either.
      wes
    • Sep 24 2007 | 6:44 am
      No worries. This is already so vastly superior to my previous method, its ok for now.
      Thanks a lot!
      On Sep 24, 2007, at 2:32 AM, Wesley Smith wrote:
      > Technically it is possible to "render to vertex buffer object" but > this hasn't been exposed in Jitter or actually in jit.gl.lua either. > > wes
      v a d e //
      www.vade.info abstrakt.vade.info
    • Sep 24 2007 | 5:08 pm
      On Sep 23, 2007, at 11:18 PM, vade wrote:
      > ah, thanks! So attribute variables must come from CPU land, and it > seems as though vertex_attr_matrix is only a jit.gl.mesh message?
      FWIW, if you want to set other varying attributes from your vertex shader (i.e. procedural information on a per vertex basis, rather than sending from the CPU), simply use the "varying" instead of "uniform" keyword for the variable in question. More info on this in the Orange Book, GLSL Spec, and online tutorials.
      -Joshua
    • Sep 24 2007 | 5:21 pm
      > FWIW, if you want to set other varying attributes from your vertex > shader (i.e. procedural information on a per vertex basis, rather > than sending from the CPU), simply use the "varying" instead of > "uniform" keyword for the variable in question. More info on this in > the Orange Book, GLSL Spec, and online tutorials.
      This is true for sending data between the vertex and fragment shader, but I think vade was asking more about sending per-vertex information into the vertex shader. The only way to do this in OpenGL is to use vertex buffers (which jit.gl.mesh uses internally) or to use old-school type function calls like glVertexAttr (or something like that) on a per-vertex basis
      i.e:
      glBegin()
      glNormal() glTexCoord() glVetexAttr() glVertex()
      ...
      glEnd()
      wes
    • Sep 24 2007 | 11:21 pm
      Yeah, exactly. What Wes said :)
      On Sep 24, 2007, at 1:21 PM, Wesley Smith wrote:
      >> FWIW, if you want to set other varying attributes from your vertex >> shader (i.e. procedural information on a per vertex basis, rather >> than sending from the CPU), simply use the "varying" instead of >> "uniform" keyword for the variable in question. More info on this in >> the Orange Book, GLSL Spec, and online tutorials. > > This is true for sending data between the vertex and fragment shader, > but I think vade was asking more about sending per-vertex information > into the vertex shader. The only way to do this in OpenGL is to use > vertex buffers (which jit.gl.mesh uses internally) or to use > old-school type function calls like glVertexAttr (or something like > that) on a per-vertex basis > > i.e: > > glBegin() > > glNormal() > glTexCoord() > glVetexAttr() > glVertex() > > ... > > glEnd() > > wes
      v a d e //
      www.vade.info abstrakt.vade.info
    • Oct 21 2009 | 11:05 pm
      Wes, can you upload the file again?http://www.mat.ucsb.edu/~whsmith/vertex_attr.zip This link is not working.
      I'm reading orange book and stuck in 'attribute variables' Can't understand fully...
      Thank you Jin