!!ARBvp1.0 # (fairly) generic file for 2D texture coordinates # x,y,z come from texture coordinates; w set to 1 # all are scaled by 61 to full noise across 0-1 texture range # all undergo a global scale based on vertex.color.g (3/4 keys) # # overall external key controls (each in a decrement/increment pair): # 1/2: vertex.color.r: 4D noise w, not used # 3/4: vertex.color.g: noise scale # 5/6: vertex.color.b: free # 7/8: vertex.color.b: free # all are passed to shader in the attribute 'frame' = result.texcoord[1] PARAM nscale = {61, 61, 61, 1}; # combined static scale factors PARAM L = {-.577,.577,.577,0}; # light position PARAM Kd = {.9,.7,.5,0}; # diffuse color PARAM Ka = {.1,.14,.18,1}; # ambient color # inputs and outputs ATTRIB Vm = vertex.position; # position in model space ATTRIB Nm = vertex.normal; # normal in model space OUTPUT Vp = result.position; # position in projection space OUTPUT frame = result.texcoord[0]; # user input OUTPUT noiseInput = result.texcoord[1]; # input to noise function # arbitrary user control MOV frame, vertex.color; # Transform the model-space vertex by the model to projection matrix DP4 Vp.x, state.matrix.mvp.row[0], Vm; DP4 Vp.y, state.matrix.mvp.row[1], Vm; DP4 Vp.z, state.matrix.mvp.row[2], Vm; DP4 Vp.w, state.matrix.mvp.row[3], Vm; # Transform the normal to view space TEMP N; DP3 N.x,state.matrix.modelview.invtrans.row[0],Nm; DP3 N.y,state.matrix.modelview.invtrans.row[1],Nm; DP3 N.z,state.matrix.modelview.invtrans.row[2],Nm; # compute per-vertex diffuse shading TEMP Nn,diff; DP3 Nn.w,N,N; RSQ Nn.w,Nn.w; MUL Nn,N,Nn.w; DP3 diff.x,Nn,L; MAX diff.x,diff.x,0; MAD result.color,diff.x,Kd,Ka; # noise input from scaled texture TEMP ni; MAD ni.x,vertex.color.y,-2,0; # scale 2^0 to 2^-3 (1 to 1/8) EX2 ni.x,ni.x; MUL ni,ni.x,nscale; # combine with static scaling MUL noiseInput.xyz, ni, vertex.texcoord; # xyz from position MOV noiseInput.w, 1; END