Removed binary files

This commit is contained in:
n00b
2024-09-28 11:56:07 -04:00
parent 1bf67ba02c
commit 44a2793f37
53 changed files with 3222 additions and 1582 deletions

View File

@@ -0,0 +1,96 @@
/*
* Copyright (c) 2013, elvman
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY elvman ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL elvman BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
const float LOG2 = 1.442695;
uniform vec3 CameraPosition; // Position of main position
uniform float WaveHeight;
uniform vec4 WaterColor;
uniform float ColorBlendFactor;
uniform sampler2D WaterBump; //coverage
uniform sampler2D RefractionMap; //coverage
uniform sampler2D ReflectionMap; //coverage
uniform bool FogEnabled;
uniform int FogMode;
varying vec2 bumpMapTexCoord;
varying vec3 refractionMapTexCoord;
varying vec3 reflectionMapTexCoord;
varying vec3 position3D;
void main()
{
//bump color
vec4 bumpColor = texture2D(WaterBump, bumpMapTexCoord);
vec2 perturbation = WaveHeight * (bumpColor.rg - 0.5);
//refraction
vec2 ProjectedRefractionTexCoords = clamp(refractionMapTexCoord.xy / refractionMapTexCoord.z + perturbation, 0.0, 1.0);
//calculate final refraction color
vec4 refractiveColor = texture2D(RefractionMap, ProjectedRefractionTexCoords );
//reflection
vec2 ProjectedReflectionTexCoords = clamp(reflectionMapTexCoord.xy / reflectionMapTexCoord.z + perturbation, 0.0, 1.0);
//calculate final reflection color
vec4 reflectiveColor = texture2D(ReflectionMap, ProjectedReflectionTexCoords );
//fresnel
vec3 eyeVector = normalize(CameraPosition - position3D);
vec3 upVector = vec3(0.0, 1.0, 0.0);
//fresnel can not be lower than 0
float fresnelTerm = max( dot(eyeVector, upVector), 0.0 );
float fogFactor = 1.0;
if (FogEnabled)
{
float z = gl_FragCoord.z / gl_FragCoord.w;
if (FogMode == 1) //exp
{
float fogFactor = exp2(-gl_Fog.density * z * LOG2);
fogFactor = clamp(fogFactor, 0.0, 1.0);
}
else if (FogMode == 0) //linear
{
fogFactor = (gl_Fog.end - z) / (gl_Fog.end - gl_Fog.start);
}
else if (FogMode == 2) //exp2
{
float fogFactor = exp2(-gl_Fog.density * gl_Fog.density * z * z * LOG2);
fogFactor = clamp(fogFactor, 0.0, 1.0);
}
}
vec4 combinedColor = refractiveColor * fresnelTerm + reflectiveColor * (1.0 - fresnelTerm);
vec4 finalColor = ColorBlendFactor * WaterColor + (1.0 - ColorBlendFactor) * combinedColor;
gl_FragColor = mix(gl_Fog.color, finalColor, fogFactor );
}

View File

@@ -0,0 +1,83 @@
/*
* Copyright (c) 2013, elvman
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY elvman ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL elvman BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
float3 CameraPosition; // Position of main position
float WaveHeight;
float4 WaterColor;
float ColorBlendFactor;
sampler2D WaterBump; //coverage
sampler2D RefractionMap; //coverage
sampler2D ReflectionMap; //coverage
// Pixel shader output structure
struct PS_OUTPUT
{
float4 color : COLOR0; // Pixel color
};
struct PS_INPUT
{
float4 position : POSITION; // vertex position
float2 bumpMapTexCoord : TEXCOORD0;
float3 refractionMapTexCoord : TEXCOORD1;
float3 reflectionMapTexCoord : TEXCOORD2;
float3 position3D : TEXCOORD3;
};
PS_OUTPUT main( PS_INPUT input )
{
PS_OUTPUT output;
//bump color
float4 bumpColor = tex2D(WaterBump, input.bumpMapTexCoord);
float2 perturbation = WaveHeight * (bumpColor.rg - 0.5);
//refraction
float2 ProjectedRefractionTexCoords = saturate(input.refractionMapTexCoord.xy / input.refractionMapTexCoord.z + perturbation);
//calculate final refraction color
float4 refractiveColor = tex2D(RefractionMap, ProjectedRefractionTexCoords );
//reflection
float2 ProjectedReflectionTexCoords = saturate(input.reflectionMapTexCoord.xy / input.reflectionMapTexCoord.z + perturbation);
//calculate final reflection color
float4 reflectiveColor = tex2D(ReflectionMap, ProjectedReflectionTexCoords );
//fresnel
float3 eyeVector = normalize(CameraPosition - input.position3D);
float3 upVector = float3(0.0, 1.0, 0.0);
//fresnel can not be lower than 0
float fresnelTerm = max( dot(eyeVector, upVector), 0.0 );
float4 combinedColor = refractiveColor * fresnelTerm + reflectiveColor * (1.0 - fresnelTerm);
output.color = ColorBlendFactor * WaterColor + (1.0 - ColorBlendFactor) * combinedColor;
return output;
}

View File

@@ -0,0 +1,65 @@
/*
* Copyright (c) 2013, elvman
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY elvman ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL elvman BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
//uniform mat4 View;
uniform mat4 WorldViewProj; // World * View * Projection transformation
uniform mat4 WorldReflectionViewProj; // World * Reflection View * Projection transformation
uniform float WaveLength;
uniform float Time;
uniform float WindForce;
uniform vec2 WindDirection;
// Vertex shader output structure
varying vec2 bumpMapTexCoord;
varying vec3 refractionMapTexCoord;
varying vec3 reflectionMapTexCoord;
varying vec3 position3D;
void main()
{
//color = gl_Color;
// transform position to clip space
vec4 pos = WorldViewProj * gl_Vertex;
gl_Position = pos;
// calculate vawe coords
bumpMapTexCoord = gl_MultiTexCoord0.xy / WaveLength + Time * WindForce * WindDirection;
// refraction texcoords
refractionMapTexCoord.x = 0.5 * (pos.w + pos.x);
refractionMapTexCoord.y = 0.5 * (pos.w + pos.y);
refractionMapTexCoord.z = pos.w;
// reflection texcoords
pos = WorldReflectionViewProj * gl_Vertex;
reflectionMapTexCoord.x = 0.5 * (pos.w + pos.x);
reflectionMapTexCoord.y = 0.5 * (pos.w + pos.y);
reflectionMapTexCoord.z = pos.w;
// position of the vertex
position3D = gl_Vertex.xyz;
}

View File

@@ -0,0 +1,80 @@
/*
* Copyright (c) 2013, elvman
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY elvman ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL elvman BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
//float4x4 View;
float4x4 WorldViewProj; // World * View * Projection transformation
float4x4 WorldReflectionViewProj; // World * Reflection View * Projection transformation
float WaveLength;
float Time;
float WindForce;
float2 WindDirection;
// Vertex shader output structure
struct VS_OUTPUT
{
float4 position : POSITION; // vertex position
float2 bumpMapTexCoord : TEXCOORD0;
float3 refractionMapTexCoord : TEXCOORD1;
float3 reflectionMapTexCoord : TEXCOORD2;
float3 position3D : TEXCOORD3;
};
struct VS_INPUT
{
float4 position : POSITION;
float4 color : COLOR0;
float2 texCoord0 : TEXCOORD0;
};
VS_OUTPUT main(VS_INPUT input)
{
VS_OUTPUT output;
// transform position to clip space
float4 pos = mul(input.position, WorldViewProj);
output.position = pos;
// calculate vawe coords
output.bumpMapTexCoord = input.texCoord0 / WaveLength + Time * WindForce * WindDirection;
// refraction texcoords
output.refractionMapTexCoord.x = 0.5 * (pos.w + pos.x);
output.refractionMapTexCoord.y = 0.5 * (pos.w - pos.y);
output.refractionMapTexCoord.z = pos.w;
// reflection texcoords
pos = mul(input.position, WorldReflectionViewProj);
output.reflectionMapTexCoord.x = 0.5 * (pos.w + pos.x);
output.reflectionMapTexCoord.y = 0.5 * (pos.w - pos.y);
output.reflectionMapTexCoord.z = pos.w;
// position of the vertex
output.position3D = input.position;
return output;
}