Initial commit

This commit is contained in:
2026-02-02 04:50:13 +01:00
commit 5b11698731
22592 changed files with 7677434 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
// Copyright 2006-2010 (C) - Frictional Games
//
// This file is part of HPL1 Engine
//
// For conditions of distribution and use, see copyright notice in LICENSE-shaders
//
///////////////////////////////////////////////////////
/// AMBIENT DIFFUSE COLOR FRAG PROGRAM ////////////
///////////////////////////////////////////////////////
in vec4 vLightColor;
in vec2 vUv;
OUTPUT
uniform sampler2D tex0; //diffuseMap
uniform vec3 ambientColor;
void main()
{
outColor = texture(tex0, vUv);
outColor.xyz *= ambientColor;
}

View File

@@ -0,0 +1,28 @@
// Copyright 2006-2010 (C) - Frictional Games
//
// This file is part of HPL1 Engine
//
// For conditions of distribution and use, see copyright notice in LICENSE-shaders
//
///////////////////////////////////////////////////////
/// SPECULAR BUMPMAPPING 2D FRAGMENT PROGRAM //////////
///////////////////////////////////////////////////////
in vec4 vColor;
in vec3 vUv; //in object space
in vec3 vLightDir;
in vec2 vScreenPos;
OUTPUT
uniform sampler2D tex0; //NormalMap
uniform sampler2D tex1; //LightMap
void main()
{
vec4 BumpVec = (1 - 2*texture(tex0, vUv));
vec4 LightCol = texture(tex1,vScreenPos);
float Diffuse = dot(vLightDir,BumpVec.xyz)*LightCol.x;
outColor.xyz = Diffuse*vColor.xyz;
}

View File

@@ -0,0 +1,48 @@
// Copyright 2006-2010 (C) - Frictional Games
//
// This file is part of HPL1 Engine
//
// For conditions of distribution and use, see copyright notice in LICENSE-shaders
//
///////////////////////////////////////////////////////
/// BUMPMAPPING 2D VERTEX PROGRAM ////////////
///////////////////////////////////////////////////////
vec4 position = gl_Vertex;
vec3 normal = gl_Normal;
vec3 uv = gl_MultiTexCoord0.xyz;
out vec4 vColor;
out vec3 vUv;
out vec3 vLightDir;
out vec2 vScreenPos;
uniform mat4 worldViewProj;
uniform vec3 LightPos;
uniform float LightRadius;
uniform vec4 LightColor;
void main()
{
vec3 L;
//Get the direction of the light and normalize it
vLightDir.xy = position.xy - LightPos.xy;
vScreenPos = (vLightDir.xy + (LightRadius) )/ (LightRadius*2.0);
//rotate the light to texture (tangent) space. Normal x=cos(angle) y = sin(angle)
vec2 TempLight = vLightDir.xy;
vLightDir.x = normal.x*TempLight.x + normal.y*TempLight.y;
vLightDir.y = normal.x*TempLight.y - normal.y*TempLight.x;
vLightDir.x *= normal.z/abs(normal.z);
vLightDir.y *= abs(normal.z)-2.0;
vLightDir.z = -LightPos.z;
vLightDir = normalize(vLightDir);
gl_Position = worldViewProj * position;
vColor = clamp(LightColor, vec4(0.0), vec4(1.0));
vUv = uv;
}

View File

@@ -0,0 +1,41 @@
// Copyright 2006-2010 (C) - Frictional Games
//
// This file is part of HPL1 Engine
//
// For conditions of distribution and use, see copyright notice in LICENSE-shaders
//
///////////////////////////////////////////////////////
/// BUMP COLOR SPECULAR LIGHTING FRAGMENT PROGRAM ///////////
///////////////////////////////////////////////////////
in vec4 vLightColor;
in vec2 vUv;
in vec3 vLightDir;
in vec3 vHalfVec;
OUTPUT
uniform sampler2D tex0; //diffuseMap
uniform sampler2D tex1; //normalMap
uniform samplerCube tex2; //normalCubeMap
uniform sampler1D tex3; //falloffMap
uniform sampler2D tex6; //specularMap
void main()
{
float attenuation = texture1D(tex3,dot(vLightDir,vLightDir)).x;
vec3 bumpVec = texture(tex1, vUv).xyz;
bumpVec.xyz = (2.0*bumpVec.xyz)-vec3(1.0);
vec3 normLightDir = normalize(vLightDir);
vec3 normHalfVec = normalize(vHalfVec);
float specular = clamp(dot(normHalfVec, bumpVec.xyz), 0.0, 1.0);
specular = pow(specular, 16.0) * vLightColor.w;
outColor.xyz = texture(tex0, vUv).xyz * vLightColor.xyz * dot(normLightDir, bumpVec.xyz)
+ (specular * texture(tex6, vUv).xyz);
outColor.xyz *= attenuation;
}

View File

@@ -0,0 +1,46 @@
// Copyright 2006-2010 (C) - Frictional Games
//
// This file is part of HPL1 Engine
//
// For conditions of distribution and use, see copyright notice in LICENSE-shaders
//
///////////////////////////////////////////////////////
/// DIFFUSE COLOR SPOTLIGHTING FRAGMENT PROGRAM /////////////
///////////////////////////////////////////////////////
in vec4 vLightColor;
in vec2 vUv;
in vec3 vLightDir;
in vec3 vHalfVec;
in vec4 vSpotlightUv;
OUTPUT
uniform sampler2D tex0; //diffuseMap
uniform sampler2D tex1; //normalMap
uniform samplerCube tex2; //normalCubeMap
uniform sampler1D tex3; //falloffMap
uniform sampler2D tex4; //spotlightMap
uniform sampler1D tex5; //spotNegRejectMap
uniform sampler2D tex6; //specularMap
void main()
{
vec3 diffuse = texture(tex0, vUv).xyz;
vec3 bumpVec = (2.0*texture(tex1, vUv)-vec4(1.0)).xyz;
vec3 lightVec = normalize(vLightDir);
vec3 normHalfVec = normalize(vHalfVec);
float attenuation = texture1D(tex3,dot(vLightDir,vLightDir)).x;
vec4 spotColor = texture(tex4, vSpotlightUv.xy / vSpotlightUv.w);
float rejectNeg = texture1D(tex5,vSpotlightUv.z + 0.5).x;
float specular = clamp(dot(normHalfVec, bumpVec.xyz), 0.0, 1.0);
specular = pow(specular, 16.0)* vLightColor.w * spotColor.w;
outColor.xyz = diffuse * dot(lightVec, bumpVec.xyz) * vLightColor.xyz * spotColor.xyz
+ (specular * texture(tex6, vUv).xyz);
outColor.xyz *= attenuation * rejectNeg;
}

View File

@@ -0,0 +1,37 @@
// Copyright 2006-2010 (C) - Frictional Games
//
// This file is part of HPL1 Engine
//
// For conditions of distribution and use, see copyright notice in
// LICENSE-shaders
//
///////////////////////////////////////////////////////
/// SPECULAR BUMPMAPPING 2D FRAGMENT PROGRAM //////////
///////////////////////////////////////////////////////
in vec4 vColor;
in vec3 vUv; // in object space
in vec3 vLightDir;
in vec3 vHalfVec;
in vec2 vScreenPos;
OUTPUT
uniform sampler2D tex0; //NormalMap
uniform sampler2D tex1; //LightMap
void main() {
vec4 BumpVec = (vec4(1.0) - 2.0 * texture(tex0, uv));
vec4 LightCol = texture(tex1, vScreenPos);
BumpVec.xyz = normalize(BumpVec.xyz);
float Diffuse = dot(normalize(vLightDir), BumpVec.xyz) * LightCol.x;
float Specular = dot(normalize(vHalfVec), BumpVec.xyz);
Specular = pow(Specular, 24.0) * BumpVec.w * vColor.w;
outColor.xyz = Diffuse * vColor.xyz;
outColor.w = Specular * LightCol.x;
}

View File

@@ -0,0 +1,67 @@
// Copyright 2006-2010 (C) - Frictional Games
//
// This file is part of HPL1 Engine
//
// For conditions of distribution and use, see copyright notice in LICENSE-shaders
//
///////////////////////////////////////////////////////
/// SPECULAR BUMPMAPPING 2D VERTEX PROGRAM ////////////
///////////////////////////////////////////////////////
vec4 position = gl_Vertex;
vec3 normal = gl_Normal;
vec2 uv = gl_MultiTexCoord0.xy;
out vec4 vColor
out vec2 vUv;
out vec3 vLightDir;
out vec3 vHalfVec;
out vec2 vScreenPos;
uniform mat4 worldViewProj;
uniform vec3 LightPos;
uniform vec3 EyePos;
uniform float LightRadius;
uniform vec4 LightColor;
void main()
{
vec3 L;
//Get the direction of the light and normalize it
vLightDir.xy = position.xy - LightPos.xy;
vScreenPos = (vLightDir.xy + (LightRadius)) / (LightRadius * 2.0);
//rotate the light to texture (tangent) space. Normal x=cos(angle) y = sin(angle)
vec2 TempLight = vLightDir.xy;
vLighttDir.x = normal.x*TempLight.x + normal.y*TempLight.y;
vLighttDir.y = normal.x*TempLight.y - normal.y*TempLight.x;
vLighttDir.x *= normal.z / abs(normal.z);
vLighttDir.y *= abs(normal.z)-2.0;
vLighttDir.z = -LightPos.z;
vLighttDir = normalize(vLightDir);
//Get the halfangle and normalize it
vHalfVec.xy = position.xy - EyePos.xy;
vHalfVec.z = -EyePos.y;
///rotate halfvec as well NOTE: Not sure you need this...
vec2 TempHalfVec = vHalfVec.xy;
vHalfVec.x = normal.x*TempHalfVec.x + normal.y*TempHalfVec.y;
vHalfVec.y = normal.x*TempHalfVec.y - normal.y*TempHalfVec.x;
vHalfVec.x *= normal.z/abs(normal.z);
vHalfVec.y *= abs(normal.z) - 2.0;
vHalfVec = normalize(vHalfVec);
vHalfVec = normalize(vHalfVec + vLightDir);
gl_Position = worldViewProj * position;
vColor = clamp(LightColor, vec4(0.0), vec4(1.0));
vUv = uv;
}

