Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (ozgur, degenerate_762, 7th_zorro), 1,075 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Ocean Waves #40298
01/29/05 12:35
01/29/05 12:35
Joined: Oct 2004
Posts: 71
Los Angeles, CA
D
DGS_Stan Offline OP
Junior Member
DGS_Stan  Offline OP
Junior Member
D

Joined: Oct 2004
Posts: 71
Los Angeles, CA
Hi, did anybody made an open source ocean water with waves shader effect? like the one below from Nvidia:


http://developer.nvidia.com/object/fx_composer_shaders.html

If someone has can you please let me know where i can find it.


Thank you.


Stan

Re: Ocean Waves [Re: DGS_Stan] #40299
01/29/05 12:42
01/29/05 12:42
Joined: Nov 2004
Posts: 832
United States, Utah
Braxton Offline
Developer
Braxton  Offline
Developer

Joined: Nov 2004
Posts: 832
United States, Utah
Well if you download FX Composer from them they have that one already made.


"The GREAT LAW: Life is and always will be justly ordered, and that all past experiences, good and bad, were the equitable out working of our evolving, yet unevolved selves" - As A Man Thinketh
Re: Ocean Waves [Re: Braxton] #40300
01/29/05 13:49
01/29/05 13:49
Joined: Aug 2003
Posts: 378
Marion,N.C. USA
Whisper Offline
Senior Member
Whisper  Offline
Senior Member

Joined: Aug 2003
Posts: 378
Marion,N.C. USA
stan

do you want the one to use with 3dgs, or the one for C++.

Re: Ocean Waves [Re: Whisper] #40301
01/29/05 16:33
01/29/05 16:33
Joined: Dec 2002
Posts: 1,866
B
b_102373 Offline
Senior Developer
b_102373  Offline
Senior Developer
B

Joined: Dec 2002
Posts: 1,866
Quote:

stan

do you want the one to use with 3dgs, or the one for C++.




3DGS most likely.

Re: Ocean Waves [Re: b_102373] #40302
01/29/05 19:33
01/29/05 19:33
Joined: Jan 2003
Posts: 798
New Zealand
Bright Offline
User
Bright  Offline
User

Joined: Jan 2003
Posts: 798
New Zealand
WOW, ive been looking for a shader program like this for AGES

Thanks guys


KAIN - Coming soon...
Re: Ocean Waves [Re: DGS_Stan] #40303
02/19/05 21:52
02/19/05 21:52
Joined: May 2004
Posts: 66
Brazil
key_46 Offline
Junior Member
key_46  Offline
Junior Member

Joined: May 2004
Posts: 66
Brazil
This is the code from Ocean Shader:

Code:

/*********************************************************************NVMH3****
Path: NVSDK\Common\media\cgfx
File: ocean.fx

Copyright NVIDIA Corporation 2003
TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THIS SOFTWARE IS PROVIDED
*AS IS* AND NVIDIA AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES, EITHER EXPRESS
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL NVIDIA OR ITS SUPPLIERS
BE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES
WHATSOEVER (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS,
BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR ANY OTHER PECUNIARY LOSS)
ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF NVIDIA HAS
BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.


Comments:
Simple ocean shader with animated bump map and geometric waves
Based partly on "Effective Water Simulation From Physical Models", GPU Gems

******************************************************************************/

float Script : STANDARDSGLOBAL <
string UIWidget = "none";
string ScriptClass = "object";
string ScriptOrder = "standard";
string ScriptOutput = "color";
string Script = "Technique=PS20;";
> = 0.8;

float4x4 worldMatrix : World < string UIWidget = "none";>; // World or Model matrix
float4x4 wvpMatrix : WorldViewProjection < string UIWidget = "none";>; // Model*View*Projection
float4x4 worldViewMatrix : WorldView < string UIWidget = "none";>;
float4x4 viewInverseMatrix : ViewInverse < string UIWidget = "none";>;

float time : Time < string UIWidget = "none"; >;

texture normalMap : Normal
<
string ResourceName = "Raygun_Color_04.dds";
string ResourceType = "2D";
>;

texture cubeMap : Environment
<
string ResourceName = "Sky_Beach.dds";
string ResourceType = "Cube";
>;

