------------------------------------------------------------------------------- * * * This is a subset of the file available at: * * http://oss.sgi.com/projects/ogl-sample/registry/ARB/vertex_program.txt * * Longer descriptions of everything are available in that file, this is * * just a handy quick-reference file. * * * ------------------------------------------------------------------------------- --------------------------------------------------------------------- Inputs to vertex program: --------------------------------------------------------------------- Vertex Attribute Binding Components Underlying State ------------------------ ---------- ------------------------------ vertex.position (x,y,z,w) object coordinates vertex.weight (w,w,w,w) vertex weights 0-3 vertex.weight[n] (w,w,w,w) vertex weights n-n+3 vertex.normal (x,y,z,1) normal vertex.color (r,g,b,a) primary color vertex.color.primary (r,g,b,a) primary color vertex.color.secondary (r,g,b,a) secondary color vertex.fogcoord (f,0,0,1) fog coordinate vertex.texcoord (s,t,r,q) texture coordinate, unit 0 vertex.texcoord[n] (s,t,r,q) texture coordinate, unit n vertex.matrixindex (i,i,i,i) vertex matrix indices 0-3 vertex.matrixindex[n] (i,i,i,i) vertex matrix indices n-n+3 vertex.attrib[n] (x,y,z,w) generic vertex attribute n --------------------------------------------------------------------- Constants in vertex program (specified once per-shader or per-program instead of per-vertex inside OpenGL): --------------------------------------------------------------------- Binding Components Underlying State ------------------------ ---------- ---------------------------- program.env[a] (x,y,z,w) program environment parameter a program.local[a] (x,y,z,w) program local parameter a --------------------------------------------------------------------- OpenGL state properties accessible in the vertex shader. These may change on a per-vertex basis or less frequently. --------------------------------------------------------------------- Material Bindings Components Underlying State ----------------------------- ---------- ---------------------------- state.material.ambient (r,g,b,a) front ambient material color state.material.diffuse (r,g,b,a) front diffuse material color state.material.specular (r,g,b,a) front specular material color state.material.emission (r,g,b,a) front emissive material color state.material.shininess (s,0,0,1) front material shininess state.material.front.ambient (r,g,b,a) front ambient material color state.material.front.diffuse (r,g,b,a) front diffuse material color state.material.front.specular (r,g,b,a) front specular material color state.material.front.emission (r,g,b,a) front emissive material color state.material.front.shininess (s,0,0,1) front material shininess state.material.back.ambient (r,g,b,a) back ambient material color state.material.back.diffuse (r,g,b,a) back diffuse material color state.material.back.specular (r,g,b,a) back specular material color state.material.back.emission (r,g,b,a) back emissive material color state.material.back.shininess (s,0,0,1) back material shininess Light Bindings Components Underlying State ----------------------------- ---------- ---------------------------- state.light[n].ambient (r,g,b,a) light n ambient color state.light[n].diffuse (r,g,b,a) light n diffuse color state.light[n].specular (r,g,b,a) light n specular color state.light[n].position (x,y,z,w) light n position state.light[n].attenuation (a,b,c,e) light n attenuation constants and spot light exponent state.light[n].spot.direction (x,y,z,c) light n spot direction and cutoff angle cosine state.light[n].half (x,y,z,1) light n infinite half-angle state.lightmodel.ambient (r,g,b,a) light model ambient color state.lightmodel.scenecolor (r,g,b,a) light model front scene color state.lightmodel. (r,g,b,a) light model front scene color front.scenecolor state.lightmodel. (r,g,b,a) light model back scene color back.scenecolor state.lightprod[n].ambient (r,g,b,a) light n / front material ambient color product state.lightprod[n].diffuse (r,g,b,a) light n / front material diffuse color product state.lightprod[n].specular (r,g,b,a) light n / front material specular color product state.lightprod[n]. (r,g,b,a) light n / front material front.ambient ambient color product state.lightprod[n]. (r,g,b,a) light n / front material front.diffuse diffuse color product state.lightprod[n]. (r,g,b,a) light n / front material front.specular specular color product state.lightprod[n]. (r,g,b,a) light n / back material back.ambient ambient color product state.lightprod[n]. (r,g,b,a) light n / back material back.diffuse diffuse color product state.lightprod[n]. (r,g,b,a) light n / back material back.specular specular color product Textrure Gen Bindings Components Underlying State ------------------------- ---------- ---------------------------- state.texgen[n].eye.s (a,b,c,d) TexGen eye linear plane coefficients, s coord, unit n state.texgen[n].eye.t (a,b,c,d) TexGen eye linear plane coefficients, t coord, unit n state.texgen[n].eye.r (a,b,c,d) TexGen eye linear plane coefficients, r coord, unit n state.texgen[n].eye.q (a,b,c,d) TexGen eye linear plane coefficients, q coord, unit n state.texgen[n].object.s (a,b,c,d) TexGen object linear plane coefficients, s coord, unit n state.texgen[n].object.t (a,b,c,d) TexGen object linear plane coefficients, t coord, unit n state.texgen[n].object.r (a,b,c,d) TexGen object linear plane coefficients, r coord, unit n state.texgen[n].object.q (a,b,c,d) TexGen object linear plane coefficients, q coord, unit n Fog Bindings Components Underlying State ----------------------------- ---------- ---------------------------- state.fog.color (r,g,b,a) RGB fog color (section 3.10) state.fog.params (d,s,e,r) fog density, linear start and end, and 1/(end-start) (section 3.10) Clip Plane Bindings Components Underlying State ----------------------------- ---------- ---------------------------- state.clip[n].plane (a,b,c,d) clip plane n coefficients Point Bindings Components Underlying State ----------------------------- ---------- ---------------------------- state.point.size (s,n,x,f) point size, min and max size clamps, and fade threshold (section 3.3) state.point.attenuation (a,b,c,1) point size attenuation consts --------------------------------------------------------------------- Matrix bindings. Still in the 'state' category, but important enough to get their own heading. These are all 4-row entries, which you can get access to by .row[0] (up to row[3]). For example to find the x-component of the eye-space position, you could use: DP4 eyeSpacePos.x, state.matrix.modelview[0].row[0], vertex.position; --------------------------------------------------------------------- Matrix Bindings Underlying State ------------------------------------ --------------------------- * state.matrix.modelview[n] modelview matrix n state.matrix.projection projection matrix state.matrix.mvp modelview-projection matrix * state.matrix.texture[n] texture matrix n state.matrix.palette[n] modelview palette matrix n state.matrix.program[n] program matrix n --------------------------------------------------------------------- Vertex shader outputs. --------------------------------------------------------------------- Binding Components Description ----------------------------- ---------- ---------------------------- result.position (x,y,z,w) position in clip coordinates result.color (r,g,b,a) front-facing primary color result.color.primary (r,g,b,a) front-facing primary color result.color.secondary (r,g,b,a) front-facing secondary color result.color.front (r,g,b,a) front-facing primary color result.color.front.primary (r,g,b,a) front-facing primary color result.color.front.secondary (r,g,b,a) front-facing secondary color result.color.back (r,g,b,a) back-facing primary color result.color.back.primary (r,g,b,a) back-facing primary color result.color.back.secondary (r,g,b,a) back-facing secondary color result.fogcoord (f,*,*,*) fog coordinate result.pointsize (s,*,*,*) point size result.texcoord (s,t,r,q) texture coordinate, unit 0 result.texcoord[n] (s,t,r,q) texture coordinate, unit n --------------------------------------------------------------------- Vertex shader instructions. --------------------------------------------------------------------- Instruction Inputs Output Description ----------- ------ ------ -------------------------------- ABS v v absolute value ADD v,v v add ARL v a address register load DP3 v,v ssss 3-component dot product DP4 v,v ssss 4-component dot product DPH v,v ssss homogeneous dot product DST v,v v distance vector EX2 s ssss exponential base 2 EXP s v exponential base 2 (approximate) FLR v v floor FRC v v fraction LG2 s ssss logarithm base 2 LIT v v compute light coefficients LOG s v logarithm base 2 (approximate) MAD v,v,v v multiply and add MAX v,v v maximum MIN v,v v minimum MOV v v move MUL v,v v multiply POW s,s ssss exponentiate RCP s ssss reciprocal RSQ s ssss reciprocal square root SGE v,v v set on greater than or equal SLT v,v v set on less than SUB v,v v subtract SWZ v v extended swizzle XPD v,v v cross product