View File

@@ -0,0 +1,40 @@
// Copyright 2006-2010 (C) - Frictional Games
//
// This file is part of HPL1 Engine
//
// For conditions of distribution and use, see copyright notice in LICENSE-shaders
//
///////////////////////////////////////////////////////
/// BUMP SPECULAR LIGHTING FRAGMENT PROGRAM ///////////
///////////////////////////////////////////////////////
in vec4 vLightColor;
in vec2 vUv;
in vec3 vLightDir;
in vec3 vHalfVec;
OUTPUT
uniform sampler2D tex0; //diffuseMap
uniform sampler2D tex1; //normalMap
uniform samplerCube tex2; //normalCubeMap
uniform sampler1D tex3; //falloffMap
void main()
{
float attenuation = texture1D(tex3,dot(vLightDir,vLightDir)).x;
vec4 bumpVec = texture(tex1, vUv);
bumpVec.xyz = (2.0*bumpVec.xyz)-vec3(1.0);
vec3 normLightDir = normalize(vLightDir);
vec3 normHalfVec = normalize(vHalfVec);
float specular = clamp(dot(normHalfVec, bumpVec.xyz), 0.0, 1.0);
specular = pow(specular, 16.0) * vLightColor.w * clamp(bumpVec.w, 0.0, 1.0);
outColor.xyz = texture(tex0, vUv).xyz * vLightColor.xyz * dot(normLightDir, bumpVec.xyz) +
specular;
outColor.xyz *= attenuation;
}

View File

@@ -0,0 +1,46 @@
// Copyright 2006-2010 (C) - Frictional Games
//
// This file is part of HPL1 Engine
//
// For conditions of distribution and use, see copyright notice in LICENSE-shaders
//
///////////////////////////////////////////////////////
/// DIFFUSE SPOTLIGHTING FRAGMENT PROGRAM /////////////
///////////////////////////////////////////////////////
in vec4 vLightColor;
in vec2 vUv;
in vec3 vLightDir;
in vec3 vHalfVec;
in vec4 vSpotlightUv;
OUTPUT
uniform sampler2D tex0; //diffuseMap
uniform sampler2D tex1; //normalMap
uniform sampler1D tex3; //falloffMap
uniform sampler2D tex4; //spotlightMap
uniform sampler1D tex5; //spotNegRejectMap
void main()
{
vec3 diffuse = texture(tex0, vUv).xyz;
vec4 bumpVec = texture(tex1, vUv);
bumpVec.xyz = (2.0*bumpVec.xyz)-vec3(1.0);
vec3 lightVec = normalize(vLightDir);
vec3 normHalfVec = normalize(vHalfVec);
float attenuation = texture1D(tex3,dot(vLightDir,vLightDir)).x;
vec4 spotColor = texture(tex4, vSpotlightUv.xy / vSpotlightUv.w);
float rejectNeg = texture1D(tex5,vSpotlightUv.z + 0.5).x;
float specular = clamp(dot(normHalfVec, bumpVec.xyz), 0.0, 1.0);
specular = pow(specular, 16.0) * vLightColor.w * clamp(bumpVec.w, 0.0, 1.0) * clamp(spotColor.w, 0.0, 1.0);
outColor.xyz = diffuse * dot(lightVec, bumpVec.xyz) * vLightColor.xyz * spotColor.xyz +
specular;
outColor.xyz *= attenuation * rejectNeg;
}

View File

@@ -0,0 +1,42 @@
// Copyright 2006-2010 (C) - Frictional Games
//
// This file is part of HPL1 Engine
//
// For conditions of distribution and use, see copyright notice in LICENSE-shaders
//
///////////////////////////////////////////////////////
/// DIFFUSE SPOTLIGHTING FRAGMENT PROGRAM /////////////
///////////////////////////////////////////////////////
in vec4 vLightColor;
in vec2 vUv;
in vec3 vLightDir;
in vec3 vHalfVec;
in vec4 vSpotlightUv;
OUTPUT
uniform sampler2D tex0; //diffuseMap
uniform sampler2D tex1; //normalMap
uniform samplerCube tex2; //normalCubeMap
uniform sampler2D tex3; //spotlightMap
void main()
{
vec3 diffuse = texture(tex0, vUv).xyz;
vec4 bumpVec = texture(tex1, vUv);
bumpVec.xyz = (2.0*bumpVec.xyz)-vec3(1.0);
vec3 lightVec = (2.0*textureCube(tex2,vLightDir)-vec4(1.0)).xyz;
vHalfVec = (2.0*textureCube(tex2,vHalfVec)-vec4(1.0)).xyz;
vec4 spotColor = texture(tex3, vSpotlightUv.xy / vSpotlightUv.w);
float specular = clamp(dot(vHalfVec, bumpVec.xyz), 0.0, 1.0);
specular = pow(specular, 16.0) * vLightColor.w * clamp(bumpVec.w, 0.0, 1.0) * clamp(spotColor.w, 0.0, 1.0);
outColor.xyz = diffuse * dot(lightVec, bumpVec.xyz) * vLightColor.xyz * spotColor.xyz +
specular;
}

View File

@@ -0,0 +1,32 @@
// Copyright 2006-2010 (C) - Frictional Games
//
// This file is part of HPL1 Engine
//
// For conditions of distribution and use, see copyright notice in LICENSE-shaders
//
///////////////////////////////////////////////////////
/// DIFFUSE LIGHTING FRAGMENT PROGRAM /////////////////
///////////////////////////////////////////////////////
in vec4 vLightColor;
in vec2 vUv;
in vec3 vLightDir;
OUTPUT
uniform sampler2D tex0; //diffuseMap
uniform sampler2D tex1; //normalMap
uniform samplerCube tex2; //normalCubeMap
uniform sampler1D tex3; //falloffMap
void main()
{
float attenuation = texture1D(tex3,dot(vLightDir,vLightDir)).x;
vec4 bumpVec = (2.0*texture(tex1, vUv)-vec4(1.0));
vec4 lightVec = (2.0*textureCube(tex2,vLightDir)-vec4(1.0));
outColor.xyz = texture(tex0, vUv).xyz * vLightColor.xyz * attenuation * dot(lightVec.xyz,bumpVec.xyz);
outColor.w = 0;
}

View File

@@ -0,0 +1,39 @@
// Copyright 2006-2010 (C) - Frictional Games
//
// This file is part of HPL1 Engine
//
// For conditions of distribution and use, see copyright notice in
// LICENSE-shaders
//
///////////////////////////////////////////////////////
/// BUMP SPOTLIGHTING FRAGMENT PROGRAM /////////////
///////////////////////////////////////////////////////
in vec4 vLightColor;
in vec2 vUv;
in vec3 vLightDir;
in vec4 vSpotlightUv;
OUTPUT
uniform sampler2D tex0; //diffuseMap
uniform sampler2D tex1; //normalMap
uniform samplerCube tex2; //normalCubeMap
uniform sampler1D tex3; //falloffMap
uniform sampler2D tex4; //spotlightMap
uniform sampler1D tex5; //spotNegRejectMap
void main() {
vec3 diffuse = texture(tex0, vUv).xyz;
vec3 bumpVec = (2 * texture(tex1, vUv) - 1).xyz;
vec3 lightVec = (2.0 * textureCube(tex2, vLightDir) - 1.0).xyz;
float attenuation = texture1D(tex3, dot(vLightDir, vLightDir)).x;
vec3 spotColor =
texture(tex4, vSpotlightUv.xy / vSpotlightUv.w).xyz;
float rejectNeg = texture1D(tex5, vSpotlightUv.z + 0.5).x;
outColor.xyz = diffuse * dot(lightVec, bumpVec) * attenuation *
vLightColor.xyz * spotColor * rejectNeg;
}

View File

@@ -0,0 +1,32 @@
// Copyright 2006-2010 (C) - Frictional Games
//
// This file is part of HPL1 Engine
//
// For conditions of distribution and use, see copyright notice in
// LICENSE-shaders
//
///////////////////////////////////////////////////////
/// BUMP SPOTLIGHTING FRAGMENT PROGRAM /////////////
///////////////////////////////////////////////////////
in vec4 vLightColor;
in vec2 vUv;
in vec3 vLightDir;
in vec4 vSpotlightUv;
OUTPUT
uniform sampler2D tex0; //diffuseMap
uniform sampler2D tex1; //normalMap
uniform samplerCube tex2; //normalCubeMap
uniform sampler2D tex3; //spotlightMap
void main() {
vec3 diffuse = texture(tex0, vUv).xyz;
vec3 bumpVec = (2.0 * texture(tex1, vUv) - vec4(1.0)).xyz;
vec3 lightVec = (2.0 * textureCube(tex2, vLightDir) - vec4(1.0)).xyz;
vec3 spotColor =
texture(tex3, vSpotlightUv.xy / vSpotlightUv.w).xyz;
outColor.xyz = diffuse * dot(lightVec, bumpVec) * vLightColor.xyz * spotColor;
}

View File

