Skip to main content
gamedev.net
🔒 Locked

Cube Map Vertex Program

Started by duhroach May 12, 2003 at 7:18 PM 2 replies 450+ views
Original Post
duhroach
duhroach
Howdy all. I''ve found examples of doing reflection/ refraction via cube maps and vertex programs, all implimeted in D3D. I''ve been trying to do the same process in Opengl, but have been coming up short, as the object''s texture is just coming up blank. Here''s my vertex program. Can anyone see a problem?
  
/*
c[0]-c[3]	Modelview Projection Matrix
c[16]-c[19] ModelView Matrix
c[5]		Camera Position 5
c[20]		Refract_Amt

*/

//# Transform position

DP4    o[HPOS].x, v[0], c[0];
DP4    o[HPOS].y, v[0], c[1];
DP4    o[HPOS].z, v[0], c[2];
DP4    o[HPOS].w, v[0], c[3];


//# Get world space vertex position

DP4    R0.x, v[0], c[16];
DP4    R0.y, v[0], c[17];
DP4    R0.z, v[0], c[18];
DP4    R0.w, v[0], c[19];


//# Transform normal to world space

DP3    R9.x, v[NRML], c[16];
DP3    R9.y, v[NRML], c[17];
DP3    R9.z, v[NRML], c[18];


//# Need to re-normalize normal

DP3    R9.w, R9, R9;
RSQ    R9.w, R9.w;
MUL    R9, R9, R9.w;


//# Get vector from eye to vertex

ADD    R1, R0, -c[5];
DP3    R3.w, R1, R1;
RSQ    R3.w, R3.w;
MUL    R3, R1, R3.w;


//# Calculate E - 2*(E dot N)*N 

DP3    R5, R3, R9;
ADD    R4, R5, R5;
MAD    o[TEX0].xyz, R9, -R4, R3;
MOV    o[TEX0].w, c[0].x;
  
also, for rendering, i''m simply enabling NV_VERTEX_PROGRAM, and then passing 0,0,0 into glVertex3f (because it gets overwritten) Any ideas? ~Main == Colt "MainRoach" McAnlis Programmer www.badheat.com/sinewave
bakery2k1
bakery2k1
What do you mean you are passing (0, 0, 0) into Vertex because it is overwritten?
Overwritten by what?
duhroach
duhroach
By the vertex program.
You''ll notice i move data into the o[TEX0] registar. This overwrtites the texture coords I passed in.

~Main

==
Colt "MainRoach" McAnlis
Programmer
www.badheat.com/sinewave
bakery2k1
bakery2k1
So you mean you are passing (0, 0, 0) to glTexCoord, because it is being overwritten?
In this case, you need not call TexCoord at all.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.