sampler2D normalMapSampler = sampler_state
{
Texture = <normalMap>;
#if 0
// this is a trick from Halo - use point sampling for sparkles
MagFilter = Linear;
MinFilter = Point;
MipFilter = None;
#else
MagFilter = Linear;
MinFilter = Linear;
MipFilter = Linear;
#endif
};

samplerCUBE envMapSampler = sampler_state
{
Texture = <cubeMap>;
MinFilter = Linear;
MagFilter = Linear;
MipFilter = Linear;
AddressU = Clamp;
AddressV = Clamp;
};

float bumpHeight
<
string UIWidget = "slider";
float UIMin = 0.0; float UIMax = 2.0; float UIStep = 0.01;
string UIName = "Bump Height";
> = 0.1;

float2 textureScale
<
string UIName = "Texture scale";
> = { 8.0, 4.0 };

float2 bumpSpeed
<
string UIName = "Bumpmap translation speed";
> = { -0.05, 0.0 };

float fresnelBias
<
string UIName = "Fresnel bias";
string UIWidget = "slider";
float UIMin = 0.0; float UIMax = 1.0; float UIStep = 0.01;
> = 0.1;

float fresnelPower
<
string UIName = "Fresnel exponent";
string UIWidget = "slider";
float UIMin = 1.0; float UIMax = 10.0; float UIStep = 0.01;
> = 4.0;

float hdrMultiplier
<
string UIName = "HDR multiplier";
string UIWidget = "slider";
float UIMin = 0.0; float UIMax = 100.0; float UIStep = 0.01;
> = 3.0;

float4 deepColor : Diffuse
<
string UIName = "Deep water color";
> = {0.0f, 0.0f, 0.1f, 1.0f};

float4 shallowColor : Diffuse
<
string UIName = "Shallow water color";
> = {0.0f, 0.5f, 0.5f, 1.0f};

float4 reflectionColor : Specular
<
string UIName = "Reflection color";
> = {1.0f, 1.0f, 1.0f, 1.0f};

// these are redundant, but makes the ui easier:
float reflectionAmount
<
string UIName = "Reflection amount";
string UIWidget = "slider";
float UIMin = 0.0; float UIMax = 2.0; float UIStep = 0.01;
> = 1.0f;

float waterAmount
<
string UIName = "Water color amount";
string UIWidget = "slider";
float UIMin = 0.0; float UIMax = 2.0; float UIStep = 0.01;
> = 1.0f;

float waveAmp
<
string UIName = "Wave amplitude";
string UIWidget = "slider";
float UIMin = 0.0; float UIMax = 10.0; float UIStep = 0.1;
> = 1.0;

float waveFreq
<
string UIName = "Wave frequency";
string UIWidget = "slider";
float UIMin = 0.0; float UIMax = 1.0; float UIStep = 0.001;
> = 0.1;



struct a2v {
float4 Position : POSITION; // in object space
float2 TexCoord : TEXCOORD0;
float3 Tangent : TEXCOORD1;
float3 Binormal : TEXCOORD2;
float3 Normal : NORMAL;
};

struct v2f {
float4 Position : POSITION; // in clip space
float2 TexCoord : TEXCOORD0;
float3 TexCoord1 : TEXCOORD1; // first row of the 3x3 transform from tangent to cube space
float3 TexCoord2 : TEXCOORD2; // second row of the 3x3 transform from tangent to cube space
float3 TexCoord3 : TEXCOORD3; // third row of the 3x3 transform from tangent to cube space

float2 bumpCoord0 : TEXCOORD4;
float2 bumpCoord1 : TEXCOORD5;
float2 bumpCoord2 : TEXCOORD6;

float3 eyeVector : TEXCOORD7;
};

// wave functions

struct Wave {
float freq; // 2*PI / wavelength
float amp; // amplitude
float phase; // speed * 2*PI / wavelength
float2 dir;
};

#define NWAVES 2
Wave wave[NWAVES] = {
{ 1.0, 1.0, 0.5, float2(-1, 0) },
{ 2.0, 0.5, 1.3, float2(-0.7, 0.7) }
};

float evaluateWave(Wave w, float2 pos, float t)
{
return w.amp * sin( dot(w.dir, pos)*w.freq + t*w.phase);
}

// derivative of wave function
float evaluateWaveDeriv(Wave w, float2 pos, float t)
{
return w.freq*w.amp * cos( dot(w.dir, pos)*w.freq + t*w.phase);
}