@@ -0,0 +1,34 @@
// Copyright 2006-2010 (C) - Frictional Games
//
// This file is part of HPL1 Engine
//
// For conditions of distribution and use, see copyright notice in LICENSE-shaders
//
///////////////////////////////////////////////////////
/// DIFFUSE SPECULAR LIGHTING FRAGMENT PROGRAM ////////
///////////////////////////////////////////////////////
in vec4 vLightColor;
in vec2 vUv;
in vec3 vLightDir;
in vec3 vHalfVec;
OUTPUT
uniform sampler2D tex0; //diffuseMap
uniform sampler1D tex3; //falloffMap
void main()
{
float attenuation = texture1D(tex3, dot(vLightDir,vLightDir)).x;
vec3 lightDir = normalize(vLightDir);
vec3 halfVec = normalize(vHalfVec);
float specular = clamp(dot(halfVec, vec3(0,0,1)), 0.0, 1.0);
specular = pow(specular, 16.0) * vLightColor.w;
outColor.xyz = specular + texture(tex0, vUv).xyz * vLightColor.xyz * dot(normalize(lightDir), vec3(0,0,1));
outColor.xyz = outColor.xyz * attenuation;
}

View File

@@ -0,0 +1,51 @@
// Copyright 2006-2010 (C) - Frictional Games
//
// This file is part of HPL1 Engine
//
// For conditions of distribution and use, see copyright notice in LICENSE-shaders
//
///////////////////////////////////////////////////////
/// DIFFUSE SPECULAR LIGHTING VERTEX PROGRAM //////////
///////////////////////////////////////////////////////
vec4 position = gl_Vertex;
vec3 normal = gl_Normal;
vec2 uv = gl_MultiTexCoord0.xy;
vec4 tangent = gl_MultiTexCoord1;
out vec4 vLightColor;
out vec2 vUv;
out vec3 vLightDir;
out vec3 vHalfVec;
uniform mat4 worldViewProj;
uniform vec3 EyePos;
uniform vec3 LightPos;
uniform vec4 LightColor;
uniform vec3 LightDirMul;
void main()
{
gl_Position = (worldViewProj * position);
vUv = uv;
vec3 lightDir = LightPos - position.xyz;
vLightDir = lightDir * LightDirMul;
//Calculate rotation for light to get it to tangent space.
vec3 binormal = cross(normal,tangent.xyz)*tangent.w;
mat3 rotation = transpose(mat3(tangent.xyz, binormal, normal));
//Transform the lightdir
vLightDir = (rotation * vLightDir);
//Get the halfvector for the specular term
vHalfVec = normalize(EyePos - position.xyz);
//transform to tangent space
vHalfVec = (rotation * vHalfVec);
vHalfVec = normalize(vLightDir)+vHalfVec;
vLightColor = clamp(LightColor, vec4(0.0), vec4(1.0));
}

View File

@@ -0,0 +1,41 @@
// Copyright 2006-2010 (C) - Frictional Games
//
// This file is part of HPL1 Engine
//
// For conditions of distribution and use, see copyright notice in LICENSE-shaders
//
///////////////////////////////////////////////////////
/// DIFFUSE SPECULAR SPOTLIGHTING FRAGMENT PROGRAM /////////////
///////////////////////////////////////////////////////
in vec4 vLightColor;
in vec2 vUv;
in vec3 vLightDir;
in vec3 vHalfVec;
in vec4 vSpotlightUv;
OUTPUT
uniform sampler2D tex0; //diffuseMap
uniform sampler1D tex3; //falloffMap
uniform sampler2D tex4; //spotlightMap
uniform sampler1D tex5; //spotNegRejectMap
void main()
{
vec3 diffuse = texture(tex0, vUv).xyz;
vec3 lightNormal = normalize(vLightDir);
vec3 halfVec = normalize(vHalfVec);
float attenuation = texture1D(tex3,dot(vLightDir,vLightDir)).x;
vec4 spotColor = texture(tex4, vSpotlightUv.xy / vSpotlightUv.w);
float rejectNeg = texture1D(tex5,vSpotlightUv.z + 0.5).x;
float specular = clamp(dot(halfVec, vec3(0,0,1)), 0.0, 1.0);
specular = pow(specular, 16.0) * vLightColor.w * spotColor.w;
outColor.xyz = specular + diffuse * dot(lightNormal, vec3(0,0,1)) * vLightColor.xyz * spotColor.xyz;
outColor.xyz *= attenuation * rejectNeg;
}

View File

@@ -0,0 +1,57 @@
// Copyright 2006-2010 (C) - Frictional Games
//
// This file is part of HPL1 Engine
//
// For conditions of distribution and use, see copyright notice in LICENSE-shaders
//
///////////////////////////////////////////////////////
/// DIFFUSE SPECUALR SPOT LIGHTING VERTEX PROGRAM ////////////
///////////////////////////////////////////////////////
vec4 position = gl_Vertex;
vec3 normal = gl_Normal;
vec2 uv = gl_MultiTexCoord0.xy;
vec4 tangent = gl_MultiTexCoord1;
out vec4 vLightColor;
out vec2 vUv;
out vec3 vLightDir;
out vec3 vHalfVec;
out vec4 vSpotlightUv;
uniform mat4 worldViewProj;
uniform mat4 spotViewProj;
uniform vec3 EyePos;
uniform vec3 LightPos;
uniform vec4 LightColor;
uniform vec3 LightDirMul;
void main()
{
gl_Position = (worldViewProj * position);
vUv = uv;
vSpotlightUv = (spotViewProj * position);
vec3 lightDir = LightPos - position.xyz;
vLightDir = lightDir * LightDirMul;
//Calculate rotation for light to get it to tangent space.
vec3 binormal = cross(normal,tangent.xyz)*tangent.w;
mat3 rotation = transpose(mat3(tangent.xyz, binormal, normal));
//Transform the lightdir
vLightDir = (rotation * vLightDir);
//Get the halfvector for the specular term
vHalfVec = normalize(EyePos - position.xyz);
//transform to tangent space
vHalfVec = (rotation * vHalfVec);
vHalfVec = normalize(vLightDir)+vHalfVec;
vLightColor = clamp(LightColor, vec4(0.0), vec4(1.0));
}

View File

@@ -0,0 +1,37 @@
// Copyright 2006-2010 (C) - Frictional Games
//
// This file is part of HPL1 Engine
//
// For conditions of distribution and use, see copyright notice in LICENSE-shaders
//
///////////////////////////////////////////////////////
/// DIFFUSE SPECULAR SPOTLIGHTING FRAGMENT PROGRAM /////////////
///////////////////////////////////////////////////////
in vec4 vLightColor;
in vec2 vUv;
in vec3 vLightDir;
in vec3 vHalfVec;
in vec4 vSpotlightUv;
OUTPUT
uniform sampler2D tex0; //diffuseMap
uniform samplerCube tex2; //normalCubeMap
uniform sampler2D tex3; //spotlightMap
void main()
{
vec3 diffuse = texture(tex0, vUv).xyz;
vec3 lightNormal = (2.0*textureCube(tex2,vLightDir)-vec4(1.0)).xyz;
vHalfVec = (2.0*textureCube(tex2,vHalfVec)-vec4(1.0)).xyz;
vec4 spotColor = texture(tex3, vSpotlightUv.xy / vSpotlightUv.w);
float specular = clamp(dot(vHalfVec, vec3(0,0,1)), 0.0, 1.0);
specular = pow(specular, 16.0) * vLightColor.w * spotColor.w;
outColor.xyz = specular + diffuse * dot(lightNormal, vec3(0,0,1)) * vLightColor.xyz * spotColor.xyz;
}

View File

@@ -0,0 +1,22 @@
// Copyright 2006-2010 (C) - Frictional Games
//
// This file is part of HPL1 Engine
//
// For conditions of distribution and use, see copyright notice in LICENSE-shaders
//
///////////////////////////////////////////////////////
/// SIMPLE DIFFUSE COLOR FRAGMENT PROGRAM ////////////
///////////////////////////////////////////////////////
in vec4 vColor;
in vec2 vUv;
OUTPUT
uniform sampler2D tex0; //diffuseMap;
void main()
{
outColor = texture(tex0, vUv) * vColor;
}

View File

@@ -0,0 +1,26 @@
// Copyright 2006-2010 (C) - Frictional Games
//
// This file is part of HPL1 Engine
//
// For conditions of distribution and use, see copyright notice in LICENSE-shaders
//
///////////////////////////////////////////////////////
/// SIMPLE DIFFUSE COLOR VERTEX PROGRAM ////////////
///////////////////////////////////////////////////////
vec4 position = gl_Vertex;
vec4 color = gl_Color;
vec2 uv = gl_MultiTexCoord0.xy;
out vec4 vColor;
out vec2 vUv;
uniform mat4 worldViewProj;
void main()
{
gl_Position = worldViewProj * position;
vColor = clamp(color, vec4(0.0), vec4(1.0));
vUv = uv;
}

View File

@@ -0,0 +1,30 @@
// Copyright 2006-2010 (C) - Frictional Games
//
// This file is part of HPL1 Engine
//
// For conditions of distribution and use, see copyright notice in LICENSE-shaders
//
///////////////////////////////////////////////////////
/// DIFFUSE COLOR MUL VERTEX PROGRAM ////////////
///////////////////////////////////////////////////////
vec4 position = gl_Vertex;
vec3 color = gl_Color.xyz;
vec3 uv = gl_MultiTexCoord0.xyz;
out vec3 vColor;
out vec3 vUv;
uniform mat4 worldViewProj
uniform vec4 colorMul;
void main()
{
gl_Position = worldViewProj * position;
vColor = clamp(color * colorMul, vec3(0.0), vec3(1.0));
vUv = uv;
}

View File

@@ -0,0 +1,16 @@
// Diffuse_EnvMap_Reflect.fragment
in vec3 vColor;
in vec3 vUv;
in vec3 vUv2;
OUTPUT
uniform sampler2D tex0; // diffuse
uniform samplerCube tex1;
void main() {
vec4 diffuseColor = texture(tex0, vUv.st);
vec4 reflectedColor = textureCube(tex1, vUv2);
outColor = mix(diffuseColor, reflectedColor, diffuseColor.a);
}

View File

