Jump to content


Portal Water in QFusion-FX... HELP!


14 replies to this topic

#1 mysticman

    Member

  • Members
  • PipPip
  • 95 posts

Posted 15 July 2005 - 06:53 PM

I have created in QFusion-FX the portalwater, practically to create effects
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
Posted Image

RENDERING
Posted Image

Posted Image

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.

#2 mysticman

    Member

  • Members
  • PipPip
  • 95 posts

Posted 15 July 2005 - 07:52 PM

Posted Image

DIVX WRONGREFLECT
http://www.webalice....rongreflect.rar 6.20mb

#3 Reedbeta

    DevMaster Staff

  • Administrators
  • 4976 posts
  • LocationBellevue, WA

Posted 15 July 2005 - 10:31 PM

Hmm, well my advice to you would be to start out by commenting out everything to do with normal maps and refraction; just get a flat reflection going. That should help you to isolate the problem with your projection.
reedbeta.com - developer blog, OpenGL demos, and other projects

#4 mysticman

    Member

  • Members
  • PipPip
  • 95 posts

Posted 15 July 2005 - 11:26 PM

Do you want to say that is that I should make a fragment program that elaborates only the reflectionmap, so that is what happens?

I will try there, but I think that it will serve to few..... :sad:

However thanks Reed! I will remember you... :happy:

#5 mysticman

    Member

  • Members
  • PipPip
  • 95 posts

Posted 17 July 2005 - 02:39 PM

OK! I have resolved, the problem is........ the reflectionmap doesn't have to be greater of the resolution! :angry: :lol:

Posted Image
Posted Image

:happy:

#6 mysticman

    Member

  • Members
  • PipPip
  • 95 posts

Posted 17 July 2005 - 04:36 PM

Well!!! Badly!!! Let's be there! The very settled house NVIDIA seems to suffer from this defect! :angry:

Posted Image

... while ATI involve well! :D

Posted Image


I start to retract me on what said of NVIDIA! :dry:

#7 mysticman

    Member

  • Members
  • PipPip
  • 95 posts

Posted 17 July 2005 - 04:48 PM

Ok! Seem that if I disable the specular, the defect disappears!

Posted Image

:glare:

#8 Reedbeta

    DevMaster Staff

  • Administrators
  • 4976 posts
  • LocationBellevue, WA

Posted 18 July 2005 - 12:53 AM

That is very weird, I guess it's a driver bug. And the water looks better without specular anyway, don't you think? The specular makes it look like there is a clear plastic sheet over the water.
reedbeta.com - developer blog, OpenGL demos, and other projects

#9 mysticman

    Member

  • Members
  • PipPip
  • 95 posts

Posted 18 July 2005 - 01:37 AM

Certainly too light on the water is not well, but if I had necessity to put a strong light in a map, here that the specular has to enter game!
If I wait that nvidia mends its drivers, then I become old.
There was once the war of the 1000 graphic cards, the programmers become stupid to make to work their program-games on 1000 pc, now this politics is reduced to 2 big producers, but human ignorance always exists. :closedeyes:

#10 mysticman

    Member

  • Members
  • PipPip
  • 95 posts

Posted 18 July 2005 - 05:15 AM

Besides, with these shaders and few changes on them, I can get a discreet glass, which deforms both the anterior things and back...

Posted Image

:)

#11 Mars_999

    New Member

  • Members
  • Pip
  • 1 posts

Posted 19 August 2005 - 09:07 PM

I am having the same issue as you are with a 6800GT card. I tried the VP/FP version myself and had specular issues also. I then ported the code to GLSL and found to have the same issues with specular lighting.... :)

#12 mysticman

    Member

  • Members
  • PipPip
  • 95 posts

Posted 19 August 2005 - 11:11 PM

Need that ATI and NVIDIA put on some accord!!!
drivers of the devil!! :glare:

#13 mysticman

    Member

  • Members
  • PipPip
  • 95 posts

Posted 23 August 2005 - 03:00 PM

Water Code released!
http://typhontaur.forumup.it/viewtopic.php...orum=typhontaur
:happy:

#14 mysticman

    Member

  • Members
  • PipPip
  • 95 posts

Posted 06 September 2005 - 09:24 AM

varying few the shader for the water we can get this effect

HAZE DIVX
http://typhontaur.so...d/hazeruins.avi ~6.91mb
(thanks Sheppard for web-space :wink: )

...I will release the code among some time :wink: )

#15 len00x

    New Member

  • Members
  • Pip
  • 1 posts

Posted 17 December 2005 - 11:22 AM

How have you done these great looking waves that go away from the person in the water?





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users