Gamestudio Links
Zorro Links
Newest Posts
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (degenerate_762, AbrahamR, AndrewAMD, ozgur), 667 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Help with some error #24597
03/24/04 02:01
03/24/04 02:01
Joined: Mar 2004
Posts: 102
T
Taros Offline OP
Member
Taros  Offline OP
Member
T

Joined: Mar 2004
Posts: 102
I've been trying to convert an ATI OceanWater Shader and i think i'm almost done, but when i run my level i get this error: mat_water(73):syntax error.

Sure it says syntax error but i can't find where (i know it's supposed to be in the 73. line of code but it isn't ). So i'm gonna post my conversion here and hope that somebody will find the error i'm looking for.

-------------------------------------------------------------------------------
// Note: Vertexshader 1.1 and Pixelshader 1.4 needed.
// Converted from ATI Ocean Water Shader
// Conversion by Taros

bmap gradient = <oceangradient.bmp>;
bmap waterbump = <waterbump3.bmp>;
bmap enviroment = <cubecloudy+6.tga>;

MATERIAL mat_water
{

Skin1 = waterbump;
Skin2 = gradient;
Skin3 = enviroment;

flags = tangent;

effect=
"
matrix matWorldViewProj;
matrix matWorld;
matrix matWorldView;
matrix matViewInv;

vector vecSunDir;
vector vecDiffuse;
vector vecViewPos;
vector vecAmbient;
vector vecLight;
vector vecFog;
vector vecTime;
vector vecSkill41;

texture mtlSkin1; //Bump
texture mtlSkin2; //Gradient
texture mtlSkin3; // Cubemap

technique water
{
pass p0
{

Texture[0]=<mtlSkin1>; // Bump
Texture[1]=<mtlSkin1>; // Bump
Texture[2]=<mtlSkin3>; // Enviroment
Texture[3]=<mtlSkin2>; // Gradient

minFilter[0]=linear;
magFilter[0]=linear;

minFilter[1]=linear;
magFilter[1]=linear;

minFilter[2]=linear;
magFilter[2]=linear;

minFilter[3]=linear;
magFilter[3]=linear;


Cullmode = 0;
zWriteEnable = false;

//////////////////////////////////////////////////////
//////////////////////////////////////////////////////
// Vertex Shader Constants
// v0 - Vertex Position
// v3 - Vertex Normal
// v7 - Vertex Texture Data u,v
// v8 - Vertex Tangent (v direction)
// v5 - Wave Height Scale
//
// c0 - { 0.0, 0.5, 1.0, 2.0}
// c1 - { 4.0, .5pi, pi, 2pi}
// c2 - {1, -1/3!, 1/5!, -1/7! } //for sin
// c3 - {1/2!, -1/4!, 1/6!, -1/8! } //for cos
// c4-7 - Composite World-View-Projection Matrix
// c8 - ModelSpace Camera Position
// c9 - ModelSpace Light Position
// c10 - {fixup factor for taylor series imprecision, }(1.02, 0.1, 0, 0)
// c11 - {waveHeight0, waveHeight1, waveHeight2, waveHeight3} (80.0, 100.0, 5.0, 5.0)
// c12 - {waveOffset0, waveOffset1, waveOffset2, waveOffset3} (0.0, 0.2, 0.0, 0.0)
// c13 - {waveSpeed0, waveSpeed1, waveSpeed2, waveSpeed3} (0.2, 0.15, 0.4, 0.4)
// c14 - {waveDirX0, waveDirX1, waveDirX2, waveDirX3} (0.25, 0.0, -0.7, -0.8)
// c15 - {waveDirY0, waveDirY1, waveDirY2, waveDirY3} (0.0, 0.15, -0.7, 0.1)
// c16 - { time, sin(time)}
// c17 - {basetexcoord distortion x0, y0, x1, y1} (0.031, 0.04, -0.03, 0.02)
// c18 - World Martix

vertexShaderConstant[0]={0.0f, 0.5f, 1.0f, 2.0f};
vertexShaderConstant[1]={4.0f, .5pi, pi, 2pi};
vertexShaderConstant[2]={1, -1/3!, 1/5!, -1/7!};
vertexShaderConstant[3]={1/2!, -1/4!, 1/6!, -1/8!};
vertexShaderConstant[4]=<matViewInv>;
vertexShaderConstant[5]=<matViewInv>;
vertexShaderConstant[6]=<matViewInv>;
vertexShaderConstant[7]=<matViewInv>;
vertexShaderConstant[8]=<vecViewPos>;
vertexShaderConstant[9]=<vecLight>;
vertexShaderConstant[10]={1.02f, 0.1f, 0f, 0f};
VertexShaderConstant[11]={80.0f, 100.0f, 5.0f, 5.0f};
VertexShaderConstant[12]={0.0f, 0.2, 0.0f, 0.0f};
VertexShaderConstant[13]={0.2f, 0.15f, 0.4f, 0.4f};
VertexShaderConstant[14]={0.25f, 0.0f, -0.7f, -0.8f};
VertexShaderConstant[15]={0.0f, 0.15f, -0.7f, 0.1f};
VertexShaderConstant[16]={vecTime, sin(vecTime), 0f, 0f};
vertexShaderConstant[17]={0.031f, 0.04f, -0.03f, 0.02f};
vertexShaderConstant[18]=<matWorld>;
///////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////
// Pixel Shader Constants
//c0 - Common Const (0, 0.5, 1, 0.25)
//c1 - highlightColor (0.8, 0.76, 0.62, 1)

PixelShaderConstant[0]={0f, 0.5f, 1f, 0.25f};
PixelShaderConstant[1]={0.8f, 0.76f, 0.62f, 1f};

///////////////////////////////////////////////////////////

vertexShader=
decl
{
stream 0;
float v0[3]; //position
float v3[3]; //normal
float v5[3]; //Wave Height Scale
float v7[2]; //uv
}

asm
{
vs.1.1

mul r0, c14, v7.x // use tex coords as inputs to sinusoidal warp
mad r0, c15, v7.y, r0 // use tex coords as inputs to sinusoidal warp

mov r1, c16.x //time...
mad r0, r1, c13, r0 // add scaled time to move bumps according to frequency
add r0, r0, c12 // starting time offset
frc r0.xy, r0 // take frac of all 4 components
frc r1.xy, r0.zwzw //
mov r0.zw, r1.xyxy //

mul r0, r0, c10.x // multiply by fixup factor (due to inaccuracy)
sub r0, r0, c0.y // subtract .5
mul r0, r0, c1.w // mult tex coords by 2pi coords range from(-pi to pi)

mul r5, r0, r0 // (wave vec)^2
mul r1, r5, r0 // (wave vec)^3
mul r6, r1, r0 // (wave vec)^4
mul r2, r6, r0 // (wave vec)^5
mul r7, r2, r0 // (wave vec)^6
mul r3, r7, r0 // (wave vec)^7
mul r8, r3, r0 // (wave vec)^8

mad r4, r1, c2.y, r0 //(wave vec) - ((wave vec)^3)/3!
mad r4, r2, c2.z, r4 // + ((wave vec)^5)/5!
mad r4, r3, c2.w, r4 // - ((wave vec)^7)/7!

mov r0, c0.z //1
mad r5, r5, c3.x ,r0 //-(wave vec)^2/2!
mad r5, r6, c3.y, r5 //+(wave vec)^4/4!
mad r5, r7, c3.z, r5 //-(wave vec)^6/6!
mad r5, r8, c3.w, r5 //+(wave vec)^8/8!

sub r0, c0.z, v5.x //... 1-wave scale
mul r4, r4, r0 // scale sin
mul r5, r5, r0 // scale cos
dp4 r0, r4, c11 //multiply wave heights by waves

mul r0.xyz, v3, r0 //multiply wave magnitude at this vertex by normal
add r0.xyz, r0, v0 //add to position
mov r0.w, c0.z //homogenous component

m4x4 oPos, r0, c4 // OutPos = ObjSpacePos * World-View-Projection Matrix

mul r1, r5, c11 //cos* waveheight
dp4 r9.x, -r1, c14 //normal x offset
dp4 r9.yzw, -r1, c15 //normal y offset and tangent offset

mov r5, v3 //starting normal
mad r5.xy, r9, c10.y, r5 //warped normal move nx, ny according to
//cos*wavedir*waveeheight

mov r4, v8 //tangent
mad r4.z, -r9.x, c10.y, r4.z //warped tangent vector

mov r10, r5
m3x3 r5, r10, c18 // transform normal
dp3 r10.x, r5, r5
rsq r10.y, r10.x
mul r5, r5, r10.y //normalize normal

mov r10, r4
m3x3 r4, r10, c18 // transform tangent
dp3 r10.x, r4, r4
rsq r10.y, r10.x
mul r4, r4, r10.y //normalize tangent

mul r3, r4.yzxw, r5.zxyw
mad r3, r4.zxyw, -r5.yzxw, r3 //xprod to find binormal

mov r10, r0
m4x4 r0, r10, c18 // transform vertex position

sub r2, c8, r0 //view vector
dp3 r10.x, r2, r2
rsq r10.y, r10.x
mul r2, r2, r10.y //normalized view vector

mov r0, c16.x
mul r0, r0, c17.xyxy
frc r0.xy, r0 //frc of incoming time
add r0, v7, r0 //add time to tex coords
mov oT0, r0 //distorted tex coord 0

mov r0, c16.x
mul r0, r0, c17.zwzw
frc r0.xy, r0 //frc of incoming time
add r0, v7, r0 //add time to tex coords
mov oT1, r0.yxzw //distorted tex coord 1

mov oT2, r2 //pass in view vector (worldspace)
mov oT3, r3 //binormal
mov oT4, r4 //tangent
mov oT5, r5 //normal

};

pixelShader=
asm
{
ps.1.4
texld r0, t0 //bump map 0
texld r1, t1 //sample bump map 1
texcrd r2.rgb, t2 //View vector
texcrd r3.rgb, t3 //Binormal
texcrd r4.rgb, t4 //Tangent
texcrd r5.rgb, t5 //Normal

add_d2 r0.xy, r0, r1 //Scaled Average of 2 bumpmaps xy offsets
mul r1.rgb, r0.x, r3
mad r1.rgb, r0.y, r4, r1
mad r1.rgb, r0.z, r5, r1 //Put bumpmap normal into world space

dp3 r0.rgb, r1, r2 //V.N
mad r2.rgb, r1, r0_x2, -r2 //R = 2N(V.N)-V

mov_sat r1, r0_x2 //2 * V.N (sample over range of 1d map!)

phase
texld r2, r2 //cubic env map
texld r3, r1 //Index fresnel map using 2*V.N

mul r2.rgb, r2, r2 //Square the environment map
+mul r2.a, r2.g, r2.g //use green channel of env map as specular

mul r2.rgb, r2, 1-r0.r //Fresnel Term
+mul r2.a, r2.a, r2.a //Specular highlight ^4

add_d4_sat r2.rgb, r2, r3_x2 //+= Water color
+mul r2.a, r2.a, r2.a //Specular highlight ^8

mad_sat r0, r2.a, c1, r2 //+= Specular highlight * highlight color


};


} // end of pass
} // end of technique
";
}