@@ -0,0 +1,39 @@
// Copyright 2006-2010 (C) - Frictional Games
//
// This file is part of HPL1 Engine
//
// For conditions of distribution and use, see copyright notice in LICENSE-shaders
//
///////////////////////////////////////////////////////
/// SIMPLE DIFFUSE COLOR VERTEX PROGRAM ////////////
///////////////////////////////////////////////////////
vec4 position = gl_Vertex;
vec3 normal = gl_Normal;
vec3 color = gl_Color.xyz;
vec3 uv = gl_MultiTexCoord0.xyz;
out vec3 vColor;
out vec3 vUv;
out vec3 vUv2;
uniform mat4 worldViewProj;
uniform mat4 objectWorldMatrix;
uniform vec3 eyeWorldPos;
void main()
{
gl_Position = (worldViewProj * position);
vColor = clamp(color, vec3(0.0), vec3(1.0));
mat3 rotation = mat3(objectWorldMatrix);
vec3 worldPos = (objectWorldMatrix * position).xyz;
vec3 worldNormal = (rotation * normal);
vec3 eyeDir = worldPos - eyeWorldPos;
vUv = uv;
vUv2 = reflect(eyeDir, worldNormal);
}

View File

@@ -0,0 +1,30 @@
// Copyright 2006-2010 (C) - Frictional Games
//
// This file is part of HPL1 Engine
//
// For conditions of distribution and use, see copyright notice in LICENSE-shaders
//
///////////////////////////////////////////////////////
/// DIFFUSE LIGHTING FRAGMENT PROGRAM /////////////////
///////////////////////////////////////////////////////
in vec4 vLightColor;
in vec2 vUv;
in vec3 vLightDir;
OUTPUT
uniform sampler2D tex0; //diffuseMap
uniform samplerCube tex2; //normalCubeMap
uniform sampler1D tex3; //falloffMap
void main()
{
float attenuation = texture1D(tex3,dot(vLightDir,vLightDir)).x;
vec3 lightDir = (2.0*textureCube(tex2,vLightDir)-vec4(1.0)).xyz;
outColor.xyz = attenuation * texture(tex0, vUv).xyz * vLightColor.xyz * dot(lightDir, vec3(0,0,1));
outColor.w = 0.0;
}

View File

@@ -0,0 +1,43 @@
// Copyright 2006-2010 (C) - Frictional Games
//
// This file is part of HPL1 Engine
//
// For conditions of distribution and use, see copyright notice in LICENSE-shaders
//
///////////////////////////////////////////////////////
/// DIFFUSE LIGHTING VERTEX PROGRAM ////////////
///////////////////////////////////////////////////////
vec4 position = gl_Vertex;
vec3 normal = gl_Normal;
vec2 uv = gl_MultiTexCoord0.xy;
vec4 tangent = gl_MultiTexCoord1;
out vec4 vLightColor;
out vec2 vUv;
out vec3 vLightDir;
uniform mat4 worldViewProj;
uniform vec3 LightPos;
uniform vec4 LightColor;
uniform vec3 LightDirMul;
void main()
{
gl_Position = (worldViewProj * position);
vUv = uv;
vec3 lightDir = LightPos - position.xyz;
vLightDir = lightDir * LightDirMul;
//Calculate rotation for light to get it to tangent space.
vec3 binormal = cross(normal,tangent.xyz)*tangent.w;
mat3 rotation = transpose(mat3(tangent.xyz, binormal, normal));
//Transform the lightdir
vLightDir = (rotation * vLightDir);
vLightColor = clamp(LightColor, vec4(0.0), vec4(1.0));
}

View File

@@ -0,0 +1,35 @@
// Copyright 2006-2010 (C) - Frictional Games
//
// This file is part of HPL1 Engine
//
// For conditions of distribution and use, see copyright notice in LICENSE-shaders
//
///////////////////////////////////////////////////////
/// DIFFUSE SPOT LIGHTING FRAGMENT PROGRAM /////////////
///////////////////////////////////////////////////////
in vec4 vLightColor;
in vec2 vUv;
in vec3 vLightDir;
in vec4 vSpotlightUv;
OUTPUT
uniform sampler2D tex0; //diffuseMap
uniform samplerCube tex2; //normalCubeMap
uniform sampler1D tex3; //falloffMap
uniform sampler2D tex4; //spotlightMap
uniform sampler1D tex5; //spotNegRejectMap
void main()
{
vec3 diffuse = texture(tex0, vUv).xyz;
vec3 lightNormal = (2.0*textureCube(tex2,vLightDir)-vec4(1.0)).xyz;
float attenuation = texture1D(tex3,dot(vLightDir,vLightDir)).x;
vec3 spotColor = texture(tex4, vSpotlightUv.xy / vSpotlightUv.w).xyz;
float rejectNeg = texture1D(tex5,vSpotlightUv.z + 0.5).x;
outColor.xyz = diffuse * dot(lightNormal, vec3(0,0,1)) * attenuation *
vLightColor.xyz * spotColor * rejectNeg;
}

View File

@@ -0,0 +1,47 @@
// Copyright 2006-2010 (C) - Frictional Games
//
// This file is part of HPL1 Engine
//
// For conditions of distribution and use, see copyright notice in LICENSE-shaders
//
///////////////////////////////////////////////////////
/// DIFFUSE SPOT LIGHTING VERTEX PROGRAM ////////////
///////////////////////////////////////////////////////
vec4 position = gl_Vertex;
vec3 normal = gl_Normal;
vec2 uv = gl_MultiTexCoord0.xy;
vec4 tangent = gl_MultiTexCoord1;
out vec4 vLightColor;
out vec2 vUv;
out vec3 vLightDir;
out vec4 vSpotlightUv;
uniform mat4 worldViewProj;
uniform mat4 spotViewProj;
uniform vec3 LightPos;
uniform vec4 LightColor;
uniform vec3 LightDirMul;
void main()
{
gl_Position = (worldViewProj * position);
vUv = uv;
vSpotlightUv = (spotViewProj * position);
vec3 lightDir = LightPos - position.xyz;
vLightDir = lightDir * LightDirMul;
//Calculate rotation for light to get it to tangent space.
vec3 binormal = cross(normal,tangent.xyz)*tangent.w;
mat3 rotation = transpose(mat3(tangent.xyz, binormal, normal));
//Transform the lightdir
vLightDir = (rotation * vLightDir);
vLightColor = clamp(LightColor, vec4(0.0), vec4(1.0));
}

View File

@@ -0,0 +1,29 @@
// Copyright 2006-2010 (C) - Frictional Games
//
// This file is part of HPL1 Engine
//
// For conditions of distribution and use, see copyright notice in LICENSE-shaders
//
///////////////////////////////////////////////////////
/// DIFFUSE SPOT LIGHTING FRAGMENT PROGRAM /////////////
///////////////////////////////////////////////////////
in vec4 vLightColor;
in vec2 vUv;
in vec3 vLightDir;
in vec4 vSpotlightUv;
OUTPUT
uniform sampler1D tex0; //falloffMap
uniform sampler1D tex1; //spotNegRejectMap
void main()
{
float attenuation = texture1D(tex0, dot(vLightDir,vLightDir)).x;
float rejectNeg = texture1D(tex1, vSpotlightUv.z + 0.5).x;
outColor.w = attenuation * rejectNeg;
outColor.xyz = vec3(0.0);
}

View File

@@ -0,0 +1,30 @@
// Copyright 2006-2010 (C) - Frictional Games
//
// This file is part of HPL1 Engine
//
// For conditions of distribution and use, see copyright notice in LICENSE-shaders
//
///////////////////////////////////////////////////////
/// DIFFUSE SPOT LIGHTING FRAGMENT PROGRAM /////////////
///////////////////////////////////////////////////////
in vec4 vLightColor;
in vec2 vUv;
in vec3 vLightDir;
in vec4 vSpotlightUv;
OUTPUT
uniform sampler2D tex0; //diffuseMap
uniform samplerCube tex2; //normalCubeMap
uniform sampler2D tex3; //spotlightMap
void main()
{
vec3 diffuse = texture(tex0, vUv).xyz;
vec3 lightNormal = (2.0*textureCube(tex2,vLightDir)-vec4(1.0)).xyz;
vec3 spotColor = texture(tex3, vSpotlightUv.xy / vSpotlightUv.w).xyz;
outColor.xyz = diffuse * dot(lightNormal, vec3(0,0,1)) * vLightColor.xyz * spotColor;
}

View File

@@ -0,0 +1,21 @@
//FallBack01_Bump_Light.fragment
in vec3 vLightDir;
in vec3 vUv;
in vec3 vLightPos;
OUTPUT
uniform samplerCube tex0; //normalizedVecMap
uniform sampler2D tex1; //normalMap
uniform sampler3D tex2; //attenuation
void main() {
vec4 nv = textureCube(tex0, vLightDir);
vec4 norm = texture(tex1, vUv.st);
vec4 attenuation = texture3D(tex2, vLightPos);
outColor = vec4(4*((nv.r - 0.5)*(norm.r - 0.5) + (nv.g - 0.5)*(norm.g - 0.5) + (nv.b - 0.5)*(norm.b - 0.5)));
outColor.a *= attenuation.g;
}

View File

@@ -0,0 +1,17 @@
//Fallback01_Diffuse_Light_Spot.fragment
in vec4 vLightColor;
in vec3 vUv;
in vec4 vSpotlightUv;
in float vRejectUv;
uniform sampler2D tex0; //diffuseMap
uniform sampler2D tex1; //normalMap
uniform sampler1D tex2; //spotNegRejectMap
void main() {
vec4 diffuse = texture(tex0, vUv.xy);
vec4 spot = texture(tex1, vSpotlightUv.xy / vSpotlightUv.w);
float spotNegReject = texture1D(tex2, vSpotlightUv.w).r;
outColor = diffuse * spot * spotNegReject * vLightColor;
}

View File

