OpenGL Shader Documentation
OpenGL supports shader programs through the following extensions:
- Vertex program extension (GL_ARB_VERTEX_PROGRAM)
- Fragment program extension (GL_ARB_FRAGMENT_PROGRAM)
The default vertex shader according to the above specification is:
!!ARBvp1.0 OPTION ARB_position_invariant; MOV result.color,vertex.color; END
The default fragment shader according to the above specification is:
!!ARBfp1.0 MOV result.color,fragment.color; END
The vertex shader supports the following assembler instructions:
Instruction Inputs Output Description ----------- ------ ------ -------------------------------- ABS v v absolute value ADD v,v v add ARL s 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
The fragment shader supports the following assembler instructions:
Instruction Inputs Output Description ----------- ------ ------ -------------------------------- ABS v v absolute value ADD v,v v add CMP v,v,v v compare COS s ssss cosine with reduction to [-PI,PI] 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 FLR v v floor FRC v v fraction KIL v v kill fragment LG2 s ssss logarithm base 2 LIT v v compute light coefficients LRP v,v,v v linear interpolation 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 SCS s ss-- sine/cosine without reduction SGE v,v v set on greater than or equal SIN s ssss sine with reduction to [-PI,PI] SLT v,v v set on less than SUB v,v v subtract SWZ v v extended swizzle TEX v,u,t v texture sample TXB v,u,t v texture sample with bias TXP v,u,t v texture sample with projection XPD v,v v cross product
Assembler example:
TEMP a,b,c; ADD c,a,b;
The above assembler statement adds the operands a and b (which are both 4 component vector registers) and stores the result in the destination register c. This involves 4 componentwise additions for all 4 components of the respective vector registers.