Advertisement

Cg+ARB_VERTEX_PROGRAM

Started by April 23, 2003 03:48 PM
2 comments, last by tHiSiSbOb 21 years, 10 months ago
I wrote a small vertex shader in Cga and then compiled it with the arbvp1 specification. It gave me the code but when I put it in, it did not work. When I edited slightly, I got it to work. Here is the origina. What is the prob? !!ARBvp1.0 # ARB_vertex_program generated by NVIDIA Cg compiler # cgc version 1.1.0003, build date Mar 4 2003 12:32:10 # command line args: -profile arbvp1 # nv30vp backend compiling ''main'' program PARAM c4 = { 1, 0, 0, 0 }; #vendor NVIDIA Corporation #version 1.0.02 #profile arbvp1 #program main #semantic main.ModelViewProj #var float4 IN.position : $vin.POSITION : POSITION : 0 : 1 #var float3 IN.color : $vin.COLOR : COLOR : 0 : 1 #var float4x4 ModelViewProj : : c[0], 4 : 1 : 1 #var float4 HPOS : $vout.POSITION : POSITION : -1 : 1 #var float4 COL0 : $vout.COLOR0 : COLOR0 : -1 : 1 ATTRIB v19 = vertex.color; ATTRIB v16 = vertex.position; PARAM c0[4] = { program.local[0..3] }; DP4 result.position.x, c0[0], v16; DP4 result.position.y, c0[1], v16; DP4 result.position.z, c0[2], v16; DP4 result.position.w, c0[3], v16; MOV result.color.front.primary.xyz, v19.xyzx; MOV result.color.front.primary.w, c4.x; END # 6 instructions # 0 temp registers # End of program
----------------------------------------------------"Plant a tree. Remove a Bush" -A bumper sticker I saw.
Well what editing did you do to get it to work?
---I write code.DelphiGL (http://delphigl.cfxweb.net)
Advertisement
ATTRIB iPos = vertex.position;ATTRIB iColor = vertex.color;ATTRIB iNormal = vertex.normal;PARAM mvp[4] = { state.matrix.mvp };OUTPUT oPos = result.position;OUTPUT oColor = result.color;TEMP t,t2,t3;MOV t,iColor;# This just does out vertex transform by the modelview projection matrix\nDP4 oPos.x, mvp[0], iPos;DP4 oPos.y, mvp[1], iPos;DP4 oPos.z, mvp[2], iPos;DP4 oPos.w, mvp[3], iPos;# Write our color out directly\nMOV oColor, iColor;MOV oColor.y, iColor.x;END

[edited by - tHiSiSbOb on April 23, 2003 8:25:55 PM]
----------------------------------------------------"Plant a tree. Remove a Bush" -A bumper sticker I saw.
Well in the Cg code you are storing the mvp in c0[0], c0[1], c0[2], and c0[3] and in your handwritten code you are using state.matrix.mvp. If you want the Cg code to be the same as your handwritten code, change your mul in your Cg code to look like this:

outPosition = mul(glstate.matrix.mvp, inPosition);
---I write code.DelphiGL (http://delphigl.cfxweb.net)

This topic is closed to new replies.

Advertisement