; Example PICA200 vertex shader ; Uniforms .fvec projection[4], modelView[4] ; Constants .constf myconst(0.0, 1.0, -1.0, 0.5) .alias zeros myconst.xxxx ; Vector full of zeros .alias ones myconst.yyyy ; Vector full of ones .alias half myconst.wwww ; Outputs .out outpos position .out outtc0 texcoord0 .out outclr color .out outview view .out outnq normalquat ; Inputs (defined as aliases for convenience) .alias inpos v0 .alias intex v1 .alias innrm v2 .proc main ; Force the w component of inpos to be 1.0 mov r0.xyz, inpos mov r0.w, ones ; r1 = modelView * inpos dp4 r1.x, modelView[0], r0 dp4 r1.y, modelView[1], r0 dp4 r1.z, modelView[2], r0 dp4 r1.w, modelView[3], r0 ; outview = -r1 mov outview, -r1 ; outpos = projection * r1 dp4 outpos.x, projection[0], r1 dp4 outpos.y, projection[1], r1 dp4 outpos.z, projection[2], r1 dp4 outpos.w, projection[3], r1 ; outtex = intex mov outtc0, intex ; Transform the normal vector with the modelView matrix ; TODO: use a separate normal matrix that is the transpose of the inverse of modelView ; r1 = normalize(modelView * innrm) ;mov r0.xyz, innrm ;mov r0.w, zeros ;dp4 r1.x, modelView[0], r0 ;dp4 r1.y, modelView[1], r0 ;dp4 r1.z, modelView[2], r0 ;mov r1.w, zeros ;dp3 r2, r1, r1 ; r2 = x^2+y^2+z^2 for each component ;rsq r2, r2 ; r2 = 1/sqrt(r2) '' ;mul r1, r2, r1 ; r1 = r1*r2 dp3 r14.x, modelView[0], innrm dp3 r14.y, modelView[1], innrm dp3 r14.z, modelView[2], innrm dp3 r6.x, r14, r14 rsq r6.x, r6.x mul r14.xyz, r14.xyz, r6.x mov r0, myconst.yxxx add r4, ones, r14.z mul r4, half, r4 cmp zeros, ge, ge, r4.x rsq r4, r4.x mul r5, half, r14 jmpc cmp.x, degenerate rcp r0.z, r4.x mul r0.xy, r5, r4 degenerate: mov outnq, r0 mov outclr, ones ; We're finished end .end