of water in the maps.
The portalwater exploits the technology of q3, the mirror surface.
The copy that I make some rendering of the mirror, in the reflection texture is
correct, that is exactly the image reflected of the scene.
The problem that I have found is this:
For how much the reflectionmap is correct, it is projected badly in the surface of destination. Believe me I have tried of everything, but really I don't succeed.
I would be thankful if kindly you helped me in this.
REFLECTIONMAP

RENDERING


My forum is: http://typhontaur.fo...orum=typhontaur
Also find me on: http://www.quakesrc....wforum.php?f=12
The used shaders are those of Michael Horsch ( http://www.bonzaisof.../water_tut.html )
VERTEX PROGRAM
!!ARBvp1.0
#================================================================
# shader_WATER_vp.s
#================================================================
ATTRIB attr_TexCoord0 = vertex.attrib[8];
ATTRIB attr_VertexPos = vertex.position;
ATTRIB attr_Tangent = vertex.attrib[6];
ATTRIB attr_Binormal = vertex.attrib[7];
ATTRIB attr_Normal = vertex.normal;
#================================================================
PARAM mvp[4] = {state.matrix.mvp};
PARAM mtx[4] = {state.matrix.texture[0]};
#================================================================
PARAM time1 = program.local[5];
PARAM time2 = program.local[6];
#================================================================
PARAM u_view_origin = program.env[0];
PARAM u_light_origin = program.env[1];
#================================================================
OUTPUT var_texCoord0 = result.texcoord[0];
OUTPUT var_texCoord1 = result.texcoord[1];
OUTPUT var_texCoord2 = result.texcoord[2];
OUTPUT var_texCoord3 = result.texcoord[3];
OUTPUT var_viewVec = result.texcoord[4];
OUTPUT var_lightVec = result.texcoord[5];
#================================================================
TEMP vpos, temp;
TEMP coord0;
#================================================================
SUB temp, u_view_origin, vertex.position;
DP3 var_viewVec.x, temp, attr_Tangent;
DP3 var_viewVec.y, temp, attr_Binormal;
DP3 var_viewVec.z, temp, attr_Normal;
MOV var_viewVec.w, 1.0;
#================================================================
SUB temp, u_light_origin, vertex.position;
DP3 var_lightVec.x, temp, attr_Tangent;
DP3 var_lightVec.y, temp, attr_Binormal;
DP3 var_lightVec.z, temp, attr_Normal;
MOV var_lightVec.w, 1.0;
#================================================================
#transform vertex coords to clip coords
#================================================================
DP4 vpos.x, mvp[0], vertex.position;
DP4 vpos.y, mvp[1], vertex.position;
DP4 vpos.z, mvp[2], vertex.position;
DP4 vpos.w, mvp[3], vertex.position;
MOV result.position, vpos;
DP4 coord0.x, mtx[0], attr_TexCoord0;
DP4 coord0.y, mtx[1], attr_TexCoord0;
DP4 coord0.z, mtx[2], attr_TexCoord0;
DP4 coord0.w, mtx[3], attr_TexCoord0;
MOV var_texCoord0, coord0;
ADD var_texCoord1.y, coord0, time1;
MOV var_texCoord1.xzw, coord0;
ADD var_texCoord2.y, coord0, time2;
MOV var_texCoord2.xzw, coord0;
DP4 var_texCoord3.x, mtx[0], vpos;
DP4 var_texCoord3.y, mtx[1], vpos;
DP4 var_texCoord3.z, mtx[2], vpos;
DP4 var_texCoord3.w, mtx[3], vpos;
END
FRAGMENT PROGRAM
!!ARBfp1.0
#================================================================
# shader_WATER_fp.s
#================================================================
OPTION ARB_precision_hint_fastest;
#================================================================
PARAM u_specular_exponent = program.env[6];
PARAM u_ambient = program.env[15];
#================================================================
ATTRIB var_texCoord0 = fragment.texcoord[0];
ATTRIB var_texCoord1 = fragment.texcoord[1];
ATTRIB var_texCoord2 = fragment.texcoord[2];
ATTRIB var_texCoord3 = fragment.texcoord[3];
ATTRIB var_viewVec = fragment.texcoord[4];
ATTRIB var_lightVec = fragment.texcoord[5];
#================================================================
PARAM scale1 = {0.005, 0.005, 0.005,0.005};
PARAM scale2 = {0.020,0.020, 0.020, 0.020};
PARAM tscale = {0.5, 0.5, 0.5, 0.5};
PARAM two = {2.0,2.0,2.0,2.0};
PARAM mone = {-1.0,-1.0,-1.0,1.0};
PARAM fexp = 4.0;
#================================================================
PARAM watercolor = program.local[7];
PARAM useDepth = program.local[8];
#================================================================
TEMP projb, refr, refl, wdepth, invdepth;
TEMP nmap, invLen, temp, viewt,fres,invfres;
TEMP disdis, temp2;
TEMP ntc;
TEMP lightTS, specular, lref;
TEMP fdist, height, pxtc;
#================================================================
#normalize light vector
#================================================================
DP3 temp, var_lightVec,var_lightVec;
RSQ invLen, temp.x;
MUL lightTS, var_lightVec, invLen;
#================================================================
#normalize vector to viewpos
#================================================================
DP3 temp, var_viewVec,var_viewVec;
RSQ invLen, temp.x;
MUL viewt, var_viewVec, invLen;
#================================================================
#distortion distortion
#================================================================
MUL temp, var_texCoord2, tscale;
TEX disdis, temp, texture[3], 2D; #load du/dv normalmap
MUL disdis, disdis, scale2; #scale down
#================================================================
#Add distortion to texcoord 1
#================================================================
ADD temp2, var_texCoord1, disdis;
#================================================================
#distortion du/dv normal map
#================================================================
TEX fdist, temp2, texture[3], 2D;
MAD fdist, fdist, two, mone;
#================================================================
#scale down du/dv normalmap
#================================================================
MUL fdist, fdist, scale1;
#================================================================
#load normalmap with new texcoords
#================================================================
TEX nmap, temp2, texture[2], 2D;
#================================================================
#scale and bias
#================================================================
MAD nmap, nmap, two, mone;
#================================================================
#normalize
#================================================================
DP3 temp, nmap, nmap;
RSQ invLen, temp.r;
MUL nmap, nmap, invLen;
#================================================================
DP3 temp, nmap, lightTS;
MUL temp, temp, two;
MUL temp, temp, nmap;
SUB lref, temp, lightTS;
#================================================================
#calculate projective texcoords
#================================================================
RCP temp, var_texCoord3.w;
MUL projb.x, var_texCoord3.x, temp.x;
MUL projb.y, var_texCoord3.y, temp.y;
MUL projb.z, var_texCoord3.z, temp.z;
ADD projb, projb, {1.0, 1.0, 1.0, 1.0};
MUL projb, projb, {0.5, 0.5, 0.5, 0.5};
#================================================================
#add distortion to projective texcoords
#================================================================
ADD ntc, projb, fdist;
#================================================================
MIN ntc, ntc, 0.999;
MAX ntc, ntc, 0.001;
#================================================================
#load reflection and refraction with new texcoords
#================================================================
TEX refr, ntc, texture[0], 2D;
TEX refl, ntc, texture[1], 2D;
#================================================================
#load depth texture
#================================================================
TEX wdepth, ntc, texture[4], 2D;
#================================================================
#check if depth is used
#================================================================
MUL wdepth, wdepth, useDepth;
#================================================================
#calculate depth^fexp.x
#================================================================
POW wdepth, wdepth.x, fexp.x;
#================================================================
#invert depth
#================================================================
SUB invdepth, 1.0, wdepth;
#================================================================
#calculate specular highlight
#================================================================
DP3 specular, lref, viewt;
POW specular, specular.x, u_specular_exponent.x;
#================================================================
#calculate fresnel
#================================================================
DP3 temp, nmap, viewt;
SUB fres, 1.0, temp;
#================================================================
#invert fresnel
#================================================================
SUB invfres, 1.0, fres;
#================================================================
#calculate reflection and refraction
#================================================================
MUL refr, refr, invfres;
MUL refr, refr, invdepth;
MUL temp, watercolor, wdepth;
MUL temp, temp, invfres;
ADD refr, temp, refr;
MUL refl, refl, fres;
#================================================================
#add reflection and refraction
#================================================================
ADD temp, refl, refr;
#================================================================
#add specular highlight
#================================================================
##MUL temp, temp, watercolor;
ADD result.color, temp, specular;
END
Thanks! Typhontaur.



