@@ -0,0 +1,37 @@
// Copyright 2006-2010 (C) - Frictional Games
//
// This file is part of HPL1 Engine
//
// For conditions of distribution and use, see copyright notice in LICENSE-shaders
//
///////////////////////////////////////////////////////
/// DIFFUSE LIGHTING VERTEX PROGRAM //////////////////
///////////////////////////////////////////////////////
vec4 position = gl_Vertex;
vec3 normal = gl_Normal;
vec3 uv = gl_MultiTexCoord0.xyz;
vec4 tangent = gl_MultiTexCoord1;
out vec4 vLightColor;
out vec3 vUv;
out vec4 vSpotlightUv;
out float vRejectUv;
uniform mat4 worldViewProj;
uniform mat4 spotViewProj;
uniform vec3 LightPos;
uniform vec4 LightColor;
uniform vec3 LightDirMul;
void main()
{
gl_Position = (worldViewProj * position);
vUv = uv;
vSpotlightUv = (spotViewProj * position);
vRejectUv = vSpotlightUv.z + 0.5;
vLightColor = clamp(LightColor, vec4(0.0), vec4(1.0));
}

View File

@@ -0,0 +1,19 @@
//Fallback01_Diffuse_Light_p1.fragment
in vec4 vLightColor;
in vec3 vUv;
in vec3 vLightPos;
in vec3 vLightDir;
OUTPUT
uniform samplerCube tex0; //normalMap
uniform sampler3D tex2; //attenuation
void main() {
vec4 normalizedVec = textureCube(tex0, vLightDir);
vec4 attenuation = texture3D(tex2, vLightPos);
outColor = vec4(2.0*(normalizedVec.b - 0.5));
outColor.a *= attenuation.g;
}

View File

@@ -0,0 +1,45 @@
// Copyright 2006-2010 (C) - Frictional Games
//
// This file is part of HPL1 Engine
//
// For conditions of distribution and use, see copyright notice in LICENSE-shaders
//
///////////////////////////////////////////////////////
/// DIFFUSE LIGHTING VERTEX PROGRAM //////////////////
///////////////////////////////////////////////////////
vec4 position = gl_Vertex;
vec3 normal = gl_Normal;
vec3 uv = gl_MultiTexCoord0.xyz;
vec4 tangent = gl_MultiTexCoord1;
out vec4 vLightColor;
out vec3 vLightDir;
out vec3 vUv;
out vec3 vLightPos;
uniform mat4 worldViewProj;
uniform vec3 LightPos;
uniform vec4 LightColor;
uniform vec3 LightDirMul;
void main()
{
gl_Position = (worldViewProj * position);
vUv = uv;
vec3 lightDir = LightPos - position.xyz;
vLightDir = lightDir * LightDirMul;
vLightPos = vLightDir *0.5 + 0.5;
//Calculate rotation for light to get it to tangent space.
vec3 binormal = cross(normal,tangent.xyz)*tangent.w;
mat3 rotation = transpose(mat3(tangent.xyz, binormal, normal));
//Transform the lightdir
vLightDir = (rotation * vLightDir);
vLightColor = vec4(1.0);
}

View File

@@ -0,0 +1,14 @@
//Fallback01_Diffuse_Light_p2.fragment
in vec4 vLightColor;
in vec3 vUv;
in vec3 vLightPos;
in vec3 vLightDir;
OUTPUT
uniform sampler2D tex0; //diffuseMap
void main() {
outColor = texture(tex0, vUv.xy) * vLightColor;
}

View File

@@ -0,0 +1,32 @@
// Copyright 2006-2010 (C) - Frictional Games
//
// This file is part of HPL1 Engine
//
// For conditions of distribution and use, see copyright notice in LICENSE-shaders
//
///////////////////////////////////////////////////////
/// DIFFUSE LIGHTING VERTEX PROGRAM //////////////////
///////////////////////////////////////////////////////
vec4 position = gl_Vertex;
vec3 normal = gl_Normal;
vec3 uv = gl_MultiTexCoord0.xyz;
vec4 tangent = gl_MultiTexCoord1;
out vec4 vLightColor;
out vec3 vUv;
uniform mat4 worldViewProj;
uniform vec3 LightPos;
uniform vec4 LightColor;
uniform vec3 LightDirMul;
void main()
{
gl_Position = (worldViewProj * position);
vUv = uv;
vLightColor = clamp(LightColor, vec4(0.0), vec4(1.0));
}

View File

@@ -0,0 +1,12 @@
//Fallback02_Diffuse_Light_Spot_p2.fragment
in vec4 vLightColor;
in float vRejectUv;
OUTPUT
uniform sampler1D tex0; //spotNegRejectMap
void main() {
outColor = texture1D(tex0, vRejectUv).r * vLightColor;
}

View File

@@ -0,0 +1,17 @@
//Fallback02_Diffuse_Light_Spot_p3.fragment
in vec4 vLightColor;
in vec3 vUv;
in vec4 vSpotlightUv;
OUTPUT
uniform sampler2D tex0; //diffuse
uniform sampler2D tex1; //spotlight
void main() {
vec4 diffuse = texture(tex0, vUv.xy);
vec4 spot = texture(tex1, vSpotlightUv.xy / vSpotlightUv.w);
outColor = diffuse * spot * vLightColor;
}

View File

@@ -0,0 +1,35 @@
// Copyright 2006-2010 (C) - Frictional Games
//
// This file is part of HPL1 Engine
//
// For conditions of distribution and use, see copyright notice in LICENSE-shaders
//
///////////////////////////////////////////////////////
/// DIFFUSE LIGHTING VERTEX PROGRAM //////////////////
///////////////////////////////////////////////////////
vec4 position = gl_Vertex;
vec3 normal = gl_Normal;
vec3 uv = gl_MultiTexCoord0.xyz;
vec4 tangent = gl_MultiTexCoord1;
out vec4 vLightColor;
out float vRejectUv;
uniform mat4 worldViewProj;
uniform mat4 spotViewProj;
uniform vec3 LightPos;
uniform vec4 LightColor;
uniform vec3 LightDirMul;
void main()
{
gl_Position = (worldViewProj * position);
//vUv = uv;
vec4 spotlightUv = (spotViewProj * position);
vRejectUv = spotlightUv.z + 0.5;
vLightColor = clamp(LightColor, vec4(0.0), vec4(1.0));
}

View File

@@ -0,0 +1,36 @@
// Copyright 2006-2010 (C) - Frictional Games
//
// This file is part of HPL1 Engine
//
// For conditions of distribution and use, see copyright notice in LICENSE-shaders
//
///////////////////////////////////////////////////////
/// DIFFUSE LIGHTING VERTEX PROGRAM //////////////////
///////////////////////////////////////////////////////
vec4 position = gl_Vertex;
vec3 normal = gl_Normal;
vec3 uv = gl_MultiTexCoord0.xyz;
vec4 tangent = gl_MultiTexCoord1;
out vec4 vLightColor;
out vec3 vUv;
out vec4 vSpotlightUv;
uniform mat4 worldViewProj;
uniform mat4 spotViewProj;
uniform vec3 LightPos;
uniform vec4 LightColor;
uniform vec3 LightDirMul;
void main()
{
gl_Position = (worldViewProj * position);
vUv = uv;
vSpotlightUv = (spotViewProj * position);
vLightColor = clamp(LightColor, vec4(0.0), vec4(1.0));
}

View File

@@ -0,0 +1,16 @@
//Fallback02_Diffuse_Light_p1.fragment
in vec3 vLightDir;
in vec3 vLightPos;
OUTPUT
uniform samplerCube tex0;
uniform sampler3D tex1;
void main() {
vec4 normalizedVec = textureCube(tex0, vLightDir);
vec4 attenuation = texture3D(tex1, vLightPos);
outColor = vec4(2.0*(normalizedVec.b - 0.5));
outColor.a *= attenuation.g;
}

View File

@@ -0,0 +1,41 @@
// Copyright 2006-2010 (C) - Frictional Games
//
// This file is part of HPL1 Engine
//
// For conditions of distribution and use, see copyright notice in LICENSE-shaders
//
///////////////////////////////////////////////////////
/// DIFFUSE LIGHTING VERTEX PROGRAM //////////////////
///////////////////////////////////////////////////////
vec4 position = gl_Vertex;
vec3 normal = gl_Normal;
vec4 tangent = gl_MultiTexCoord1;
out vec4 vColor;
out vec3 vLightDir;
out vec3 vLightPos;
uniform mat4 worldViewProj;
uniform vec3 LightPos;
uniform vec4 LightColor;
uniform vec3 LightDirMul;
void main()
{
gl_Position = (worldViewProj * position);
vec3 lightDir = LightPos - position.xyz;
vLightDir = lightDir * LightDirMul;
vLightPos = vLightDir *0.5 + 0.5;
//Calculate rotation for light to get it to tangent space.
vec3 binormal = cross(normal,tangent.xyz)*tangent.w;
mat3 rotation = transpose(mat3(tangent.xyz, binormal, normal));
//Transform the lightdir
vLightDir = (rotation * vLightDir);
vColor = vec4(1.0);
}

View File

@@ -0,0 +1,33 @@
// Copyright 2006-2010 (C) - Frictional Games
//
// This file is part of HPL1 Engine
//
// For conditions of distribution and use, see copyright notice in LICENSE-shaders
//
///////////////////////////////////////////////////////
/// DIFFUSE LIGHTING VERTEX PROGRAM //////////////////
///////////////////////////////////////////////////////
vec4 position = gl_Vertex;
vec3 normal = gl_Normal;
vec3 uv = gl_MultiTexCoord0.xyz;
vec4 tangent = gl_MultiTexCoord1;
out vec4 vLightColor;
out vec3 vUv;
uniform mat4 worldViewProj;
uniform vec3 LightPos;
uniform vec4 LightColor;
uniform vec3 LightDirMul;
void main()
{
gl_Position = (worldViewProj * position);
vUv = uv;
vLightColor = clamp(LightColor, vec4(0.0), vec4(1.0));
}

