maximian

03-29-2005, 09:09 AM

Okay, I have been having trouble with a vertex and fragment program I have been testing. So I tested a simplified version:

VP

!!ARBvp1.0

# cgc version 1.3.0001, build date Aug 4 2004 10:01:10

# command line args: -profile arbvp1

# source file: reflectionLinesVP.cg

#vendor NVIDIA Corporation

#version 1.0.02

#profile arbvp1

#program main

#var float4 i.position : $vin.POSITION : POSITION : 0 : 1

#var float3 i.normal : $vin.NORMAL : NORMAL : 0 : 1

#var float3 i.texcoord0 : : : 0 : 0

#var float3 i.texcoord1 : : : 0 : 0

#var float4 main.position : $vout.HPOS : HPOS : -1 : 1

#var float3 main.texcoord0 : $vout.TEX0 : TEX0 : -1 : 1

#var float3 main.texcoord1 : $vout.TEX1 : TEX1 : -1 : 1

PARAM c[1] = { program.local[0] };

PARAM MVP[4] = { state.matrix.mvp }; # Modelview Projection Matrix.

PARAM IMV[4] = {state.matrix.modelview.invtrans }; #inverse modelview

TEMP Temp;

#Transform vertex to clip space

DP4 Temp.x, MVP[0], vertex.position;

DP4 Temp.y, MVP[1], vertex.position;

DP4 Temp.z, MVP[2], vertex.position;

DP4 Temp.w, MVP[3], vertex.position;

MOV result.position, Temp;

MOV result.texcoord[0].xyz, Temp;

DP3 Temp.x, IMV[0], vertex.normal;

DP3 Temp.y, IMV[1], vertex.normal;

DP3 Temp.z, IMV[2], vertex.normal;

MOV result.texcoord[1].xyz, Temp;

END

# 3 instructions, 0 R-regs

Fragment Program

PARAM c[1] = { { 0, 1, 0, 1 } };

TEMP R0;

MOV result.color, fragment.texcoord[1];

END

The results in a white background, instead of a multicolored model based on normal directions.

The point is I need to pass, both the normal and position interpolated for each pixel.

So I transform, the vertices, and the normal correctly, and then apply some operations to them in the fragment program.

Help.

VP

!!ARBvp1.0

# cgc version 1.3.0001, build date Aug 4 2004 10:01:10

# command line args: -profile arbvp1

# source file: reflectionLinesVP.cg

#vendor NVIDIA Corporation

#version 1.0.02

#profile arbvp1

#program main

#var float4 i.position : $vin.POSITION : POSITION : 0 : 1

#var float3 i.normal : $vin.NORMAL : NORMAL : 0 : 1

#var float3 i.texcoord0 : : : 0 : 0

#var float3 i.texcoord1 : : : 0 : 0

#var float4 main.position : $vout.HPOS : HPOS : -1 : 1

#var float3 main.texcoord0 : $vout.TEX0 : TEX0 : -1 : 1

#var float3 main.texcoord1 : $vout.TEX1 : TEX1 : -1 : 1

PARAM c[1] = { program.local[0] };

PARAM MVP[4] = { state.matrix.mvp }; # Modelview Projection Matrix.

PARAM IMV[4] = {state.matrix.modelview.invtrans }; #inverse modelview

TEMP Temp;

#Transform vertex to clip space

DP4 Temp.x, MVP[0], vertex.position;

DP4 Temp.y, MVP[1], vertex.position;

DP4 Temp.z, MVP[2], vertex.position;

DP4 Temp.w, MVP[3], vertex.position;

MOV result.position, Temp;

MOV result.texcoord[0].xyz, Temp;

DP3 Temp.x, IMV[0], vertex.normal;

DP3 Temp.y, IMV[1], vertex.normal;

DP3 Temp.z, IMV[2], vertex.normal;

MOV result.texcoord[1].xyz, Temp;

END

# 3 instructions, 0 R-regs

Fragment Program

PARAM c[1] = { { 0, 1, 0, 1 } };

TEMP R0;

MOV result.color, fragment.texcoord[1];

END

The results in a white background, instead of a multicolored model based on normal directions.

The point is I need to pass, both the normal and position interpolated for each pixel.

So I transform, the vertices, and the normal correctly, and then apply some operations to them in the fragment program.

Help.