// sharp wave functions
float evaluateWaveSharp(Wave w, float2 pos, float t, float k)
{
return w.amp * pow(sin( dot(w.dir, pos)*w.freq + t*w.phase)* 0.5 + 0.5 , k);
}

float evaluateWaveDerivSharp(Wave w, float2 pos, float t, float k)
{
return k*w.freq*w.amp * pow(sin( dot(w.dir, pos)*w.freq + t*w.phase)* 0.5 + 0.5 , k - 1) * cos( dot(w.dir, pos)*w.freq + t*w.phase);
}

v2f BumpReflectWaveVS(a2v IN,
uniform float4x4 WorldViewProj,
uniform float4x4 World,
uniform float4x4 ViewIT,
uniform float BumpScale,
uniform float2 textureScale,
uniform float2 bumpSpeed,
uniform float time,
uniform float waveFreq,
uniform float waveAmp
)
{
v2f OUT;

wave[0].freq = waveFreq;
wave[0].amp = waveAmp;

wave[1].freq = waveFreq*2.0;
wave[1].amp = waveAmp*0.5;

float4 P = IN.Position;

// sum waves
P.y = 0.0;
float ddx = 0.0, ddy = 0.0;
for(int i=0; i<NWAVES; i++) {
P.y += evaluateWave(wave[i], P.xz, time);
float deriv = evaluateWaveDeriv(wave[i], P.xz, time);
ddx += deriv * wave[i].dir.x;
ddy += deriv * wave[i].dir.y;
}

// compute tangent basis
float3 B = float3(1, ddx, 0);
float3 T = float3(0, ddy, 1);
float3 N = float3(-ddx, 1, -ddy);

OUT.Position = mul(P, WorldViewProj);

// pass texture coordinates for fetching the normal map
OUT.TexCoord.xy = IN.TexCoord*textureScale;

time = fmod(time, 100.0);
OUT.bumpCoord0.xy = IN.TexCoord*textureScale + time*bumpSpeed;
OUT.bumpCoord1.xy = IN.TexCoord*textureScale*2.0 + time*bumpSpeed*4.0;
OUT.bumpCoord2.xy = IN.TexCoord*textureScale*4.0 + time*bumpSpeed*8.0;

// compute the 3x3 tranform from tangent space to object space
float3x3 objToTangentSpace;
// first rows are the tangent and binormal scaled by the bump scale
objToTangentSpace[0] = BumpScale * normalize(T);
objToTangentSpace[1] = BumpScale * normalize(B);
objToTangentSpace[2] = normalize(N);

OUT.TexCoord1.xyz = mul(objToTangentSpace, World[0].xyz);
OUT.TexCoord2.xyz = mul(objToTangentSpace, World[1].xyz);
OUT.TexCoord3.xyz = mul(objToTangentSpace, World[2].xyz);

// compute the eye vector (going from shaded point to eye) in cube space
float4 worldPos = mul(P, World);
OUT.eyeVector = ViewIT[3] - worldPos; // view inv. transpose contains eye position in world space in last row
return OUT;
}


// Pixel Shaders

float4 BumpReflectPS20(v2f IN,
uniform sampler2D NormalMap,
uniform samplerCUBE EnvironmentMap) : COLOR
{
// fetch the bump normal from the normal map
float4 N = tex2D(NormalMap, IN.TexCoord.xy)*2.0 - 1.0;

float3x3 m; // tangent to world matrix
m[0] = IN.TexCoord1;
m[1] = IN.TexCoord2;
m[2] = IN.TexCoord3;
float3 Nw = mul(m, N.xyz);

// float3 E = float3(IN.TexCoord1.w, IN.TexCoord2.w, IN.TexCoord3.w);
float3 E = IN.eyeVector;
float3 R = reflect(-E, Nw);

return texCUBE(EnvironmentMap, R);
}