View File

@@ -0,0 +1,22 @@
// Copyright 2006-2010 (C) - Frictional Games
//
// This file is part of HPL1 Engine
//
// For conditions of distribution and use, see copyright notice in LICENSE-shaders
//
///////////////////////////////////////////////////////
/// SOLID FOG FRAGMENT PROGRAM ////////////
///////////////////////////////////////////////////////
in vec4 vColor;
in float vUv;
OUTPUT
uniform sampler1D tex0; //diffuseMap;
void main()
{
outColor = texture1D(tex0, vUv).rrrg * vColor;
}

View File

@@ -0,0 +1,31 @@
// Copyright 2006-2010 (C) - Frictional Games
//
// This file is part of HPL1 Engine
//
// For conditions of distribution and use, see copyright notice in LICENSE-shaders
//
///////////////////////////////////////////////////////
/// SIMPLE DIFFUSE COLOR VERTEX PROGRAM ////////////
///////////////////////////////////////////////////////
vec4 position = gl_Vertex;
vec3 color = gl_Color.xyz;
out vec4 vColor;
out float vUv;
uniform mat4 worldViewProj;
uniform vec3 fogColor;
uniform float fogStart;
uniform float fogEnd;
void main()
{
gl_Position = (worldViewProj * position);
vUv = (fogEnd - gl_Position.z)/(fogEnd - fogStart);
vColor.xyz = clamp(fogColor, vec3(0.0), vec3(1.0));
vColor.w = 1;
}

View File

@@ -0,0 +1,31 @@
// Copyright 2006-2010 (C) - Frictional Games
//
// This file is part of HPL1 Engine
//
// For conditions of distribution and use, see copyright notice in LICENSE-shaders
//
///////////////////////////////////////////////////////
/// SIMPLE DIFFUSE COLOR VERTEX PROGRAM ////////////
///////////////////////////////////////////////////////
vec4 position = gl_Vertex;
vec4 color = gl_Color;
vec3 uv = gl_MultiTexCoord0.xyz;
out vec4 vColor;
out vec2 vUv;
out float vFogUv;
uniform mat4 worldViewProj;
uniform float fogStart;
uniform float fogEnd;
void main()
{
gl_Position = (worldViewProj * position);
vUv = uv.xy;
vFogUv = (fogEnd - gl_Position.z)/(fogEnd - fogStart);
vColor = clamp(color, vec4(0.0), vec4(1.0));
}

View File

@@ -0,0 +1,24 @@
// Copyright 2006-2010 (C) - Frictional Games
//
// This file is part of HPL1 Engine
//
// For conditions of distribution and use, see copyright notice in LICENSE-shaders
//
///////////////////////////////////////////////////////
/// SIMPLE DIFFUSE COLOR VERTEX PROGRAM ////////////
///////////////////////////////////////////////////////
in vec4 vColor;
in vec2 vUv;
in float vFogUv;
OUTPUT
uniform sampler2D tex0; //diffuseMap
uniform sampler1D tex1; //fogMap
void main()
{
outColor = texture(tex0, vUv) * texture1D(tex1, vFogUv).r * vColor;
}

View File

@@ -0,0 +1,27 @@
// Copyright 2006-2010 (C) - Frictional Games
//
// This file is part of HPL1 Engine
//
// For conditions of distribution and use, see copyright notice in LICENSE-shaders
//
///////////////////////////////////////////////////////
/// SIMPLE DIFFUSE COLOR VERTEX PROGRAM ////////////
///////////////////////////////////////////////////////
in vec4 vColor;
in vec2 vUv;
in float vFogUv;
OUTPUT
uniform sampler2D tex0; //diffuseMap
uniform sampler1D tex1; //fogMap
void main()
{
vec4 diffuse = texture(tex0, vUv);
float alpha = texture1D(tex1, vFogUv).g;
outColor.xyz = diffuse.xyz * alpha + vec3(1.0 - alpha);
outColor.w = diffuse.w;
}

View File

@@ -0,0 +1,27 @@
// Copyright 2006-2010 (C) - Frictional Games
//
// This file is part of HPL1 Engine
//
// For conditions of distribution and use, see copyright notice in LICENSE-shaders
//
///////////////////////////////////////////////////////
/// SIMPLE DIFFUSE COLOR VERTEX PROGRAM ////////////
///////////////////////////////////////////////////////
in vec4 vColor;
in vec2 vUv;
in float vFogUv;
OUTPUT
uniform sampler2D tex0; //diffuseMap
uniform sampler1D tex1; //fogMap
void main()
{
vec4 diffuse = texture(tex0, vUv);
float alpha = texture1D(tex1, vFogUv).g;
outColor.xyz = diffuse.xyz * alpha + vec3(0.5,0.5,0.5)*(1 - alpha);
outColor.w = diffuse.w;
}

View File

@@ -0,0 +1,27 @@
// Copyright 2006-2010 (C) - Frictional Games
//
// This file is part of HPL1 Engine
//
// For conditions of distribution and use, see copyright notice in LICENSE-shaders
//
///////////////////////////////////////////////////////
/// BLOOOM FRAGMENT PROGRAM /////////////////
///////////////////////////////////////////////////////
in vec2 vUv0;
in vec2 vUv1;
OUTPUT
uniform sampler2D tex0; //blurTex
uniform sampler2DRect tex1; //screenTex
void main()
{
vec4 blurCol = texture(tex0, vUv0);
vec4 screenCol = texture2DRect(tex1, vUv1);
blurCol *= blurCol;
outColor.xyz = blurCol.xyz * dot(blurCol.xyz,vec3(0.3, 0.58, 0.12)) + screenCol.xyz;
}

View File

@@ -0,0 +1,28 @@
// Copyright 2006-2010 (C) - Frictional Games
//
// This file is part of HPL1 Engine
//
// For conditions of distribution and use, see copyright notice in LICENSE-shaders
//
///////////////////////////////////////////////////////
/// BLOOM VERTEX PROGRAM ////////////
///////////////////////////////////////////////////////
vec4 position = gl_Vertex;
vec3 color = gl_Color.xyz;
vec2 uv0 = gl_MultiTexCoord0.xy;
vec2 uv1 = gl_MultiTexCoord1.xy;
out vec2 vUv0;
out vec2 vUv1;
uniform mat4 worldViewProj;
void main()
{
gl_Position = (worldViewProj * position);
vUv0 = uv0;
vUv1 = uv1;
}

View File

@@ -0,0 +1,33 @@
// Copyright 2006-2010 (C) - Frictional Games
//
// This file is part of HPL1 Engine
//
// For conditions of distribution and use, see copyright notice in LICENSE-shaders
//
///////////////////////////////////////////////////////
/// SIMPLE DIFFUSE COLOR VERTEX PROGRAM ////////////
///////////////////////////////////////////////////////
vec4 position = gl_Vertex;
vec3 color = gl_Color.xyz;
vec2 uv = gl_MultiTexCoord0.xy;
out vec2 vUv0;
out vec2 vUv1;
out vec2 vUv2;
out vec2 vUv3;
uniform mat4 worldViewProj;
uniform float yOffset;
uniform float xOffset;
uniform float amount;
void main()
{
gl_Position = (worldViewProj * position);
vUv0 = uv + vec2(xOffset, yOffset) * amount;
vUv1 = uv + vec2(xOffset, yOffset) * 2.0 * amount;
vUv2 = uv - vec2(xOffset, yOffset) * amount;
vUv3 = uv - vec2(xOffset, yOffset) * 2.0 * amount;
}

View File

@@ -0,0 +1,36 @@
// Copyright 2006-2010 (C) - Frictional Games
//
// This file is part of HPL1 Engine
//
// For conditions of distribution and use, see copyright notice in LICENSE-shaders
//
///////////////////////////////////////////////////////
/// DIFFUSE LIGHTING FRAGMENT PROGRAM /////////////////
///////////////////////////////////////////////////////
in vec2 vUv0;
in vec2 vUv1;
in vec2 vUv2;
in vec2 vUv3;
OUTPUT
uniform sampler2D tex0;
void main()
{
//Samples
vec4 col5 = texture(tex0, (vUv0 + vUv2)/2.0 ) * 0.35;
vec4 col1 = texture(tex0, vUv0) * 0.15;
vec4 col3 = texture(tex0, vUv2) * 0.15;
vec4 col6 = texture(tex0, (vUv2 + vUv3)/2.0 ) * 0.1;
vec4 col7 = texture(tex0, (vUv0 + vUv1)/2.0 ) * 0.1;
vec4 col2 = texture(tex0, vUv1) * 0.075;
vec4 col4 = texture(tex0, vUv3) * 0.075;
outColor = col1 + col2 + col3 + col4 + col5 + col6 + col7;
}

View File

@@ -0,0 +1,37 @@
// Copyright 2006-2010 (C) - Frictional Games
//
// This file is part of HPL1 Engine
//
// For conditions of distribution and use, see copyright notice in LICENSE-shaders
//
///////////////////////////////////////////////////////
/// DIFFUSE LIGHTING FRAGMENT PROGRAM /////////////////
///////////////////////////////////////////////////////
in vec2 vUv0;
in vec2 vUv1;
in vec2 vUv2;
in vec2 vUv3;
OUTPUT
uniform sampler2DRect tex0;
void main()
{
//Samples
vec4 col5 = texture2DRect(tex0, (vUv0 + vUv2)/2.0 ) * 0.35;
vec4 col1 = texture2DRect(tex0, vUv0) * 0.15;
vec4 col3 = texture2DRect(tex0, vUv2) * 0.15;
vec4 col6 = texture2DRect(tex0, (vUv2 + vUv3)/2.0 ) * 0.1;
vec4 col7 = texture2DRect(tex0, (vUv0 + vUv1)/2.0 ) * 0.1;
vec4 col2 = texture2DRect(tex0, vUv1) * 0.075;
vec4 col4 = texture2DRect(tex0, vUv3) * 0.075;
outColor = col1 + col2 + col3 + col4 + col5 + col6 + col7;
}

