Well first of all hi yall
Next I’m gonna try exposing my problem with hope of finding someone with the right solution to it.
I’m trying to make a reflective shiny object as seen in some of Nvidia’s cubemaping demos, problem is, I’m using an ATi Radeon 9700 Pro which lacks support for some proprietary extensions necessary to produce the mentioned effect.
So I turned to PS and VS programming thinking it’d be pretty straight forward to compute the reflection vector in eye space, based on normals fetched from a normal map, and then use it to look up into my texture cube map loaded in the second texture unit.
Well all I can say is that the result obtained by following code is partilally right since the texturecubemap seems to go upsides down as I rotate the reflective object around.
Can anybody look at my code and attempt to point out the flaws in it?
Thanks in advance
!!ARBvp1.0
#*********************************************************************#
Coder : Abdul Bezrati
Contact: abezrati@hotmail.com
#*********************************************************************#
OPTION ARB_position_invariant;
PARAM modelViewTranspose[4] = { state.matrix.modelview.transpose};
PARAM cameraPosition = {0,0,9,0};
TEMP cameraPosObjSpace, viewVector, temp;
TEMP tangent, binormal;
MOV tangent , vertex.texcoord[1];
MOV binormal, vertex.texcoord[2];
DP3 cameraPosObjSpace.x, modelViewTranspose[0], cameraPosition;
DP3 cameraPosObjSpace.y, modelViewTranspose[1], cameraPosition;
DP3 cameraPosObjSpace.z, modelViewTranspose[2], cameraPosition;
SUB temp, cameraPosObjSpace, vertex.position;
DP3 viewVector.x, temp, tangent;
DP3 viewVector.y, temp, binormal;
DP3 viewVector.z, temp, vertex.normal;
MOV result.texcoord[0], vertex.texcoord[0];
MOV result.texcoord[1], viewVector;
END
!!ARBfp1.0
##
#Author:Abdul Bezrati “Java Cool Dude” #
##
TEMP normalVector, reflectionVector, viewVector;
TEMP temp;
TEX normalVector, fragment.texcoord[0], texture[0], 2D;
MAD normalVector, normalVector , 2.0, -1.0;
MOV viewVector , fragment.texcoord[1];
DP3 viewVector.w, viewVector, viewVector;
RSQ viewVector.w, viewVector.w;
MUL viewVector , viewVector, viewVector.w;
DP3 temp , normalVector , viewVector;
MUL temp , temp , -2;
MAD reflectionVector , temp , normalVector, viewVector;
DP3 reflectionVector.w, reflectionVector, reflectionVector;
RSQ reflectionVector.w, reflectionVector.w;
MUL reflectionVector, reflectionVector, reflectionVector.w;
TEX result.color, reflectionVector, texture[1], CUBE;
END