float4 OceanPS20(v2f IN,
uniform sampler2D NormalMap,
uniform samplerCUBE EnvironmentMap,
uniform half4 deepColor,
uniform half4 shallowColor,
uniform half4 reflectionColor,
uniform half4 reflectionAmount,
uniform half4 waterAmount,
uniform half fresnelPower,
uniform half fresnelBias,
uniform half hdrMultiplier
) : COLOR
{
// sum normal maps
half4 t0 = tex2D(NormalMap, IN.bumpCoord0.xy)*2.0-1.0;
half4 t1 = tex2D(NormalMap, IN.bumpCoord1.xy)*2.0-1.0;
half4 t2 = tex2D(NormalMap, IN.bumpCoord2.xy)*2.0-1.0;
half3 N = t0.xyz + t1.xyz + t2.xyz;
// half3 N = t1.xyz;

half3x3 m; // tangent to world matrix
m[0] = IN.TexCoord1;
m[1] = IN.TexCoord2;
m[2] = IN.TexCoord3;
half3 Nw = mul(m, N.xyz);
Nw = normalize(Nw);

// reflection
float3 E = normalize(IN.eyeVector);
half3 R = reflect(-E, Nw);

half4 reflection = texCUBE(EnvironmentMap, R);
// hdr effect (multiplier in alpha channel)
reflection.rgb *= (1.0 + reflection.a*hdrMultiplier);

// fresnel - could use 1D tex lookup for this
half facing = 1.0 - max(dot(E, Nw), 0);
half fresnel = fresnelBias + (1.0-fresnelBias)*pow(facing, fresnelPower);

half4 waterColor = lerp(deepColor, shallowColor, facing);

return waterColor*waterAmount + reflection*reflectionColor*reflectionAmount*fresnel;
// return waterColor;
// return fresnel;
// return reflection;
}

technique PS20 <
string Script = "Pass=p0;";
> {
pass p0 <
string Script = "Draw=geometry;";
> {
VertexShader = compile vs_2_0 BumpReflectWaveVS(wvpMatrix, worldMatrix, viewInverseMatrix,
bumpHeight, textureScale, bumpSpeed, time,
waveFreq, waveAmp);

Zenable = true;
ZWriteEnable = true;
CullMode = None;

// PixelShader = compile ps_2_0 BumpReflectPS20(normalMapSampler, envMapSampler);
PixelShader = compile ps_2_0 OceanPS20(normalMapSampler, envMapSampler,
deepColor, shallowColor, reflectionColor, reflectionAmount, waterAmount,
fresnelPower, fresnelBias, hdrMultiplier);
}
}





ADPA Ataque Dos Pôneis Assassinos! Atack Of Killer Ponys! ADPA(R) all rights reserved
Re: Ocean Waves [Re: Bright] #40304
02/21/05 16:29
02/21/05 16:29
Joined: Oct 2002
Posts: 8,939
planet.earth
ello Offline
Senior Expert
ello  Offline
Senior Expert

Joined: Oct 2002
Posts: 8,939
planet.earth
In Antwort auf:

WOW, ive been looking for a shader program like this for AGES

Thanks guys




ugh,man! why are you waiting for this for ages while it already has been converted "ages" ago???

ppl.. please move your mouse upwards to the search function before posting the same things again and again. even the thread title is nearly the same:P and double :P

Re: Ocean Waves [Re: ello] #40305
02/21/05 21:49
02/21/05 21:49
Joined: Nov 2004
Posts: 1,011
South Africa
capanno Offline
Serious User
capanno  Offline
Serious User

Joined: Nov 2004
Posts: 1,011
South Africa
Is FX Composer free?

Re: Ocean Waves [Re: DGS_Stan] #40306
02/22/05 07:04
02/22/05 07:04
Joined: May 2004
Posts: 66
Brazil
key_46 Offline
Junior Member
key_46  Offline
Junior Member

Joined: May 2004
Posts: 66
Brazil


ADPA Ataque Dos Pôneis Assassinos! Atack Of Killer Ponys! ADPA(R) all rights reserved
Re: Ocean Waves [Re: DGS_Stan] #40307
02/22/05 07:11
02/22/05 07:11
Joined: May 2004
Posts: 66
Brazil
key_46 Offline
Junior Member
key_46  Offline
Junior Member

Joined: May 2004
Posts: 66
Brazil
ãããm...ello...a little bot respect don't hurt anyone, with my age you nor it imagined what a code line was. And my age is 13;


ADPA Ataque Dos Pôneis Assassinos! Atack Of Killer Ponys! ADPA(R) all rights reserved
Page 1 of 2 1 2

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