View File

@@ -0,0 +1,36 @@
// Copyright 2006-2010 (C) - Frictional Games
//
// This file is part of HPL1 Engine
//
// For conditions of distribution and use, see copyright notice in LICENSE-shaders
//
///////////////////////////////////////////////////////
/// DEPTH OF FIELD FRAGMENT PROGRAM /////////////////
///////////////////////////////////////////////////////
in float vDepth;
OUTPUT
uniform sampler2DRect tex0; //screenMap
uniform sampler2D tex1; //blurMap
uniform vec3 planes;
uniform float maxBlur;
uniform vec2 screenSize;
void main()
{
float blur = 0.0;
if(vDepth < planes.y) {
blur = (planes.y - vDepth) / (planes.y - planes.x);
}
else {
blur = (vDepth - planes.y) / (planes.z - planes.y);
}
blur = clamp(blur, 0.0, maxBlur);
outColor = texture2DRect(tex0,gl_FragCoord.xy) * (1.0-blur) + texture(tex1,gl_FragCoord.xy/screenSize) *blur;
}

View File

@@ -0,0 +1,25 @@
// Copyright 2006-2010 (C) - Frictional Games
//
// This file is part of HPL1 Engine
//
// For conditions of distribution and use, see copyright notice in LICENSE-shaders
//
///////////////////////////////////////////////////////
///DEPTH OF FIELD VERTEX PROGRAM ////////////
///////////////////////////////////////////////////////
vec4 position = gl_Vertex;
out float vDepth;
uniform mat4 worldViewProj;
void main()
{
//Get the positions in window space.
gl_Position = (worldViewProj * position);
vDepth = gl_Position.z;
}

View File

@@ -0,0 +1,32 @@
// Copyright 2006-2010 (C) - Frictional Games
//
// This file is part of HPL1 Engine
//
// For conditions of distribution and use, see copyright notice in LICENSE-shaders
//
///////////////////////////////////////////////////////
/// DIFFUSE LIGHTING FRAGMENT PROGRAM /////////////////
///////////////////////////////////////////////////////
in vec2 vUv0;
in vec2 vUv1;
in vec2 vUv2;
in vec2 vUv3;
OUTPUT
uniform sampler2D tex0;
uniform sampler2D tex1;
uniform sampler2D tex2;
void main()
{
//Samples
vec4 col1 = texture(tex0, (vUv0 + vUv1)/2) * 0.3;
vec4 col3 = texture(tex1, (vUv2 + vUv3)/2) * 0.3;
vec4 col2 = texture(tex2, (vUv0 + vUv2)/2 ) * 0.4;
outColor = col1 + col2 + col3;
}

View File

@@ -0,0 +1,33 @@
// Copyright 2006-2010 (C) - Frictional Games
//
// This file is part of HPL1 Engine
//
// For conditions of distribution and use, see copyright notice in LICENSE-shaders
//
///////////////////////////////////////////////////////
/// DIFFUSE LIGHTING FRAGMENT PROGRAM /////////////////
///////////////////////////////////////////////////////
in vec4 color;
in vec2 vUv0;
in vec2 vUv1;
in vec2 vUv2;
in vec2 vUv3;
OUTPUT
uniform sampler2DRect tex0;
uniform sampler2DRect tex1;
uniform sampler2DRect tex2;
void main()
{
//Samples
vec4 col1 = texture2DRect(tex0, (vUv0 + vUv1)/2.0) * 0.3;
vec4 col3 = texture2DRect(tex1, (vUv2 + vUv3)/2.0) * 0.3;
vec4 col2 = texture2DRect(tex2, (vUv0 + vUv2)/2.0) * 0.4;
outColor = col1 + col2 + col3;
}

View File

@@ -0,0 +1,42 @@
// Copyright 2006-2010 (C) - Frictional Games
//
// This file is part of HPL1 Engine
//
// For conditions of distribution and use, see copyright notice in LICENSE-shaders
//
///////////////////////////////////////////////////////
// MOTION BLUR FRAGMENT PROGRAM
// Credits to jonathan for optimization
///////////////////////////////////////////////////////
in vec4 vVtxPos;
in vec4 vPrevVtxPos;
OUTPUT
uniform sampler2DRect tex0; //screenTex
uniform vec2 halfScreenSize;
void main()
{
vec2 wpos = gl_FragCoord.xy;
vec2 p1 = vVtxPos.xy / vVtxPos.w;
vec2 p2 = vPrevVtxPos.xy / vPrevVtxPos.w;
vec2 velocity = (p2 - p1) * halfScreenSize;
//Sample into scene texture along motion vector
float samples = min( max( 1.0, ceil( max( abs( velocity.x ), abs( velocity.y ) ) / 2.0 ) ), 16.0 );
float w = 1.0 / samples; // weight
vec2 s = velocity / samples; // step
vec4 a = vec4(0.0);
for(float i=0.0; i<samples; i+=1.0)
{
a += texture2DRect(tex0, wpos) * w;
wpos += s;
}
outColor = a;
}

View File

@@ -0,0 +1,48 @@
// Copyright 2006-2010 (C) - Frictional Games
//
// This file is part of HPL1 Engine
//
// For conditions of distribution and use, see copyright notice in LICENSE-shaders
//
///////////////////////////////////////////////////////
/// SIMPLE DIFFUSE COLOR VERTEX PROGRAM ////////////
///////////////////////////////////////////////////////
vec4 position = gl_Vertex;
vec3 normal = gl_Normal;
vec3 color = gl_Color.xyz;
out vec4 vVtxPos;
out vec4 vPrevVtxPos;
uniform mat4 modelView;
uniform mat4 prevModelView;
uniform mat4 worldViewProj;
uniform mat4 prevWorldViewProj;
uniform float blurScale;
void main()
{
//Get the positions in eye space
vec4 pos = (modelView * position);
vec4 prevPos = (prevModelView * position);
//Transform normal to eye space
vec3 eyeNormal = mat3(modelView) * normal;
// calculate eye space motion vector
vec3 motionVector = pos.xyz - prevPos.xyz;
//Get the positions in window space.
pos = (worldViewProj * position);
prevPos = (prevWorldViewProj * position);
//Interpolate the previous according to blurscale
prevPos = mix(pos, prevPos, blurScale);
gl_Position = pos;
vVtxPos = pos;
vPrevVtxPos = prevPos;
}

View File

@@ -0,0 +1,42 @@
// Copyright 2006-2010 (C) - Frictional Games
//
// This file is part of HPL1 Engine
//
// For conditions of distribution and use, see copyright notice in LICENSE-shaders
//
///////////////////////////////////////////////////////
// MOTION BLUR FRAGMENT PROGRAM WITH STATIC LOOP
// Credits to jonathan for optimization
///////////////////////////////////////////////////////
in vec4 vVtxPos;
in vec4 vPrevVtxPos;
OUTPUT
uniform sampler2DRect tex0; //screenTex
uniform vec2 halfScreenSize;
void main()
{
vec2 wpos = gl_FragCoord.xy;
vec2 p1 = vVtxPos.xy / vVtxPos.w;
vec2 p2 = vPrevVtxPos.xy / vPrevVtxPos.w;
vec2 velocity = (p2 - p1) * halfScreenSize;
//Sample into scene texture along motion vector
const float samples = 16.0;
const fixed w = 1.0 / samples; // weight
const vec2 s = velocity / samples; // step
vec4 a = vec4(0.0);
for(float i=0.0; i<samples; i+=1.0)
{
a += texture2DRect(tex0, wpos) * w;
wpos += s;
}
outColor = a;
}

View File

@@ -0,0 +1,23 @@
// Copyright 2006-2010 (C) - Frictional Games
//
// This file is part of HPL1 Engine
//
// For conditions of distribution and use, see copyright notice in LICENSE-shaders
//
///////////////////////////////////////////////////////
/// SPECULAR BUMPMAPPING 2D FRAGMENT PROGRAM //////////
///////////////////////////////////////////////////////
in vec3 vUv; //in object space
OUTPUT
uniform sampler2D tex0; //ScreenBuffer
void main()
{
vec4 Col = texture(tex0, vUv);
outColor = Col;
}

View File

@@ -0,0 +1,24 @@
// Copyright 2006-2010 (C) - Frictional Games
//
// This file is part of HPL1 Engine
//
// For conditions of distribution and use, see copyright notice in LICENSE-shaders
//
///////////////////////////////////////////////////////
/// SPECULAR BUMPMAPPING 2D VERTEX PROGRAM ////////////
///////////////////////////////////////////////////////
vec4 position = gl_Vertex;
vec3 uv = gl_MultiTexCoord0.xyz;
out vec3 vUv;
uniform mat4 worldViewProj;
void main()
{
gl_Position = (worldViewProj * position);
vUv = uv;
}

View File

@@ -0,0 +1,17 @@
// Copyright 2006-2010 (C) - Frictional Games
//
// This file is part of HPL1 Engine
//
// For conditions of distribution and use, see copyright notice in LICENSE-shaders
//
///////////////////////////////////////////////////////
/// SIMPLE DIFFUSE COLOR VERTEX PROGRAM ////////////
///////////////////////////////////////////////////////
OUTPUT
void main()
{
outColor = vec4(1.0);
}

View File

@@ -0,0 +1,20 @@
// Copyright 2006-2010 (C) - Frictional Games
//
// This file is part of HPL1 Engine
//
// For conditions of distribution and use, see copyright notice in LICENSE-shaders
//
///////////////////////////////////////////////////////
/// SIMPLE DIFFUSE COLOR VERTEX PROGRAM ////////////
///////////////////////////////////////////////////////
vec4 position = gl_Vertex;
uniform mat4 worldViewProj;
uniform vec3 lightPosition;
void main()
{
gl_Position = (worldViewProj * vec4((position.xyz - lightPosition*(1.0-position.w)), position.w));
}