starter mat_water_init

{
bmap_to_cubemap(mat_water.skin3);
bmap_to_normals(mat_water.skin1,2);

}

action water_setting
{
my.material = mat_water;
} // end

-------------------------------------------------------------------------------

Also, how do i setup this vecTime vector i need for the c16 vertexshaderconstant?

Thank you for your time

Re: Help with some error [Re: Taros] #24598
03/24/04 08:37
03/24/04 08:37
Joined: Dec 2003
Posts: 1,097
Maryland, USA
Steempipe Offline
Serious User
Steempipe  Offline
Serious User

Joined: Dec 2003
Posts: 1,097
Maryland, USA
Ahhhggggg.... this is bringing back bitter memories of long, hard nights!

Okay... I ran the script and changed things according to the version I had worked on.

Change the PI stuff to numbers like this:
VertexShaderConstant[0]={0f,0.5f,1f,2f};
VertexShaderConstant[1]={4.0f, 1.57079632f, 3.14159265f, 6.28318530f};
VertexShaderConstant[2]={1f, -0.16161616f, 0.0083333f, -0.00019841f};
VertexShaderConstant[3]={-0.5, 0.041666666, -0.0013888889, 0.000024801587};

For the sine/time thing you will need to change like this:
VertexShaderConstant[16]=<vecSkill41>;

Add something like this to your ACTION:
///////////////////////////////////
var count;

action water_setting
{

my.material = mat_water;
while(1)
{

my.skill41=float(count); //x
my.skill42=float(0); //y
my.skill43=float(0); //z
my.skill44=float(0); //w
count += 0.015*time;
wait(1);
}
}
/////////////////////////////////

Note: You can make any calculations you want and can pass it there using the
x,y,z,w of vecSkill41.

Hey! Good luck and keep us informed. You are tackling a monster.

BTW: If your code does not work after these changes. Send me the WDL file so that I can compare it to mine. I copied and pasted your stuff, then compared that file to the one I already "converted" and the only differences that I could see are the changes mentioned above.

Eric


Re: Help with some error [Re: Steempipe] #24599
03/25/04 00:56
03/25/04 00:56
Joined: Mar 2004
Posts: 102
T
Taros Offline OP
Member
Taros  Offline OP
Member
T

Joined: Mar 2004
Posts: 102
Thanks for the help, Steempipe

BTW i sent you a PM


Moderated by  Blink, Hummel, Superku 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1