View File

@@ -0,0 +1,13 @@
// Water_Diffuse.fragment
in vec3 vColor;
in vec2 vUv;
OUTPUT
uniform sampler2D tex0; //diffuse
void main() {
outColor = texture(tex0, vUv);
outColor.xyz *= vColor;
}

View File

@@ -0,0 +1,35 @@
// Copyright 2006-2010 (C) - Frictional Games
//
// This file is part of HPL1 Engine
//
// For conditions of distribution and use, see copyright notice in LICENSE-shaders
//
///////////////////////////////////////////////////////
/// WATER FOG VERTEX PROGRAM ////////////
///////////////////////////////////////////////////////
vec4 position = gl_Vertex;
vec3 color = gl_Color.xyz;
vec2 uv = gl_MultiTexCoord0.xy;
out vec3 vColor;
out vec2 vUv;
uniform mat4 worldViewProj;
uniform float timeCount;
void main()
{
float amp = 0.04;
float freq = 15.0;
float speed = 3.0;
gl_Position = (worldViewProj * position);
gl_Position.y += sin(timeCount*speed + (position.x)*freq)*amp;
gl_Position.y += sin(timeCount*speed + (position.z)*freq)*amp;
vColor = clamp(color, vec3(0.0), vec3(1.0));
vUv = uv;
}

View File

@@ -0,0 +1,14 @@
// Water_Diffuse.fragment
in vec4 vColor;
in vec2 vUv;
in float vFogUv;
OUTPUT
uniform sampler2D tex0; // diffuse
uniform sampler1D tex1; // fog
void main() {
outColor = texture(tex0, vUv) * texture1D(tex1, vFogUv).rrrg * vColor;
}

View File

@@ -0,0 +1,39 @@
// Copyright 2006-2010 (C) - Frictional Games
//
// This file is part of HPL1 Engine
//
// For conditions of distribution and use, see copyright notice in LICENSE-shaders
//
///////////////////////////////////////////////////////
/// WATER FOG VERTEX PROGRAM ////////////
///////////////////////////////////////////////////////
vec4 position = gl_Vertex;
vec4 color = gl_Color;
vec2 uv = gl_MultiTexCoord0.xy;
out vec4 vColor;
out vec2 vUv;
out float vFogUv;
uniform mat4 worldViewProj;
uniform float fogStart;
uniform float fogEnd;
uniform float timeCount;
void main()
{
float amp = 0.04;
float freq = 15.0;
float speed = 3.0;
gl_Position = (worldViewProj * position);
gl_Position.y += sin(timeCount*speed + (position.x)*freq)*amp;
gl_Position.y += sin(timeCount*speed + (position.z)*freq)*amp;
vUv = uv;
vFogUv = (fogEnd - gl_Position.z)/(fogEnd - fogStart);
vColor = clamp(color, vec4(0.0), vec4(1.0));
}

View File

@@ -0,0 +1,14 @@
// hpl1_gamma_correction.fragment
in vec2 vUv;
uniform sampler2DRect tex0;
uniform float gamma;
OUTPUT
void main()
{
vec4 color = texture2DRect(tex0, vUv);
outColor = vec4(pow(color.r, 1/gamma), pow(color.g, 1/gamma), pow(color.b, 1/gamma), color.a);
}

View File

@@ -0,0 +1,11 @@
// hpl1_gamma_correction.fragment
vec4 position = gl_Vertex;
vec2 uv = gl_MultiTexCoord0.xy;
out vec2 vUv;
void main() {
gl_Position = position;
vUv = uv;
}

View File

@@ -0,0 +1,28 @@
// Copyright 2006-2010 (C) - Frictional Games
//
// This file is part of HPL1 Engine
//
// For conditions of distribution and use, see copyright notice in LICENSE-shaders
//
///////////////////////////////////////////////////////
/// REFRACTION FRAGMENT PROGRAM /////////////////
///////////////////////////////////////////////////////
in vec2 vUv; //in object space
in vec4 vColor;
OUTPUT
uniform sampler2DRect tex0; //screenMap
uniform sampler2D tex1; //refractMap
uniform vec2 screenSize;
uniform float scale;
void main()
{
vec3 offset = vec3(((texture(tex1, vUv)*2.0) - vec4(1.0)) * vColor.w);
outColor = texture2DRect(tex0, gl_FragCoord.xy - (offset.xy*scale) / gl_FragCoord.z);
}

View File

@@ -0,0 +1,28 @@
// Copyright 2006-2010 (C) - Frictional Games
//
// This file is part of HPL1 Engine
//
// For conditions of distribution and use, see copyright notice in LICENSE-shaders
//
///////////////////////////////////////////////////////
/// REFRACTION VERTEX PROGRAM ////////////
///////////////////////////////////////////////////////
vec4 position = gl_Vertex;
vec4 color = gl_Color;
vec2 uv = gl_MultiTexCoord0.xy;
out vec4 vColor;
out vec2 vUv;
uniform mat4 worldViewProj;
void main()
{
gl_Position = (worldViewProj * position);
vColor = clamp(color, vec4(0.0), vec4(1.0));
vUv = uv;
}

View File

@@ -0,0 +1,34 @@
// Copyright 2006-2010 (C) - Frictional Games
//
// This file is part of HPL1 Engine
//
// For conditions of distribution and use, see copyright notice in LICENSE-shaders
//
///////////////////////////////////////////////////////
/// REFRACTION SPECIAL FRAGMENT PROGRAM /////////////////
///////////////////////////////////////////////////////
in vec2 vUv; //in object space
in vec4 vColor;
OUTPUT
uniform sampler2DRect tex0; //screenMap
uniform sampler2D tex1; //refractMap
uniform sampler2D tex2; //alphaMap
uniform vec2 screenSize;
uniform float t;
uniform float scale;
void main()
{
float alpha = texture(tex2, vUv).x;
vec2 uv2 = (gl_FragCoord.xy / screenSize);
uv2.x += sin(t + uv2.y*10) * 0.001 * scale;
uv2.y += sin(t + uv2.x*10) * 0.001 * scale;
vec3 offset = vec3(((texture(tex1, uv2)*2.0) - vec4(1.0)) * alpha * vColor.w);
outColor.xyz = (texture2DRect(tex0,gl_FragCoord.xy - offset.xy*scale)).xyz;
}

View File

@@ -0,0 +1,58 @@
// Copyright 2006-2010 (C) - Frictional Games
//
// This file is part of HPL1 Engine
//
// For conditions of distribution and use, see copyright notice in LICENSE-shaders
//
///////////////////////////////////////////////////////
/// REFRACTION FRAGMENT PROGRAM /////////////////
///////////////////////////////////////////////////////
in vec2 vUv; //in object space
in vec3 vNormal;
in vec3 vEyePos;
in vec4 vColor;
OUTPUT
uniform sampler2DRect tex0; //screenMap
uniform sampler2D tex1; //refractMap
uniform sampler2D tex2; //diffuseMap
uniform vec2 screenSize;
uniform float scale;
uniform float t;
void main()
{
//t *= 1;
vec2 uv_offset1 = vUv;
uv_offset1.x += sin(t*0.8 + vUv.y*10.0)*0.04;
uv_offset1.y += sin(t*0.8 + uv_offset1.x*10.0)*0.04;
vec3 offset1 = ((texture(tex1, uv_offset1)*2.0) - vec4(1.0)).xyz;
vec2 uv_offset2 = vUv;
uv_offset2.x += sin(t*-2.6 + vUv.y*12.0)*0.03;
uv_offset2.y += sin(t*-2.6 + uv_offset2.x*12.0)*0.03;
vec3 offset2 = ((texture(tex1, uv_offset2)*2.0) - vec4(1.0)).xyz;
offset2.xy = -offset2.xy;
vec3 offset = normalize(offset1*0.7 + offset2*0.3);
//float fresnel = saturate(dot(normalize(vEyePos), normalize(vNormal)));
//fresnel = (fresnel + 0.2)*0.8;
vec3 waterColor = texture(tex2, uv_offset1).xyz;
vec4 screenColor = texture2DRect(tex0, gl_FragCoord.xy + offset.xy * -scale);
if(screenColor.w < 0.5) screenColor = texture2DRect(tex0, gl_FragCoord.xy);
outColor.xyz = screenColor.xyz * waterColor;
//outColor.y = uv.y+1 + uv_offset1.y;
outColor.xyz *= clamp(dot(vec3(1.0/3.0, 1.0/3.0, 1.0/3.0), offset), 0.0, 1.0)*0.5 + 0.5;
outColor.xyz += pow(clamp(dot(vec3(1.0/3.0, 1.0/3.0, 1.0/3.0), offset), 0.0, 1.0), 8.0)*5.0;
}

View File

@@ -0,0 +1,36 @@
// Copyright 2006-2010 (C) - Frictional Games
//
// This file is part of HPL1 Engine
//
// For conditions of distribution and use, see copyright notice in LICENSE-shaders
//
///////////////////////////////////////////////////////
/// REFRACTION VERTEX PROGRAM ////////////
///////////////////////////////////////////////////////
vec4 position = gl_Vertex;
vec4 color = gl_Color;
vec2 uv = gl_MultiTexCoord0.xy;
vec3 normal = gl_Normal;
out vec4 vColor;
out vec2 vUv;
out vec3 vNormal;
out vec3 vEyePos;
uniform vec3 EyePos;
uniform mat4 worldViewProj;
void main()
{
gl_Position = (worldViewProj * position);
vColor = clamp(color, vec4(0.0), vec4(1.0));
vUv = uv;
vNormal = normal;
vEyePos = normalize(EyePos - position.xyz);
}