Merging r5975 through r6036 from trunk to ogl-es branch.
GLES drivers adapted, but only did make compile-tests. git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/branches/ogl-es@6038 dfc29bdd-3216-0410-991c-e03cc46cb475
BIN
media/2ddemo.png
Normal file
After Width: | Height: | Size: 43 KiB |
BIN
media/Faerie5.BMP
Normal file
After Width: | Height: | Size: 42 KiB |
BIN
media/IrrlichtTheme.ogg
Normal file
BIN
media/Particle.tga
Normal file
After Width: | Height: | Size: 12 KiB |
70
media/Shaders/COGLES2DetailMap.fsh
Normal file
@ -0,0 +1,70 @@
|
||||
precision mediump float;
|
||||
|
||||
/* Uniforms */
|
||||
|
||||
uniform int uTextureUsage0;
|
||||
uniform int uTextureUsage1;
|
||||
uniform sampler2D uTextureUnit0;
|
||||
uniform sampler2D uTextureUnit1;
|
||||
uniform int uFogEnable;
|
||||
uniform int uFogType;
|
||||
uniform vec4 uFogColor;
|
||||
uniform float uFogStart;
|
||||
uniform float uFogEnd;
|
||||
uniform float uFogDensity;
|
||||
|
||||
/* Varyings */
|
||||
|
||||
varying vec2 vTextureCoord0;
|
||||
varying vec2 vTextureCoord1;
|
||||
varying vec4 vVertexColor;
|
||||
varying vec4 vSpecularColor;
|
||||
varying float vFogCoord;
|
||||
|
||||
float computeFog()
|
||||
{
|
||||
const float LOG2 = 1.442695;
|
||||
float FogFactor = 0.0;
|
||||
|
||||
if (uFogType == 0) // Exp
|
||||
{
|
||||
FogFactor = exp2(-uFogDensity * vFogCoord * LOG2);
|
||||
}
|
||||
else if (uFogType == 1) // Linear
|
||||
{
|
||||
float Scale = 1.0 / (uFogEnd - uFogStart);
|
||||
FogFactor = (uFogEnd - vFogCoord) * Scale;
|
||||
}
|
||||
else if (uFogType == 2) // Exp2
|
||||
{
|
||||
FogFactor = exp2(-uFogDensity * uFogDensity * vFogCoord * vFogCoord * LOG2);
|
||||
}
|
||||
|
||||
FogFactor = clamp(FogFactor, 0.0, 1.0);
|
||||
|
||||
return FogFactor;
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 Color0 = vec4(1.0, 1.0, 1.0, 1.0);
|
||||
vec4 Color1 = vec4(1.0, 1.0, 1.0, 1.0);
|
||||
|
||||
if (bool(uTextureUsage0))
|
||||
Color0 = texture2D(uTextureUnit0, vTextureCoord0);
|
||||
|
||||
if (bool(uTextureUsage1))
|
||||
Color1 = texture2D(uTextureUnit1, vTextureCoord1);
|
||||
|
||||
vec4 FinalColor = vec4(Color0 + (Color1 - 0.5)) * vVertexColor + vSpecularColor;
|
||||
|
||||
if (bool(uFogEnable))
|
||||
{
|
||||
float FogFactor = computeFog();
|
||||
vec4 FogColor = uFogColor;
|
||||
FogColor.a = 1.0;
|
||||
FinalColor = mix(FogColor, FinalColor, FogFactor);
|
||||
}
|
||||
|
||||
gl_FragColor = FinalColor;
|
||||
}
|
70
media/Shaders/COGLES2LightmapAdd.fsh
Normal file
@ -0,0 +1,70 @@
|
||||
precision mediump float;
|
||||
|
||||
/* Uniforms */
|
||||
|
||||
uniform int uTextureUsage0;
|
||||
uniform int uTextureUsage1;
|
||||
uniform sampler2D uTextureUnit0;
|
||||
uniform sampler2D uTextureUnit1;
|
||||
uniform int uFogEnable;
|
||||
uniform int uFogType;
|
||||
uniform vec4 uFogColor;
|
||||
uniform float uFogStart;
|
||||
uniform float uFogEnd;
|
||||
uniform float uFogDensity;
|
||||
|
||||
/* Varyings */
|
||||
|
||||
varying vec2 vTextureCoord0;
|
||||
varying vec2 vTextureCoord1;
|
||||
varying vec4 vVertexColor;
|
||||
varying vec4 vSpecularColor;
|
||||
varying float vFogCoord;
|
||||
|
||||
float computeFog()
|
||||
{
|
||||
const float LOG2 = 1.442695;
|
||||
float FogFactor = 0.0;
|
||||
|
||||
if (uFogType == 0) // Exp
|
||||
{
|
||||
FogFactor = exp2(-uFogDensity * vFogCoord * LOG2);
|
||||
}
|
||||
else if (uFogType == 1) // Linear
|
||||
{
|
||||
float Scale = 1.0 / (uFogEnd - uFogStart);
|
||||
FogFactor = (uFogEnd - vFogCoord) * Scale;
|
||||
}
|
||||
else if (uFogType == 2) // Exp2
|
||||
{
|
||||
FogFactor = exp2(-uFogDensity * uFogDensity * vFogCoord * vFogCoord * LOG2);
|
||||
}
|
||||
|
||||
FogFactor = clamp(FogFactor, 0.0, 1.0);
|
||||
|
||||
return FogFactor;
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 Color0 = vec4(1.0, 1.0, 1.0, 1.0);
|
||||
vec4 Color1 = vec4(1.0, 1.0, 1.0, 1.0);
|
||||
|
||||
if (bool(uTextureUsage0))
|
||||
Color0 = texture2D(uTextureUnit0, vTextureCoord0);
|
||||
|
||||
if (bool(uTextureUsage1))
|
||||
Color1 = texture2D(uTextureUnit1, vTextureCoord1);
|
||||
|
||||
vec4 FinalColor = (Color0 + Color1) * vVertexColor + vSpecularColor;
|
||||
|
||||
if (bool(uFogEnable))
|
||||
{
|
||||
float FogFactor = computeFog();
|
||||
vec4 FogColor = uFogColor;
|
||||
FogColor.a = 1.0;
|
||||
FinalColor = mix(FogColor, FinalColor, FogFactor);
|
||||
}
|
||||
|
||||
gl_FragColor = FinalColor;
|
||||
}
|
72
media/Shaders/COGLES2LightmapModulate.fsh
Normal file
@ -0,0 +1,72 @@
|
||||
precision mediump float;
|
||||
|
||||
/* Uniforms */
|
||||
|
||||
uniform float uModulate;
|
||||
uniform int uTextureUsage0;
|
||||
uniform int uTextureUsage1;
|
||||
uniform sampler2D uTextureUnit0;
|
||||
uniform sampler2D uTextureUnit1;
|
||||
uniform int uFogEnable;
|
||||
uniform int uFogType;
|
||||
uniform vec4 uFogColor;
|
||||
uniform float uFogStart;
|
||||
uniform float uFogEnd;
|
||||
uniform float uFogDensity;
|
||||
|
||||
/* Varyings */
|
||||
|
||||
varying vec2 vTextureCoord0;
|
||||
varying vec2 vTextureCoord1;
|
||||
varying vec4 vVertexColor;
|
||||
varying vec4 vSpecularColor;
|
||||
varying float vFogCoord;
|
||||
|
||||
float computeFog()
|
||||
{
|
||||
const float LOG2 = 1.442695;
|
||||
float FogFactor = 0.0;
|
||||
|
||||
if (uFogType == 0) // Exp
|
||||
{
|
||||
FogFactor = exp2(-uFogDensity * vFogCoord * LOG2);
|
||||
}
|
||||
else if (uFogType == 1) // Linear
|
||||
{
|
||||
float Scale = 1.0 / (uFogEnd - uFogStart);
|
||||
FogFactor = (uFogEnd - vFogCoord) * Scale;
|
||||
}
|
||||
else if (uFogType == 2) // Exp2
|
||||
{
|
||||
FogFactor = exp2(-uFogDensity * uFogDensity * vFogCoord * vFogCoord * LOG2);
|
||||
}
|
||||
|
||||
FogFactor = clamp(FogFactor, 0.0, 1.0);
|
||||
|
||||
return FogFactor;
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 Color0 = vec4(1.0, 1.0, 1.0, 1.0);
|
||||
vec4 Color1 = vec4(1.0, 1.0, 1.0, 1.0);
|
||||
|
||||
if (bool(uTextureUsage0))
|
||||
Color0 = texture2D(uTextureUnit0, vTextureCoord0);
|
||||
|
||||
if (bool(uTextureUsage1))
|
||||
Color1 = texture2D(uTextureUnit1, vTextureCoord1);
|
||||
|
||||
vec4 FinalColor = (Color0 * Color1 * uModulate) * vVertexColor;
|
||||
FinalColor += vSpecularColor;
|
||||
|
||||
if (bool(uFogEnable))
|
||||
{
|
||||
float FogFactor = computeFog();
|
||||
vec4 FogColor = uFogColor;
|
||||
FogColor.a = 1.0;
|
||||
FinalColor = mix(FogColor, FinalColor, FogFactor);
|
||||
}
|
||||
|
||||
gl_FragColor = FinalColor;
|
||||
}
|
74
media/Shaders/COGLES2NormalMap.fsh
Normal file
@ -0,0 +1,74 @@
|
||||
#define MAX_LIGHTS 2
|
||||
|
||||
precision mediump float;
|
||||
|
||||
/* Uniforms */
|
||||
|
||||
uniform sampler2D uTextureUnit0;
|
||||
uniform sampler2D uTextureUnit1;
|
||||
uniform int uFogEnable;
|
||||
uniform int uFogType;
|
||||
uniform vec4 uFogColor;
|
||||
uniform float uFogStart;
|
||||
uniform float uFogEnd;
|
||||
uniform float uFogDensity;
|
||||
|
||||
/* Varyings */
|
||||
|
||||
varying vec2 vTexCoord;
|
||||
varying vec3 vLightVector[MAX_LIGHTS];
|
||||
varying vec4 vLightColor[MAX_LIGHTS];
|
||||
varying float vFogCoord;
|
||||
|
||||
float computeFog()
|
||||
{
|
||||
const float LOG2 = 1.442695;
|
||||
float FogFactor = 0.0;
|
||||
|
||||
if (uFogType == 0) // Exp
|
||||
{
|
||||
FogFactor = exp2(-uFogDensity * vFogCoord * LOG2);
|
||||
}
|
||||
else if (uFogType == 1) // Linear
|
||||
{
|
||||
float Scale = 1.0 / (uFogEnd - uFogStart);
|
||||
FogFactor = (uFogEnd - vFogCoord) * Scale;
|
||||
}
|
||||
else if (uFogType == 2) // Exp2
|
||||
{
|
||||
FogFactor = exp2(-uFogDensity * uFogDensity * vFogCoord * vFogCoord * LOG2);
|
||||
}
|
||||
|
||||
FogFactor = clamp(FogFactor, 0.0, 1.0);
|
||||
|
||||
return FogFactor;
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 Color = texture2D(uTextureUnit0, vTexCoord);
|
||||
vec3 Normal = texture2D(uTextureUnit1, vTexCoord).xyz * 2.0 - 1.0;
|
||||
|
||||
vec4 FinalColor = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
|
||||
for (int i = 0; i < int(MAX_LIGHTS); i++)
|
||||
{
|
||||
vec3 LightVector = normalize(vLightVector[i]);
|
||||
|
||||
float Lambert = max(dot(LightVector, Normal), 0.0);
|
||||
FinalColor += vec4(Lambert) * vLightColor[i];
|
||||
}
|
||||
|
||||
FinalColor *= Color;
|
||||
FinalColor.w = vLightColor[0].w;
|
||||
|
||||
if (bool(uFogEnable))
|
||||
{
|
||||
float FogFactor = computeFog();
|
||||
vec4 FogColor = uFogColor;
|
||||
FogColor.a = 1.0;
|
||||
FinalColor = mix(FogColor, FinalColor, FogFactor);
|
||||
}
|
||||
|
||||
gl_FragColor = FinalColor;
|
||||
}
|
52
media/Shaders/COGLES2NormalMap.vsh
Normal file
@ -0,0 +1,52 @@
|
||||
#define MAX_LIGHTS 2
|
||||
|
||||
/* Attributes */
|
||||
|
||||
attribute vec3 inVertexPosition;
|
||||
attribute vec3 inVertexNormal;
|
||||
attribute vec3 inVertexTangent;
|
||||
attribute vec3 inVertexBinormal;
|
||||
attribute vec4 inVertexColor;
|
||||
attribute vec2 inTexCoord0;
|
||||
|
||||
/* Uniforms */
|
||||
|
||||
uniform mat4 uWVPMatrix;
|
||||
uniform mat4 uWVMatrix;
|
||||
uniform vec3 uLightPosition[MAX_LIGHTS];
|
||||
uniform vec4 uLightColor[MAX_LIGHTS];
|
||||
|
||||
/* Varyings */
|
||||
|
||||
varying vec2 vTexCoord;
|
||||
varying vec3 vLightVector[MAX_LIGHTS];
|
||||
varying vec4 vLightColor[MAX_LIGHTS];
|
||||
varying float vFogCoord;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = uWVPMatrix * vec4(inVertexPosition, 1.0);
|
||||
|
||||
vTexCoord = inTexCoord0;
|
||||
|
||||
for (int i = 0; i < int(MAX_LIGHTS); i++)
|
||||
{
|
||||
vec3 LightVector = uLightPosition[i] - inVertexPosition;
|
||||
|
||||
vLightVector[i].x = dot(inVertexTangent, LightVector);
|
||||
vLightVector[i].y = dot(inVertexBinormal, LightVector);
|
||||
vLightVector[i].z = dot(inVertexNormal, LightVector);
|
||||
|
||||
vLightColor[i].x = dot(LightVector, LightVector);
|
||||
vLightColor[i].x *= uLightColor[i].a;
|
||||
vLightColor[i] = vec4(inversesqrt(vLightColor[i].x));
|
||||
vLightColor[i] *= uLightColor[i];
|
||||
vLightColor[i].a = inVertexColor.a;
|
||||
|
||||
vLightColor[i].x = clamp(vLightColor[i].x, 0.0, 1.0);
|
||||
vLightColor[i].y = clamp(vLightColor[i].y, 0.0, 1.0);
|
||||
vLightColor[i].z = clamp(vLightColor[i].z, 0.0, 1.0);
|
||||
}
|
||||
|
||||
vFogCoord = length((uWVMatrix * vec4(inVertexPosition, 1.0)).xyz);
|
||||
}
|
75
media/Shaders/COGLES2OneTextureBlend.fsh
Normal file
@ -0,0 +1,75 @@
|
||||
precision mediump float;
|
||||
|
||||
/* Uniforms */
|
||||
|
||||
uniform int uTextureUsage0;
|
||||
uniform sampler2D uTextureUnit0;
|
||||
uniform int uBlendType;
|
||||
uniform int uFogEnable;
|
||||
uniform int uFogType;
|
||||
uniform vec4 uFogColor;
|
||||
uniform float uFogStart;
|
||||
uniform float uFogEnd;
|
||||
uniform float uFogDensity;
|
||||
|
||||
/* Varyings */
|
||||
|
||||
varying vec2 vTextureCoord0;
|
||||
varying vec4 vVertexColor;
|
||||
varying vec4 vSpecularColor;
|
||||
varying float vFogCoord;
|
||||
|
||||
float computeFog()
|
||||
{
|
||||
const float LOG2 = 1.442695;
|
||||
float FogFactor = 0.0;
|
||||
|
||||
if (uFogType == 0) // Exp
|
||||
{
|
||||
FogFactor = exp2(-uFogDensity * vFogCoord * LOG2);
|
||||
}
|
||||
else if (uFogType == 1) // Linear
|
||||
{
|
||||
float Scale = 1.0 / (uFogEnd - uFogStart);
|
||||
FogFactor = (uFogEnd - vFogCoord) * Scale;
|
||||
}
|
||||
else if (uFogType == 2) // Exp2
|
||||
{
|
||||
FogFactor = exp2(-uFogDensity * uFogDensity * vFogCoord * vFogCoord * LOG2);
|
||||
}
|
||||
|
||||
FogFactor = clamp(FogFactor, 0.0, 1.0);
|
||||
|
||||
return FogFactor;
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 Color0 = vVertexColor;
|
||||
vec4 Color1 = vec4(1.0, 1.0, 1.0, 1.0);
|
||||
|
||||
if (bool(uTextureUsage0))
|
||||
Color1 = texture2D(uTextureUnit0, vTextureCoord0);
|
||||
|
||||
vec4 FinalColor = Color0 * Color1;
|
||||
FinalColor += vSpecularColor;
|
||||
|
||||
if (uBlendType == 1)
|
||||
{
|
||||
FinalColor.w = Color0.w;
|
||||
}
|
||||
else if (uBlendType == 2)
|
||||
{
|
||||
FinalColor.w = Color1.w;
|
||||
}
|
||||
|
||||
if (bool(uFogEnable))
|
||||
{
|
||||
float FogFactor = computeFog();
|
||||
vec4 FogColor = uFogColor;
|
||||
FogColor.a = 1.0;
|
||||
FinalColor = mix(FogColor, FinalColor, FogFactor);
|
||||
}
|
||||
|
||||
gl_FragColor = FinalColor;
|
||||
}
|
82
media/Shaders/COGLES2ParallaxMap.fsh
Normal file
@ -0,0 +1,82 @@
|
||||
#define MAX_LIGHTS 2
|
||||
|
||||
precision mediump float;
|
||||
|
||||
/* Uniforms */
|
||||
|
||||
uniform float uFactor;
|
||||
uniform sampler2D uTextureUnit0;
|
||||
uniform sampler2D uTextureUnit1;
|
||||
uniform int uFogEnable;
|
||||
uniform int uFogType;
|
||||
uniform vec4 uFogColor;
|
||||
uniform float uFogStart;
|
||||
uniform float uFogEnd;
|
||||
uniform float uFogDensity;
|
||||
|
||||
/* Varyings */
|
||||
|
||||
varying vec2 vTexCoord;
|
||||
varying vec3 vEyeVector;
|
||||
varying vec3 vLightVector[MAX_LIGHTS];
|
||||
varying vec4 vLightColor[MAX_LIGHTS];
|
||||
varying float vFogCoord;
|
||||
|
||||
float computeFog()
|
||||
{
|
||||
const float LOG2 = 1.442695;
|
||||
float FogFactor = 0.0;
|
||||
|
||||
if (uFogType == 0) // Exp
|
||||
{
|
||||
FogFactor = exp2(-uFogDensity * vFogCoord * LOG2);
|
||||
}
|
||||
else if (uFogType == 1) // Linear
|
||||
{
|
||||
float Scale = 1.0 / (uFogEnd - uFogStart);
|
||||
FogFactor = (uFogEnd - vFogCoord) * Scale;
|
||||
}
|
||||
else if (uFogType == 2) // Exp2
|
||||
{
|
||||
FogFactor = exp2(-uFogDensity * uFogDensity * vFogCoord * vFogCoord * LOG2);
|
||||
}
|
||||
|
||||
FogFactor = clamp(FogFactor, 0.0, 1.0);
|
||||
|
||||
return FogFactor;
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 TempFetch = texture2D(uTextureUnit1, vTexCoord) * 2.0 - 1.0;
|
||||
TempFetch *= uFactor;
|
||||
|
||||
vec3 EyeVector = normalize(vEyeVector);
|
||||
vec2 TexCoord = EyeVector.xy * TempFetch.w + vTexCoord;
|
||||
|
||||
vec4 Color = texture2D(uTextureUnit0, TexCoord);
|
||||
vec3 Normal = texture2D(uTextureUnit1, TexCoord).xyz * 2.0 - 1.0;
|
||||
|
||||
vec4 FinalColor = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
|
||||
for (int i = 0; i < int(MAX_LIGHTS); i++)
|
||||
{
|
||||
vec3 LightVector = normalize(vLightVector[i]);
|
||||
|
||||
float Lambert = max(dot(LightVector, Normal), 0.0);
|
||||
FinalColor += vec4(Lambert) * vLightColor[i];
|
||||
}
|
||||
|
||||
FinalColor *= Color;
|
||||
FinalColor.w = vLightColor[0].w;
|
||||
|
||||
if (bool(uFogEnable))
|
||||
{
|
||||
float FogFactor = computeFog();
|
||||
vec4 FogColor = uFogColor;
|
||||
FogColor.a = 1.0;
|
||||
FinalColor = mix(FogColor, FinalColor, FogFactor);
|
||||
}
|
||||
|
||||
gl_FragColor = FinalColor;
|
||||
}
|
61
media/Shaders/COGLES2ParallaxMap.vsh
Normal file
@ -0,0 +1,61 @@
|
||||
#define MAX_LIGHTS 2
|
||||
|
||||
/* Attributes */
|
||||
|
||||
attribute vec3 inVertexPosition;
|
||||
attribute vec3 inVertexNormal;
|
||||
attribute vec3 inVertexTangent;
|
||||
attribute vec3 inVertexBinormal;
|
||||
attribute vec4 inVertexColor;
|
||||
attribute vec2 inTexCoord0;
|
||||
|
||||
/* Uniforms */
|
||||
|
||||
uniform mat4 uWVPMatrix;
|
||||
uniform mat4 uWVMatrix;
|
||||
uniform vec3 uEyePosition;
|
||||
uniform vec3 uLightPosition[MAX_LIGHTS];
|
||||
uniform vec4 uLightColor[MAX_LIGHTS];
|
||||
|
||||
/* Varyings */
|
||||
|
||||
varying vec2 vTexCoord;
|
||||
varying vec3 vEyeVector;
|
||||
varying vec3 vLightVector[MAX_LIGHTS];
|
||||
varying vec4 vLightColor[MAX_LIGHTS];
|
||||
varying float vFogCoord;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = uWVPMatrix * vec4(inVertexPosition, 1.0);
|
||||
|
||||
vTexCoord = inTexCoord0;
|
||||
|
||||
vec3 EyeVector = uEyePosition - inVertexPosition;
|
||||
|
||||
vEyeVector.x = dot(inVertexTangent, EyeVector);
|
||||
vEyeVector.y = dot(inVertexBinormal, EyeVector);
|
||||
vEyeVector.z = dot(inVertexNormal, EyeVector);
|
||||
vEyeVector *= vec3(1.0, -1.0, -1.0);
|
||||
|
||||
for (int i = 0; i < int(MAX_LIGHTS); i++)
|
||||
{
|
||||
vec3 LightVector = uLightPosition[i] - inVertexPosition;
|
||||
|
||||
vLightVector[i].x = dot(inVertexTangent, LightVector);
|
||||
vLightVector[i].y = dot(inVertexBinormal, LightVector);
|
||||
vLightVector[i].z = dot(inVertexNormal, LightVector);
|
||||
|
||||
vLightColor[i].x = dot(LightVector, LightVector);
|
||||
vLightColor[i].x *= uLightColor[i].a;
|
||||
vLightColor[i] = vec4(inversesqrt(vLightColor[i].x));
|
||||
vLightColor[i] *= uLightColor[i];
|
||||
vLightColor[i].a = inVertexColor.a;
|
||||
|
||||
vLightColor[i].x = clamp(vLightColor[i].x, 0.0, 1.0);
|
||||
vLightColor[i].y = clamp(vLightColor[i].y, 0.0, 1.0);
|
||||
vLightColor[i].z = clamp(vLightColor[i].z, 0.0, 1.0);
|
||||
}
|
||||
|
||||
vFogCoord = length((uWVMatrix * vec4(inVertexPosition, 1.0)).xyz);
|
||||
}
|
70
media/Shaders/COGLES2Reflection2Layer.fsh
Normal file
@ -0,0 +1,70 @@
|
||||
precision mediump float;
|
||||
|
||||
/* Uniforms */
|
||||
|
||||
uniform int uTextureUsage0;
|
||||
uniform int uTextureUsage1;
|
||||
uniform sampler2D uTextureUnit0;
|
||||
uniform sampler2D uTextureUnit1;
|
||||
uniform int uFogEnable;
|
||||
uniform int uFogType;
|
||||
uniform vec4 uFogColor;
|
||||
uniform float uFogStart;
|
||||
uniform float uFogEnd;
|
||||
uniform float uFogDensity;
|
||||
|
||||
/* Varyings */
|
||||
|
||||
varying vec2 vTextureCoord0;
|
||||
varying vec2 vTextureCoord1;
|
||||
varying vec4 vVertexColor;
|
||||
varying vec4 vSpecularColor;
|
||||
varying float vFogCoord;
|
||||
|
||||
float computeFog()
|
||||
{
|
||||
const float LOG2 = 1.442695;
|
||||
float FogFactor = 0.0;
|
||||
|
||||
if (uFogType == 0) // Exp
|
||||
{
|
||||
FogFactor = exp2(-uFogDensity * vFogCoord * LOG2);
|
||||
}
|
||||
else if (uFogType == 1) // Linear
|
||||
{
|
||||
float Scale = 1.0 / (uFogEnd - uFogStart);
|
||||
FogFactor = (uFogEnd - vFogCoord) * Scale;
|
||||
}
|
||||
else if (uFogType == 2) // Exp2
|
||||
{
|
||||
FogFactor = exp2(-uFogDensity * uFogDensity * vFogCoord * vFogCoord * LOG2);
|
||||
}
|
||||
|
||||
FogFactor = clamp(FogFactor, 0.0, 1.0);
|
||||
|
||||
return FogFactor;
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 Color0 = vec4(1.0, 1.0, 1.0, 1.0);
|
||||
vec4 Color1 = vec4(1.0, 1.0, 1.0, 1.0);
|
||||
|
||||
if (bool(uTextureUsage0))
|
||||
Color0 = texture2D(uTextureUnit0, vTextureCoord0);
|
||||
|
||||
if (bool(uTextureUsage1))
|
||||
Color1 = texture2D(uTextureUnit1, vTextureCoord1);
|
||||
|
||||
vec4 FinalColor = (Color0 * Color1) * vVertexColor + vSpecularColor;
|
||||
|
||||
if (bool(uFogEnable))
|
||||
{
|
||||
float FogFactor = computeFog();
|
||||
vec4 FogColor = uFogColor;
|
||||
FogColor.a = 1.0;
|
||||
FinalColor = mix(FogColor, FinalColor, FogFactor);
|
||||
}
|
||||
|
||||
gl_FragColor = FinalColor;
|
||||
}
|
159
media/Shaders/COGLES2Reflection2Layer.vsh
Normal file
@ -0,0 +1,159 @@
|
||||
#define MAX_LIGHTS 8
|
||||
|
||||
/* Attributes */
|
||||
|
||||
attribute vec3 inVertexPosition;
|
||||
attribute vec3 inVertexNormal;
|
||||
attribute vec4 inVertexColor;
|
||||
attribute vec2 inTexCoord0;
|
||||
attribute vec2 inTexCoord1;
|
||||
|
||||
/* Uniforms */
|
||||
|
||||
uniform mat4 uWVPMatrix;
|
||||
uniform mat4 uWVMatrix;
|
||||
uniform mat4 uNMatrix;
|
||||
uniform mat4 uTMatrix0;
|
||||
|
||||
uniform vec4 uGlobalAmbient;
|
||||
uniform vec4 uMaterialAmbient;
|
||||
uniform vec4 uMaterialDiffuse;
|
||||
uniform vec4 uMaterialEmissive;
|
||||
uniform vec4 uMaterialSpecular;
|
||||
uniform float uMaterialShininess;
|
||||
|
||||
uniform int uLightCount;
|
||||
uniform int uLightType[MAX_LIGHTS];
|
||||
uniform vec3 uLightPosition[MAX_LIGHTS];
|
||||
uniform vec3 uLightDirection[MAX_LIGHTS];
|
||||
uniform vec3 uLightAttenuation[MAX_LIGHTS];
|
||||
uniform vec4 uLightAmbient[MAX_LIGHTS];
|
||||
uniform vec4 uLightDiffuse[MAX_LIGHTS];
|
||||
uniform vec4 uLightSpecular[MAX_LIGHTS];
|
||||
|
||||
uniform float uThickness;
|
||||
|
||||
/* Varyings */
|
||||
|
||||
varying vec2 vTextureCoord0;
|
||||
varying vec2 vTextureCoord1;
|
||||
varying vec4 vVertexColor;
|
||||
varying vec4 vSpecularColor;
|
||||
varying float vFogCoord;
|
||||
|
||||
void dirLight(in int index, in vec3 position, in vec3 normal, inout vec4 ambient, inout vec4 diffuse, inout vec4 specular)
|
||||
{
|
||||
vec3 L = normalize(-(uNMatrix * vec4(uLightDirection[index], 0.0)).xyz);
|
||||
|
||||
ambient += uLightAmbient[index];
|
||||
|
||||
float NdotL = dot(normal, L);
|
||||
|
||||
if (NdotL > 0.0)
|
||||
{
|
||||
diffuse += uLightDiffuse[index] * NdotL;
|
||||
|
||||
vec3 E = normalize(-position);
|
||||
vec3 HalfVector = normalize(L + E);
|
||||
float NdotH = max(0.0, dot(normal, HalfVector));
|
||||
|
||||
float SpecularFactor = pow(NdotH, uMaterialShininess);
|
||||
specular += uLightSpecular[index] * SpecularFactor;
|
||||
}
|
||||
}
|
||||
|
||||
void pointLight(in int index, in vec3 position, in vec3 normal, inout vec4 ambient, inout vec4 diffuse, inout vec4 specular)
|
||||
{
|
||||
vec3 L = uLightPosition[index] - position;
|
||||
float D = length(L);
|
||||
L = normalize(L);
|
||||
|
||||
float Attenuation = 1.0 / (uLightAttenuation[index].x + uLightAttenuation[index].y * D +
|
||||
uLightAttenuation[index].z * D * D);
|
||||
|
||||
ambient += uLightAmbient[index] * Attenuation;
|
||||
|
||||
float NdotL = dot(normal, L);
|
||||
|
||||
if (NdotL > 0.0)
|
||||
{
|
||||
diffuse += uLightDiffuse[index] * NdotL * Attenuation;
|
||||
|
||||
vec3 E = normalize(-position);
|
||||
vec3 HalfVector = normalize(L + E);
|
||||
float NdotH = max(0.0, dot(normal, HalfVector));
|
||||
|
||||
float SpecularFactor = pow(NdotH, uMaterialShininess);
|
||||
specular += uLightSpecular[index] * SpecularFactor * Attenuation;
|
||||
}
|
||||
}
|
||||
|
||||
void spotLight(in int index, in vec3 position, in vec3 normal, inout vec4 ambient, inout vec4 diffuse, inout vec4 specular)
|
||||
{
|
||||
// TO-DO
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = uWVPMatrix * vec4(inVertexPosition, 1.0);
|
||||
gl_PointSize = uThickness;
|
||||
|
||||
vec4 TextureCoord0 = vec4(inTexCoord0.x, inTexCoord0.y, 1.0, 1.0);
|
||||
vTextureCoord0 = vec4(uTMatrix0 * TextureCoord0).xy;
|
||||
|
||||
vec3 Position = (uWVMatrix * vec4(inVertexPosition, 1.0)).xyz;
|
||||
vec3 P = normalize(Position);
|
||||
vec3 N = normalize(vec4(uNMatrix * vec4(inVertexNormal, 0.0)).xyz);
|
||||
vec3 R = reflect(P, N);
|
||||
|
||||
float V = 2.0 * sqrt(R.x*R.x + R.y*R.y + (R.z+1.0)*(R.z+1.0));
|
||||
vTextureCoord1 = vec2(R.x/V + 0.5, R.y/V + 0.5);
|
||||
|
||||
vVertexColor = inVertexColor.bgra;
|
||||
vSpecularColor = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
|
||||
if (uLightCount > 0)
|
||||
{
|
||||
vec3 Normal = normalize((uNMatrix * vec4(inVertexNormal, 0.0)).xyz);
|
||||
|
||||
vec4 Ambient = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
vec4 Diffuse = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
|
||||
for (int i = 0; i < int(MAX_LIGHTS); i++)
|
||||
{
|
||||
if( i >= uLightCount ) // can't use uniform as loop-counter directly in glsl
|
||||
break;
|
||||
if (uLightType[i] == 0)
|
||||
pointLight(i, Position, Normal, Ambient, Diffuse, vSpecularColor);
|
||||
}
|
||||
|
||||
for (int i = 0; i < int(MAX_LIGHTS); i++)
|
||||
{
|
||||
if( i >= uLightCount )
|
||||
break;
|
||||
if (uLightType[i] == 1)
|
||||
spotLight(i, Position, Normal, Ambient, Diffuse, vSpecularColor);
|
||||
}
|
||||
|
||||
for (int i = 0; i < int(MAX_LIGHTS); i++)
|
||||
{
|
||||
if( i >= uLightCount )
|
||||
break;
|
||||
if (uLightType[i] == 2)
|
||||
dirLight(i, Position, Normal, Ambient, Diffuse, vSpecularColor);
|
||||
}
|
||||
|
||||
vec4 LightColor = Ambient * uMaterialAmbient + Diffuse * uMaterialDiffuse;
|
||||
LightColor = clamp(LightColor, 0.0, 1.0);
|
||||
LightColor.w = 1.0;
|
||||
|
||||
vVertexColor *= LightColor;
|
||||
vVertexColor += uMaterialEmissive;
|
||||
vVertexColor += uGlobalAmbient * uMaterialAmbient;
|
||||
vVertexColor = clamp(vVertexColor, 0.0, 1.0);
|
||||
|
||||
vSpecularColor *= uMaterialSpecular;
|
||||
}
|
||||
|
||||
vFogCoord = length(Position);
|
||||
}
|
21
media/Shaders/COGLES2Renderer2D.fsh
Normal file
@ -0,0 +1,21 @@
|
||||
precision mediump float;
|
||||
|
||||
/* Uniforms */
|
||||
|
||||
uniform int uTextureUsage;
|
||||
uniform sampler2D uTextureUnit;
|
||||
|
||||
/* Varyings */
|
||||
|
||||
varying vec2 vTextureCoord;
|
||||
varying vec4 vVertexColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 Color = vVertexColor;
|
||||
|
||||
if (bool(uTextureUsage))
|
||||
Color *= texture2D(uTextureUnit, vTextureCoord);
|
||||
|
||||
gl_FragColor = Color;
|
||||
}
|
22
media/Shaders/COGLES2Renderer2D.vsh
Normal file
@ -0,0 +1,22 @@
|
||||
/* Attributes */
|
||||
|
||||
attribute vec4 inVertexPosition;
|
||||
attribute vec4 inVertexColor;
|
||||
attribute vec2 inTexCoord0;
|
||||
|
||||
/* Uniforms */
|
||||
|
||||
uniform float uThickness;
|
||||
|
||||
/* Varyings */
|
||||
|
||||
varying vec2 vTextureCoord;
|
||||
varying vec4 vVertexColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = inVertexPosition;
|
||||
gl_PointSize = uThickness;
|
||||
vTextureCoord = inTexCoord0;
|
||||
vVertexColor = inVertexColor.bgra;
|
||||
}
|
9
media/Shaders/COGLES2Renderer2D_noTex.fsh
Normal file
@ -0,0 +1,9 @@
|
||||
precision mediump float;
|
||||
|
||||
/* Varyings */
|
||||
varying vec4 vVertexColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = vVertexColor;
|
||||
}
|
62
media/Shaders/COGLES2Solid.fsh
Normal file
@ -0,0 +1,62 @@
|
||||
precision mediump float;
|
||||
|
||||
/* Uniforms */
|
||||
|
||||
uniform int uTextureUsage0;
|
||||
uniform sampler2D uTextureUnit0;
|
||||
uniform int uFogEnable;
|
||||
uniform int uFogType;
|
||||
uniform vec4 uFogColor;
|
||||
uniform float uFogStart;
|
||||
uniform float uFogEnd;
|
||||
uniform float uFogDensity;
|
||||
|
||||
/* Varyings */
|
||||
|
||||
varying vec2 vTextureCoord0;
|
||||
varying vec4 vVertexColor;
|
||||
varying vec4 vSpecularColor;
|
||||
varying float vFogCoord;
|
||||
|
||||
float computeFog()
|
||||
{
|
||||
const float LOG2 = 1.442695;
|
||||
float FogFactor = 0.0;
|
||||
|
||||
if (uFogType == 0) // Exp
|
||||
{
|
||||
FogFactor = exp2(-uFogDensity * vFogCoord * LOG2);
|
||||
}
|
||||
else if (uFogType == 1) // Linear
|
||||
{
|
||||
float Scale = 1.0 / (uFogEnd - uFogStart);
|
||||
FogFactor = (uFogEnd - vFogCoord) * Scale;
|
||||
}
|
||||
else if (uFogType == 2) // Exp2
|
||||
{
|
||||
FogFactor = exp2(-uFogDensity * uFogDensity * vFogCoord * vFogCoord * LOG2);
|
||||
}
|
||||
|
||||
FogFactor = clamp(FogFactor, 0.0, 1.0);
|
||||
|
||||
return FogFactor;
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 Color = vVertexColor;
|
||||
|
||||
if (bool(uTextureUsage0))
|
||||
Color *= texture2D(uTextureUnit0, vTextureCoord0);
|
||||
Color += vSpecularColor;
|
||||
|
||||
if (bool(uFogEnable))
|
||||
{
|
||||
float FogFactor = computeFog();
|
||||
vec4 FogColor = uFogColor;
|
||||
FogColor.a = 1.0;
|
||||
Color = mix(FogColor, Color, FogFactor);
|
||||
}
|
||||
|
||||
gl_FragColor = Color;
|
||||
}
|
151
media/Shaders/COGLES2Solid.vsh
Normal file
@ -0,0 +1,151 @@
|
||||
#define MAX_LIGHTS 8
|
||||
|
||||
/* Attributes */
|
||||
|
||||
attribute vec3 inVertexPosition;
|
||||
attribute vec3 inVertexNormal;
|
||||
attribute vec4 inVertexColor;
|
||||
attribute vec2 inTexCoord0;
|
||||
|
||||
/* Uniforms */
|
||||
|
||||
uniform mat4 uWVPMatrix;
|
||||
uniform mat4 uWVMatrix;
|
||||
uniform mat4 uNMatrix;
|
||||
uniform mat4 uTMatrix0;
|
||||
|
||||
uniform vec4 uGlobalAmbient;
|
||||
uniform vec4 uMaterialAmbient;
|
||||
uniform vec4 uMaterialDiffuse;
|
||||
uniform vec4 uMaterialEmissive;
|
||||
uniform vec4 uMaterialSpecular;
|
||||
uniform float uMaterialShininess;
|
||||
|
||||
uniform int uLightCount;
|
||||
uniform int uLightType[MAX_LIGHTS];
|
||||
uniform vec3 uLightPosition[MAX_LIGHTS];
|
||||
uniform vec3 uLightDirection[MAX_LIGHTS];
|
||||
uniform vec3 uLightAttenuation[MAX_LIGHTS];
|
||||
uniform vec4 uLightAmbient[MAX_LIGHTS];
|
||||
uniform vec4 uLightDiffuse[MAX_LIGHTS];
|
||||
uniform vec4 uLightSpecular[MAX_LIGHTS];
|
||||
|
||||
uniform float uThickness;
|
||||
|
||||
/* Varyings */
|
||||
|
||||
varying vec2 vTextureCoord0;
|
||||
varying vec4 vVertexColor;
|
||||
varying vec4 vSpecularColor;
|
||||
varying float vFogCoord;
|
||||
|
||||
void dirLight(in int index, in vec3 position, in vec3 normal, inout vec4 ambient, inout vec4 diffuse, inout vec4 specular)
|
||||
{
|
||||
vec3 L = normalize(-(uNMatrix * vec4(uLightDirection[index], 0.0)).xyz);
|
||||
|
||||
ambient += uLightAmbient[index];
|
||||
|
||||
float NdotL = dot(normal, L);
|
||||
|
||||
if (NdotL > 0.0)
|
||||
{
|
||||
diffuse += uLightDiffuse[index] * NdotL;
|
||||
|
||||
vec3 E = normalize(-position);
|
||||
vec3 HalfVector = normalize(L + E);
|
||||
float NdotH = max(0.0, dot(normal, HalfVector));
|
||||
|
||||
float SpecularFactor = pow(NdotH, uMaterialShininess);
|
||||
specular += uLightSpecular[index] * SpecularFactor;
|
||||
}
|
||||
}
|
||||
|
||||
void pointLight(in int index, in vec3 position, in vec3 normal, inout vec4 ambient, inout vec4 diffuse, inout vec4 specular)
|
||||
{
|
||||
vec3 L = uLightPosition[index] - position;
|
||||
float D = length(L);
|
||||
L = normalize(L);
|
||||
|
||||
float Attenuation = 1.0 / (uLightAttenuation[index].x + uLightAttenuation[index].y * D +
|
||||
uLightAttenuation[index].z * D * D);
|
||||
|
||||
ambient += uLightAmbient[index] * Attenuation;
|
||||
|
||||
float NdotL = dot(normal, L);
|
||||
|
||||
if (NdotL > 0.0)
|
||||
{
|
||||
diffuse += uLightDiffuse[index] * NdotL * Attenuation;
|
||||
|
||||
vec3 E = normalize(-position);
|
||||
vec3 HalfVector = normalize(L + E);
|
||||
float NdotH = max(0.0, dot(normal, HalfVector));
|
||||
|
||||
float SpecularFactor = pow(NdotH, uMaterialShininess);
|
||||
specular += uLightSpecular[index] * SpecularFactor * Attenuation;
|
||||
}
|
||||
}
|
||||
|
||||
void spotLight(in int index, in vec3 position, in vec3 normal, inout vec4 ambient, inout vec4 diffuse, inout vec4 specular)
|
||||
{
|
||||
// TO-DO
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = uWVPMatrix * vec4(inVertexPosition, 1.0);
|
||||
gl_PointSize = uThickness;
|
||||
|
||||
vec4 TextureCoord0 = vec4(inTexCoord0.x, inTexCoord0.y, 1.0, 1.0);
|
||||
vTextureCoord0 = vec4(uTMatrix0 * TextureCoord0).xy;
|
||||
|
||||
vVertexColor = inVertexColor.bgra;
|
||||
vSpecularColor = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
|
||||
vec3 Position = (uWVMatrix * vec4(inVertexPosition, 1.0)).xyz;
|
||||
|
||||
if (uLightCount > 0)
|
||||
{
|
||||
vec3 Normal = normalize((uNMatrix * vec4(inVertexNormal, 0.0)).xyz);
|
||||
|
||||
vec4 Ambient = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
vec4 Diffuse = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
|
||||
for (int i = 0; i < int(MAX_LIGHTS); i++)
|
||||
{
|
||||
if( i >= uLightCount ) // can't use uniform as loop-counter directly in glsl
|
||||
break;
|
||||
if (uLightType[i] == 0)
|
||||
pointLight(i, Position, Normal, Ambient, Diffuse, vSpecularColor);
|
||||
}
|
||||
|
||||
for (int i = 0; i < int(MAX_LIGHTS); i++)
|
||||
{
|
||||
if( i >= uLightCount )
|
||||
break;
|
||||
if (uLightType[i] == 1)
|
||||
spotLight(i, Position, Normal, Ambient, Diffuse, vSpecularColor);
|
||||
}
|
||||
|
||||
for (int i = 0; i < int(MAX_LIGHTS); i++)
|
||||
{
|
||||
if( i >= uLightCount )
|
||||
break;
|
||||
if (uLightType[i] == 2)
|
||||
dirLight(i, Position, Normal, Ambient, Diffuse, vSpecularColor);
|
||||
}
|
||||
|
||||
vec4 LightColor = Ambient * uMaterialAmbient + Diffuse * uMaterialDiffuse;
|
||||
LightColor = clamp(LightColor, 0.0, 1.0);
|
||||
LightColor.w = 1.0;
|
||||
|
||||
vVertexColor *= LightColor;
|
||||
vVertexColor += uMaterialEmissive;
|
||||
vVertexColor += uGlobalAmbient * uMaterialAmbient;
|
||||
vVertexColor = clamp(vVertexColor, 0.0, 1.0);
|
||||
|
||||
vSpecularColor *= uMaterialSpecular;
|
||||
}
|
||||
|
||||
vFogCoord = length(Position);
|
||||
}
|
157
media/Shaders/COGLES2Solid2.vsh
Normal file
@ -0,0 +1,157 @@
|
||||
#define MAX_LIGHTS 8
|
||||
|
||||
/* Attributes */
|
||||
|
||||
attribute vec3 inVertexPosition;
|
||||
attribute vec3 inVertexNormal;
|
||||
attribute vec4 inVertexColor;
|
||||
attribute vec2 inTexCoord0;
|
||||
attribute vec2 inTexCoord1;
|
||||
|
||||
/* Uniforms */
|
||||
|
||||
uniform mat4 uWVPMatrix;
|
||||
uniform mat4 uWVMatrix;
|
||||
uniform mat4 uNMatrix;
|
||||
uniform mat4 uTMatrix0;
|
||||
uniform mat4 uTMatrix1;
|
||||
|
||||
uniform vec4 uGlobalAmbient;
|
||||
uniform vec4 uMaterialAmbient;
|
||||
uniform vec4 uMaterialDiffuse;
|
||||
uniform vec4 uMaterialEmissive;
|
||||
uniform vec4 uMaterialSpecular;
|
||||
uniform float uMaterialShininess;
|
||||
|
||||
uniform int uLightCount;
|
||||
uniform int uLightType[MAX_LIGHTS];
|
||||
uniform vec3 uLightPosition[MAX_LIGHTS];
|
||||
uniform vec3 uLightDirection[MAX_LIGHTS];
|
||||
uniform vec3 uLightAttenuation[MAX_LIGHTS];
|
||||
uniform vec4 uLightAmbient[MAX_LIGHTS];
|
||||
uniform vec4 uLightDiffuse[MAX_LIGHTS];
|
||||
uniform vec4 uLightSpecular[MAX_LIGHTS];
|
||||
|
||||
uniform float uThickness;
|
||||
|
||||
/* Varyings */
|
||||
|
||||
varying vec2 vTextureCoord0;
|
||||
varying vec2 vTextureCoord1;
|
||||
varying vec4 vVertexColor;
|
||||
varying vec4 vSpecularColor;
|
||||
varying float vFogCoord;
|
||||
|
||||
void dirLight(in int index, in vec3 position, in vec3 normal, inout vec4 ambient, inout vec4 diffuse, inout vec4 specular)
|
||||
{
|
||||
vec3 L = normalize(-(uNMatrix * vec4(uLightDirection[index], 0.0)).xyz);
|
||||
|
||||
ambient += uLightAmbient[index];
|
||||
|
||||
float NdotL = dot(normal, L);
|
||||
|
||||
if (NdotL > 0.0)
|
||||
{
|
||||
diffuse += uLightDiffuse[index] * NdotL;
|
||||
|
||||
vec3 E = normalize(-position);
|
||||
vec3 HalfVector = normalize(L + E);
|
||||
float NdotH = max(0.0, dot(normal, HalfVector));
|
||||
|
||||
float SpecularFactor = pow(NdotH, uMaterialShininess);
|
||||
specular += uLightSpecular[index] * SpecularFactor;
|
||||
}
|
||||
}
|
||||
|
||||
void pointLight(in int index, in vec3 position, in vec3 normal, inout vec4 ambient, inout vec4 diffuse, inout vec4 specular)
|
||||
{
|
||||
vec3 L = uLightPosition[index] - position;
|
||||
float D = length(L);
|
||||
L = normalize(L);
|
||||
|
||||
float Attenuation = 1.0 / (uLightAttenuation[index].x + uLightAttenuation[index].y * D +
|
||||
uLightAttenuation[index].z * D * D);
|
||||
|
||||
ambient += uLightAmbient[index] * Attenuation;
|
||||
|
||||
float NdotL = dot(normal, L);
|
||||
|
||||
if (NdotL > 0.0)
|
||||
{
|
||||
diffuse += uLightDiffuse[index] * NdotL * Attenuation;
|
||||
|
||||
vec3 E = normalize(-position);
|
||||
vec3 HalfVector = normalize(L + E);
|
||||
float NdotH = max(0.0, dot(normal, HalfVector));
|
||||
|
||||
float SpecularFactor = pow(NdotH, uMaterialShininess);
|
||||
specular += uLightSpecular[index] * SpecularFactor * Attenuation;
|
||||
}
|
||||
}
|
||||
|
||||
void spotLight(in int index, in vec3 position, in vec3 normal, inout vec4 ambient, inout vec4 diffuse, inout vec4 specular)
|
||||
{
|
||||
// TO-DO
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = uWVPMatrix * vec4(inVertexPosition, 1.0);
|
||||
gl_PointSize = uThickness;
|
||||
|
||||
vec4 TextureCoord0 = vec4(inTexCoord0.x, inTexCoord0.y, 1.0, 1.0);
|
||||
vTextureCoord0 = vec4(uTMatrix0 * TextureCoord0).xy;
|
||||
|
||||
vec4 TextureCoord1 = vec4(inTexCoord1.x, inTexCoord1.y, 1.0, 1.0);
|
||||
vTextureCoord1 = vec4(uTMatrix1 * TextureCoord1).xy;
|
||||
|
||||
vVertexColor = inVertexColor.bgra;
|
||||
vSpecularColor = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
|
||||
vec3 Position = (uWVMatrix * vec4(inVertexPosition, 1.0)).xyz;
|
||||
|
||||
if (uLightCount > 0)
|
||||
{
|
||||
vec3 Normal = normalize((uNMatrix * vec4(inVertexNormal, 0.0)).xyz);
|
||||
|
||||
vec4 Ambient = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
vec4 Diffuse = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
|
||||
for (int i = 0; i < int(MAX_LIGHTS); i++)
|
||||
{
|
||||
if( i >= uLightCount ) // can't use uniform as loop-counter directly in glsl
|
||||
break;
|
||||
if (uLightType[i] == 0)
|
||||
pointLight(i, Position, Normal, Ambient, Diffuse, vSpecularColor);
|
||||
}
|
||||
|
||||
for (int i = 0; i < int(MAX_LIGHTS); i++)
|
||||
{
|
||||
if( i >= uLightCount )
|
||||
break;
|
||||
if (uLightType[i] == 1)
|
||||
spotLight(i, Position, Normal, Ambient, Diffuse, vSpecularColor);
|
||||
}
|
||||
|
||||
for (int i = 0; i < int(MAX_LIGHTS); i++)
|
||||
{
|
||||
if( i >= uLightCount )
|
||||
break;
|
||||
if (uLightType[i] == 2)
|
||||
dirLight(i, Position, Normal, Ambient, Diffuse, vSpecularColor);
|
||||
}
|
||||
|
||||
vec4 LightColor = Ambient * uMaterialAmbient + Diffuse * uMaterialDiffuse;
|
||||
LightColor = clamp(LightColor, 0.0, 1.0);
|
||||
LightColor.w = 1.0;
|
||||
|
||||
vVertexColor *= LightColor;
|
||||
vVertexColor += uMaterialEmissive;
|
||||
vVertexColor += uGlobalAmbient * uMaterialAmbient;
|
||||
vVertexColor = clamp(vVertexColor, 0.0, 1.0);
|
||||
|
||||
vSpecularColor *= uMaterialSpecular;
|
||||
}
|
||||
|
||||
vFogCoord = length(Position);
|
||||
}
|
72
media/Shaders/COGLES2Solid2Layer.fsh
Normal file
@ -0,0 +1,72 @@
|
||||
precision mediump float;
|
||||
|
||||
/* Uniforms */
|
||||
|
||||
uniform int uTextureUsage0;
|
||||
uniform int uTextureUsage1;
|
||||
uniform sampler2D uTextureUnit0;
|
||||
uniform sampler2D uTextureUnit1;
|
||||
uniform int uFogEnable;
|
||||
uniform int uFogType;
|
||||
uniform vec4 uFogColor;
|
||||
uniform float uFogStart;
|
||||
uniform float uFogEnd;
|
||||
uniform float uFogDensity;
|
||||
|
||||
/* Varyings */
|
||||
|
||||
varying vec2 vTextureCoord0;
|
||||
varying vec2 vTextureCoord1;
|
||||
varying vec4 vVertexColor;
|
||||
varying vec4 vSpecularColor;
|
||||
varying float vFogCoord;
|
||||
|
||||
float computeFog()
|
||||
{
|
||||
const float LOG2 = 1.442695;
|
||||
float FogFactor = 0.0;
|
||||
|
||||
if (uFogType == 0) // Exp
|
||||
{
|
||||
FogFactor = exp2(-uFogDensity * vFogCoord * LOG2);
|
||||
}
|
||||
else if (uFogType == 1) // Linear
|
||||
{
|
||||
float Scale = 1.0 / (uFogEnd - uFogStart);
|
||||
FogFactor = (uFogEnd - vFogCoord) * Scale;
|
||||
}
|
||||
else if (uFogType == 2) // Exp2
|
||||
{
|
||||
FogFactor = exp2(-uFogDensity * uFogDensity * vFogCoord * vFogCoord * LOG2);
|
||||
}
|
||||
|
||||
FogFactor = clamp(FogFactor, 0.0, 1.0);
|
||||
|
||||
return FogFactor;
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 Color0 = vec4(1.0, 1.0, 1.0, 1.0);
|
||||
vec4 Color1 = vec4(1.0, 1.0, 1.0, 1.0);
|
||||
|
||||
if (bool(uTextureUsage0))
|
||||
Color0 = texture2D(uTextureUnit0, vTextureCoord0);
|
||||
|
||||
if (bool(uTextureUsage1))
|
||||
Color1 = texture2D(uTextureUnit1, vTextureCoord1);
|
||||
|
||||
vec4 FinalColor = (Color0 * vVertexColor.a + Color1 * (1.0 - vVertexColor.a)) * vVertexColor;
|
||||
FinalColor += vSpecularColor;
|
||||
|
||||
if (bool(uFogEnable))
|
||||
{
|
||||
float FogFactor = computeFog();
|
||||
vec4 FogColor = uFogColor;
|
||||
FogColor.a = 1.0;
|
||||
FinalColor = mix(FogColor, FinalColor, FogFactor);
|
||||
}
|
||||
|
||||
gl_FragColor = FinalColor;
|
||||
|
||||
}
|
62
media/Shaders/COGLES2SphereMap.fsh
Normal file
@ -0,0 +1,62 @@
|
||||
precision mediump float;
|
||||
|
||||
/* Uniforms */
|
||||
|
||||
uniform int uTextureUsage0;
|
||||
uniform sampler2D uTextureUnit0;
|
||||
uniform int uFogEnable;
|
||||
uniform int uFogType;
|
||||
uniform vec4 uFogColor;
|
||||
uniform float uFogStart;
|
||||
uniform float uFogEnd;
|
||||
uniform float uFogDensity;
|
||||
|
||||
/* Varyings */
|
||||
|
||||
varying vec2 vTextureCoord0;
|
||||
varying vec4 vVertexColor;
|
||||
varying vec4 vSpecularColor;
|
||||
varying float vFogCoord;
|
||||
|
||||
float computeFog()
|
||||
{
|
||||
const float LOG2 = 1.442695;
|
||||
float FogFactor = 0.0;
|
||||
|
||||
if (uFogType == 0) // Exp
|
||||
{
|
||||
FogFactor = exp2(-uFogDensity * vFogCoord * LOG2);
|
||||
}
|
||||
else if (uFogType == 1) // Linear
|
||||
{
|
||||
float Scale = 1.0 / (uFogEnd - uFogStart);
|
||||
FogFactor = (uFogEnd - vFogCoord) * Scale;
|
||||
}
|
||||
else if (uFogType == 2) // Exp2
|
||||
{
|
||||
FogFactor = exp2(-uFogDensity * uFogDensity * vFogCoord * vFogCoord * LOG2);
|
||||
}
|
||||
|
||||
FogFactor = clamp(FogFactor, 0.0, 1.0);
|
||||
|
||||
return FogFactor;
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 Color = vVertexColor;
|
||||
|
||||
if (bool(uTextureUsage0))
|
||||
Color *= texture2D(uTextureUnit0, vTextureCoord0);
|
||||
Color += vSpecularColor;
|
||||
|
||||
if (bool(uFogEnable))
|
||||
{
|
||||
float FogFactor = computeFog();
|
||||
vec4 FogColor = uFogColor;
|
||||
FogColor.a = 1.0;
|
||||
Color = mix(FogColor, Color, FogFactor);
|
||||
}
|
||||
|
||||
gl_FragColor = Color;
|
||||
}
|
154
media/Shaders/COGLES2SphereMap.vsh
Normal file
@ -0,0 +1,154 @@
|
||||
#define MAX_LIGHTS 8
|
||||
|
||||
/* Attributes */
|
||||
|
||||
attribute vec3 inVertexPosition;
|
||||
attribute vec3 inVertexNormal;
|
||||
attribute vec4 inVertexColor;
|
||||
attribute vec2 inTexCoord0;
|
||||
attribute vec2 inTexCoord1;
|
||||
|
||||
/* Uniforms */
|
||||
|
||||
uniform mat4 uWVPMatrix;
|
||||
uniform mat4 uWVMatrix;
|
||||
uniform mat4 uNMatrix;
|
||||
|
||||
uniform vec4 uGlobalAmbient;
|
||||
uniform vec4 uMaterialAmbient;
|
||||
uniform vec4 uMaterialDiffuse;
|
||||
uniform vec4 uMaterialEmissive;
|
||||
uniform vec4 uMaterialSpecular;
|
||||
uniform float uMaterialShininess;
|
||||
|
||||
uniform int uLightCount;
|
||||
uniform int uLightType[MAX_LIGHTS];
|
||||
uniform vec3 uLightPosition[MAX_LIGHTS];
|
||||
uniform vec3 uLightDirection[MAX_LIGHTS];
|
||||
uniform vec3 uLightAttenuation[MAX_LIGHTS];
|
||||
uniform vec4 uLightAmbient[MAX_LIGHTS];
|
||||
uniform vec4 uLightDiffuse[MAX_LIGHTS];
|
||||
uniform vec4 uLightSpecular[MAX_LIGHTS];
|
||||
|
||||
uniform float uThickness;
|
||||
|
||||
/* Varyings */
|
||||
|
||||
varying vec2 vTextureCoord0;
|
||||
varying vec4 vVertexColor;
|
||||
varying vec4 vSpecularColor;
|
||||
varying float vFogCoord;
|
||||
|
||||
void dirLight(in int index, in vec3 position, in vec3 normal, inout vec4 ambient, inout vec4 diffuse, inout vec4 specular)
|
||||
{
|
||||
vec3 L = normalize(-(uNMatrix * vec4(uLightDirection[index], 0.0)).xyz);
|
||||
|
||||
ambient += uLightAmbient[index];
|
||||
|
||||
float NdotL = dot(normal, L);
|
||||
|
||||
if (NdotL > 0.0)
|
||||
{
|
||||
diffuse += uLightDiffuse[index] * NdotL;
|
||||
|
||||
vec3 E = normalize(-position);
|
||||
vec3 HalfVector = normalize(L + E);
|
||||
float NdotH = max(0.0, dot(normal, HalfVector));
|
||||
|
||||
float SpecularFactor = pow(NdotH, uMaterialShininess);
|
||||
specular += uLightSpecular[index] * SpecularFactor;
|
||||
}
|
||||
}
|
||||
|
||||
void pointLight(in int index, in vec3 position, in vec3 normal, inout vec4 ambient, inout vec4 diffuse, inout vec4 specular)
|
||||
{
|
||||
vec3 L = uLightPosition[index] - position;
|
||||
float D = length(L);
|
||||
L = normalize(L);
|
||||
|
||||
float Attenuation = 1.0 / (uLightAttenuation[index].x + uLightAttenuation[index].y * D +
|
||||
uLightAttenuation[index].z * D * D);
|
||||
|
||||
ambient += uLightAmbient[index] * Attenuation;
|
||||
|
||||
float NdotL = dot(normal, L);
|
||||
|
||||
if (NdotL > 0.0)
|
||||
{
|
||||
diffuse += uLightDiffuse[index] * NdotL * Attenuation;
|
||||
|
||||
vec3 E = normalize(-position);
|
||||
vec3 HalfVector = normalize(L + E);
|
||||
float NdotH = max(0.0, dot(normal, HalfVector));
|
||||
|
||||
float SpecularFactor = pow(NdotH, uMaterialShininess);
|
||||
specular += uLightSpecular[index] * SpecularFactor * Attenuation;
|
||||
}
|
||||
}
|
||||
|
||||
void spotLight(in int index, in vec3 position, in vec3 normal, inout vec4 ambient, inout vec4 diffuse, inout vec4 specular)
|
||||
{
|
||||
// TO-DO
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = uWVPMatrix * vec4(inVertexPosition, 1.0);
|
||||
gl_PointSize = uThickness;
|
||||
|
||||
vec3 Position = (uWVMatrix * vec4(inVertexPosition, 1.0)).xyz;
|
||||
vec3 P = normalize(Position);
|
||||
vec3 N = normalize(vec4(uNMatrix * vec4(inVertexNormal, 0.0)).xyz);
|
||||
vec3 R = reflect(P, N);
|
||||
|
||||
float V = 2.0 * sqrt(R.x*R.x + R.y*R.y + (R.z+1.0)*(R.z+1.0));
|
||||
vTextureCoord0 = vec2(R.x/V + 0.5, R.y/V + 0.5);
|
||||
|
||||
vVertexColor = inVertexColor.bgra;
|
||||
vSpecularColor = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
|
||||
if (uLightCount > 0)
|
||||
{
|
||||
vec3 Normal = normalize((uNMatrix * vec4(inVertexNormal, 0.0)).xyz);
|
||||
|
||||
vec4 Ambient = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
vec4 Diffuse = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
|
||||
for (int i = 0; i < int(MAX_LIGHTS); i++)
|
||||
{
|
||||
if( i >= uLightCount ) // can't use uniform as loop-counter directly in glsl
|
||||
break;
|
||||
if (uLightType[i] == 0)
|
||||
pointLight(i, Position, Normal, Ambient, Diffuse, vSpecularColor);
|
||||
}
|
||||
|
||||
for (int i = 0; i < int(MAX_LIGHTS); i++)
|
||||
{
|
||||
if( i >= uLightCount )
|
||||
break;
|
||||
if (uLightType[i] == 1)
|
||||
spotLight(i, Position, Normal, Ambient, Diffuse, vSpecularColor);
|
||||
}
|
||||
|
||||
for (int i = 0; i < int(MAX_LIGHTS); i++)
|
||||
{
|
||||
if( i >= uLightCount )
|
||||
break;
|
||||
if (uLightType[i] == 2)
|
||||
dirLight(i, Position, Normal, Ambient, Diffuse, vSpecularColor);
|
||||
}
|
||||
|
||||
vec4 LightColor = Ambient * uMaterialAmbient + Diffuse * uMaterialDiffuse;
|
||||
LightColor = clamp(LightColor, 0.0, 1.0);
|
||||
LightColor.w = 1.0;
|
||||
|
||||
vVertexColor *= LightColor;
|
||||
vVertexColor += uMaterialEmissive;
|
||||
vVertexColor += uGlobalAmbient * uMaterialAmbient;
|
||||
vVertexColor = clamp(vVertexColor, 0.0, 1.0);
|
||||
|
||||
vSpecularColor *= uMaterialSpecular;
|
||||
}
|
||||
|
||||
vFogCoord = length(Position);
|
||||
}
|
69
media/Shaders/COGLES2TransparentAlphaChannel.fsh
Normal file
@ -0,0 +1,69 @@
|
||||
precision mediump float;
|
||||
|
||||
/* Uniforms */
|
||||
|
||||
uniform float uAlphaRef;
|
||||
uniform int uTextureUsage0;
|
||||
uniform sampler2D uTextureUnit0;
|
||||
uniform int uFogEnable;
|
||||
uniform int uFogType;
|
||||
uniform vec4 uFogColor;
|
||||
uniform float uFogStart;
|
||||
uniform float uFogEnd;
|
||||
uniform float uFogDensity;
|
||||
|
||||
/* Varyings */
|
||||
|
||||
varying vec2 vTextureCoord0;
|
||||
varying vec4 vVertexColor;
|
||||
varying vec4 vSpecularColor;
|
||||
varying float vFogCoord;
|
||||
|
||||
float computeFog()
|
||||
{
|
||||
const float LOG2 = 1.442695;
|
||||
float FogFactor = 0.0;
|
||||
|
||||
if (uFogType == 0) // Exp
|
||||
{
|
||||
FogFactor = exp2(-uFogDensity * vFogCoord * LOG2);
|
||||
}
|
||||
else if (uFogType == 1) // Linear
|
||||
{
|
||||
float Scale = 1.0 / (uFogEnd - uFogStart);
|
||||
FogFactor = (uFogEnd - vFogCoord) * Scale;
|
||||
}
|
||||
else if (uFogType == 2) // Exp2
|
||||
{
|
||||
FogFactor = exp2(-uFogDensity * uFogDensity * vFogCoord * vFogCoord * LOG2);
|
||||
}
|
||||
|
||||
FogFactor = clamp(FogFactor, 0.0, 1.0);
|
||||
|
||||
return FogFactor;
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 Color = vVertexColor;
|
||||
|
||||
if (bool(uTextureUsage0))
|
||||
{
|
||||
Color *= texture2D(uTextureUnit0, vTextureCoord0);
|
||||
|
||||
// TODO: uAlphaRef should rather control sharpness of alpha, don't know how to do that right now and this works in most cases.
|
||||
if (Color.a < uAlphaRef)
|
||||
discard;
|
||||
}
|
||||
Color += vSpecularColor;
|
||||
|
||||
if (bool(uFogEnable))
|
||||
{
|
||||
float FogFactor = computeFog();
|
||||
vec4 FogColor = uFogColor;
|
||||
FogColor.a = 1.0;
|
||||
Color = mix(FogColor, Color, FogFactor);
|
||||
}
|
||||
|
||||
gl_FragColor = Color;
|
||||
}
|
67
media/Shaders/COGLES2TransparentAlphaChannelRef.fsh
Normal file
@ -0,0 +1,67 @@
|
||||
precision mediump float;
|
||||
|
||||
/* Uniforms */
|
||||
|
||||
uniform float uAlphaRef;
|
||||
uniform int uTextureUsage0;
|
||||
uniform sampler2D uTextureUnit0;
|
||||
uniform int uFogEnable;
|
||||
uniform int uFogType;
|
||||
uniform vec4 uFogColor;
|
||||
uniform float uFogStart;
|
||||
uniform float uFogEnd;
|
||||
uniform float uFogDensity;
|
||||
|
||||
/* Varyings */
|
||||
|
||||
varying vec2 vTextureCoord0;
|
||||
varying vec4 vVertexColor;
|
||||
varying vec4 vSpecularColor;
|
||||
varying float vFogCoord;
|
||||
|
||||
float computeFog()
|
||||
{
|
||||
const float LOG2 = 1.442695;
|
||||
float FogFactor = 0.0;
|
||||
|
||||
if (uFogType == 0) // Exp
|
||||
{
|
||||
FogFactor = exp2(-uFogDensity * vFogCoord * LOG2);
|
||||
}
|
||||
else if (uFogType == 1) // Linear
|
||||
{
|
||||
float Scale = 1.0 / (uFogEnd - uFogStart);
|
||||
FogFactor = (uFogEnd - vFogCoord) * Scale;
|
||||
}
|
||||
else if (uFogType == 2) // Exp2
|
||||
{
|
||||
FogFactor = exp2(-uFogDensity * uFogDensity * vFogCoord * vFogCoord * LOG2);
|
||||
}
|
||||
|
||||
FogFactor = clamp(FogFactor, 0.0, 1.0);
|
||||
|
||||
return FogFactor;
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 Color = vVertexColor;
|
||||
|
||||
if (bool(uTextureUsage0))
|
||||
Color *= texture2D(uTextureUnit0, vTextureCoord0);
|
||||
|
||||
if (Color.a < uAlphaRef)
|
||||
discard;
|
||||
|
||||
Color += vSpecularColor;
|
||||
|
||||
if (bool(uFogEnable))
|
||||
{
|
||||
float FogFactor = computeFog();
|
||||
vec4 FogColor = uFogColor;
|
||||
FogColor.a = 1.0;
|
||||
Color = mix(FogColor, Color, FogFactor);
|
||||
}
|
||||
|
||||
gl_FragColor = Color;
|
||||
}
|
62
media/Shaders/COGLES2TransparentVertexAlpha.fsh
Normal file
@ -0,0 +1,62 @@
|
||||
precision mediump float;
|
||||
|
||||
/* Uniforms */
|
||||
|
||||
uniform int uTextureUsage0;
|
||||
uniform sampler2D uTextureUnit0;
|
||||
uniform int uFogEnable;
|
||||
uniform int uFogType;
|
||||
uniform vec4 uFogColor;
|
||||
uniform float uFogStart;
|
||||
uniform float uFogEnd;
|
||||
uniform float uFogDensity;
|
||||
|
||||
/* Varyings */
|
||||
|
||||
varying vec2 vTextureCoord0;
|
||||
varying vec4 vVertexColor;
|
||||
varying vec4 vSpecularColor;
|
||||
varying float vFogCoord;
|
||||
|
||||
float computeFog()
|
||||
{
|
||||
const float LOG2 = 1.442695;
|
||||
float FogFactor = 0.0;
|
||||
|
||||
if (uFogType == 0) // Exp
|
||||
{
|
||||
FogFactor = exp2(-uFogDensity * vFogCoord * LOG2);
|
||||
}
|
||||
else if (uFogType == 1) // Linear
|
||||
{
|
||||
float Scale = 1.0 / (uFogEnd - uFogStart);
|
||||
FogFactor = (uFogEnd - vFogCoord) * Scale;
|
||||
}
|
||||
else if (uFogType == 2) // Exp2
|
||||
{
|
||||
FogFactor = exp2(-uFogDensity * uFogDensity * vFogCoord * vFogCoord * LOG2);
|
||||
}
|
||||
|
||||
FogFactor = clamp(FogFactor, 0.0, 1.0);
|
||||
|
||||
return FogFactor;
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 Color = vVertexColor;
|
||||
|
||||
if (bool(uTextureUsage0))
|
||||
Color *= texture2D(uTextureUnit0, vTextureCoord0);
|
||||
Color += vSpecularColor;
|
||||
|
||||
if (bool(uFogEnable))
|
||||
{
|
||||
float FogFactor = computeFog();
|
||||
vec4 FogColor = uFogColor;
|
||||
FogColor.a = 1.0;
|
||||
Color = mix(FogColor, Color, FogFactor);
|
||||
}
|
||||
|
||||
gl_FragColor = Color;
|
||||
}
|
BIN
media/axe.jpg
Normal file
After Width: | Height: | Size: 64 KiB |
BIN
media/ball.wav
Normal file
BIN
media/bigfont.png
Normal file
After Width: | Height: | Size: 21 KiB |
BIN
media/burninglogo.png
Normal file
After Width: | Height: | Size: 14 KiB |
29
media/config.xml
Normal file
@ -0,0 +1,29 @@
|
||||
<?xml version="1.0"?>
|
||||
<config>
|
||||
<!--This is a config file for the Irrlicht Engine Mesh Viewer.-->
|
||||
<startUpModel file="dwarf.x" />
|
||||
<messageText caption="Irrlicht Engine Mesh Viewer">Welcome to the Mesh Viewer of the "Irrlicht Engine"!.
|
||||
This program is able to load and display all 3D geometry and models the Irrlicht Engine can.
|
||||
Controls: Left mouse to rotate, right mouse to move, both buttons to zoom. Escape to Stop FPS Camera
|
||||
|
||||
Supported formats are:
|
||||
- Irrlicht scene and mesh formats (.irr, .irrmesh, .xml)
|
||||
- 3D Studio (.3ds)
|
||||
- Blitz3D (.b3d)
|
||||
- COLLADA 1.2/1.3 (.dae, .xml)
|
||||
- Cartography shop 4 (.csm)
|
||||
- DirectX (.x)
|
||||
- DeleD (.dmf)
|
||||
- Maya (.obj)
|
||||
- Milkshape (.ms3d)
|
||||
- My3D (.my3D)
|
||||
- OCT (.oct)
|
||||
- Ogre3d (.mesh)
|
||||
- Pulsar LMTools (.lmts)
|
||||
- Quake 3 levels (.bsp)
|
||||
- Quake 2 models (.md2)
|
||||
- Stanford Triangle (.ply)
|
||||
- Stereolithography format (.stl)
|
||||
|
||||
</messageText>
|
||||
</config>
|
12
media/cubeMapReflection.frag
Normal file
@ -0,0 +1,12 @@
|
||||
uniform samplerCube cubeTex;
|
||||
uniform float Roughness;
|
||||
|
||||
void main( void )
|
||||
{
|
||||
// gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
|
||||
vec3 uvw = vec3(gl_TexCoord[0]);
|
||||
//gl_FragColor = textureCube( cubeTex, uvw );
|
||||
gl_FragColor = textureLod( cubeTex, uvw, Roughness );
|
||||
//gl_FragColor = textureCube( cubeTex, uvw, Roughness );
|
||||
}
|
||||
|
27
media/cubeMapReflection.vert
Normal file
@ -0,0 +1,27 @@
|
||||
uniform int StyleUVW ; // 0 = specular reflection, 1 = diffuse reflection, 2 = use model vertex coordinates for uvw.
|
||||
uniform vec3 CameraPos;
|
||||
uniform mat4 World;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
gl_Position = ftransform(); // same as gl_ModelViewProjectionMatrix * gl_Vertex;
|
||||
|
||||
// compute the reflection vector, and assign it to texcoord 0
|
||||
if ( StyleUVW == 0 )
|
||||
{
|
||||
vec4 worldPos = World*gl_Vertex;
|
||||
vec3 viewNormal = normalize(worldPos.xyz - CameraPos); // view vector
|
||||
|
||||
gl_TexCoord[0] = vec4( reflect( viewNormal, normalize(gl_Normal) ), 1.0 );
|
||||
}
|
||||
else if ( StyleUVW == 1 )
|
||||
{
|
||||
// just use the normal for the reflection vector
|
||||
gl_TexCoord[0] = vec4(normalize(gl_Normal), 1.0);
|
||||
}
|
||||
else if ( StyleUVW == 2 )
|
||||
{
|
||||
// use vertex-coordinates for texture coordinates
|
||||
gl_TexCoord[0] = normalize(gl_Vertex);
|
||||
}
|
||||
}
|
10
media/cubeMapReflectionPS.hlsl
Normal file
@ -0,0 +1,10 @@
|
||||
sampler cubeTex: register(s0);
|
||||
float Roughness;
|
||||
|
||||
float4 PS( float4 uvwTex : TEXCOORD0 ) : COLOR
|
||||
{
|
||||
uvwTex.w = Roughness;
|
||||
//return texCUBEbias( cubeTex, uvwTex);
|
||||
return texCUBElod( cubeTex, uvwTex);
|
||||
//return texCUBE( cubeTex, uvwTex);
|
||||
}
|
38
media/cubeMapReflectionVS.hlsl
Normal file
@ -0,0 +1,38 @@
|
||||
int StyleUVW ; // 0 = specular reflection, 1 = diffuse reflection, 2 = use model vertex coordinates for uvw.
|
||||
float4x4 WorldViewProj;
|
||||
float4x4 World;
|
||||
float3 CameraPos;
|
||||
|
||||
// Vertex Shader
|
||||
void VS(
|
||||
in float4 VPos : POSITION,
|
||||
in float3 VNorm : NORMAL,
|
||||
in float3 VTex : TEXCOORD0,
|
||||
out float4 outPos : POSITION,
|
||||
out float4 outTex : TEXCOORD0 )
|
||||
{
|
||||
// vertex position from model-space to view-space
|
||||
outPos = mul( VPos, WorldViewProj );
|
||||
|
||||
if ( StyleUVW == 0 )
|
||||
{
|
||||
// create ray from camera position to the vertex, in world space
|
||||
float4 worldPos = mul(float4(VPos.x, VPos.y, VPos.z, 1.0), World);
|
||||
float3 view = CameraPos - worldPos.xyz;
|
||||
|
||||
float4 normWorld = normalize(mul(float4(VNorm.x, VNorm.y, VNorm.z, 0.0), World)); // TODO: when objects are scaled non-uniform we need to multiply by WorldInverseTranspose instead
|
||||
|
||||
// compute the reflection vector, and assign it to texcoord 0
|
||||
outTex.xyz = reflect( -normalize(view), normWorld.xyz );
|
||||
}
|
||||
else if ( StyleUVW == 1 )
|
||||
{
|
||||
// just use the normal for the reflection vector
|
||||
outTex.xyz = normalize(VNorm);
|
||||
}
|
||||
else if ( StyleUVW == 2 )
|
||||
{
|
||||
// use vertex-coordinates for texture coordinates
|
||||
outTex.xyz = VPos.xyz;
|
||||
}
|
||||
}
|
18
media/cubemap_license.txt
Normal file
@ -0,0 +1,18 @@
|
||||
License for the cubemap_*.jpg files in this folder.
|
||||
|
||||
Author
|
||||
======
|
||||
|
||||
This is the work of Emil Persson, aka Humus.
|
||||
http://www.humus.name
|
||||
|
||||
License
|
||||
=======
|
||||
|
||||
This work is licensed under a Creative Commons Attribution 3.0 Unported License.
|
||||
http://creativecommons.org/licenses/by/3.0/
|
||||
|
||||
|
||||
Changes
|
||||
=======
|
||||
For the Irrlicht engine we downscaled the images to 512x512. Get the full 2048x2048 resolution at http://www.humus.name
|
BIN
media/cubemap_negx.jpg
Normal file
After Width: | Height: | Size: 130 KiB |
BIN
media/cubemap_negy.jpg
Normal file
After Width: | Height: | Size: 108 KiB |
BIN
media/cubemap_negz.jpg
Normal file
After Width: | Height: | Size: 111 KiB |
BIN
media/cubemap_posx.jpg
Normal file
After Width: | Height: | Size: 128 KiB |
BIN
media/cubemap_posy.jpg
Normal file
After Width: | Height: | Size: 64 KiB |
BIN
media/cubemap_posz.jpg
Normal file
After Width: | Height: | Size: 102 KiB |
84
media/d3d9.hlsl
Normal file
@ -0,0 +1,84 @@
|
||||
// Part of the Irrlicht Engine Shader example.
|
||||
// These simple Direct3D9 pixel and vertex shaders will be loaded by the shaders
|
||||
// example. Please note that these example shaders don't do anything really useful.
|
||||
// They only demonstrate that shaders can be used in Irrlicht.
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Global variables
|
||||
//-----------------------------------------------------------------------------
|
||||
float4x4 mWorldViewProj; // World * View * Projection transformation
|
||||
float4x4 mInvWorld; // Inverted world matrix
|
||||
float4x4 mTransWorld; // Transposed world matrix
|
||||
float3 mLightPos; // Light position (actually just camera-pos in this case)
|
||||
float4 mLightColor; // Light color
|
||||
|
||||
|
||||
// Vertex shader output structure
|
||||
struct VS_OUTPUT
|
||||
{
|
||||
float4 Position : POSITION; // vertex position
|
||||
float4 Diffuse : COLOR0; // vertex diffuse color
|
||||
float2 TexCoord : TEXCOORD0; // tex coords
|
||||
};
|
||||
|
||||
|
||||
VS_OUTPUT vertexMain(in float4 vPosition : POSITION,
|
||||
in float3 vNormal : NORMAL,
|
||||
float2 texCoord : TEXCOORD0 )
|
||||
{
|
||||
VS_OUTPUT Output;
|
||||
|
||||
// transform position to clip space
|
||||
Output.Position = mul(vPosition, mWorldViewProj);
|
||||
|
||||
// transform normal somehow (NOTE: for the real vertex normal you would use an inverse-transpose world matrix instead of mInvWorld)
|
||||
float3 normal = mul(float4(vNormal,0.0), mInvWorld);
|
||||
|
||||
// renormalize normal
|
||||
normal = normalize(normal);
|
||||
|
||||
// position in world coordinates (NOTE: not sure why transposed world is used instead of world?)
|
||||
float3 worldpos = mul(mTransWorld, vPosition);
|
||||
|
||||
// calculate light vector, vtxpos - lightpos
|
||||
float3 lightVector = worldpos - mLightPos;
|
||||
|
||||
// normalize light vector
|
||||
lightVector = normalize(lightVector);
|
||||
|
||||
// calculate light color
|
||||
float3 tmp = dot(-lightVector, normal);
|
||||
tmp = lit(tmp.x, tmp.y, 1.0);
|
||||
|
||||
tmp = mLightColor * tmp.y;
|
||||
Output.Diffuse = float4(tmp.x, tmp.y, tmp.z, 0);
|
||||
Output.TexCoord = texCoord;
|
||||
|
||||
return Output;
|
||||
}
|
||||
|
||||
|
||||
// Pixel shader output structure
|
||||
struct PS_OUTPUT
|
||||
{
|
||||
float4 RGBColor : COLOR0; // Pixel color
|
||||
};
|
||||
|
||||
|
||||
sampler2D myTexture;
|
||||
|
||||
PS_OUTPUT pixelMain(float2 TexCoord : TEXCOORD0,
|
||||
float4 Position : POSITION,
|
||||
float4 Diffuse : COLOR0 )
|
||||
{
|
||||
PS_OUTPUT Output;
|
||||
|
||||
float4 col = tex2D( myTexture, TexCoord ); // sample color map
|
||||
|
||||
// multiply with diffuse and do other senseless operations
|
||||
Output.RGBColor = Diffuse * col;
|
||||
Output.RGBColor *= 4.0;
|
||||
|
||||
return Output;
|
||||
}
|
||||
|
11
media/d3d9.psh
Normal file
@ -0,0 +1,11 @@
|
||||
; part of the Irrlicht Engine Shader example.
|
||||
; This simple Direct3D9 pixel shader will be loaded by the engine.
|
||||
; Please note that these example shaders don't do anything really useful.
|
||||
; They only demonstrate that shaders can be used in Irrlicht.
|
||||
|
||||
ps.1.1
|
||||
|
||||
tex t0 ; sample color map
|
||||
add r0, v0, v0 ; mulitply with color
|
||||
mul t0, t0, r0 ; mulitply with color
|
||||
add r0, t0, t0 ; make it brighter and store result
|
42
media/d3d9.vsh
Normal file
@ -0,0 +1,42 @@
|
||||
; part of the Irrlicht Engine Shader example.
|
||||
; This Direct3D9 vertex shader will be loaded by the engine.
|
||||
; Please note that these example shaders don't do anything really useful.
|
||||
; They only demonstrate that shaders can be used in Irrlicht.
|
||||
|
||||
vs.1.1
|
||||
|
||||
dcl_position v0; ; declare position
|
||||
dcl_normal v1; ; declare normal
|
||||
dcl_color v2; ; declare color
|
||||
dcl_texcoord0 v3; ; declare texture coordinate
|
||||
|
||||
; transpose and transform position to clip space
|
||||
mul r0, v0.x, c4
|
||||
mad r0, v0.y, c5, r0
|
||||
mad r0, v0.z, c6, r0
|
||||
add oPos, c7, r0
|
||||
|
||||
; transform normal
|
||||
dp3 r1.x, v1, c0
|
||||
dp3 r1.y, v1, c1
|
||||
dp3 r1.z, v1, c2
|
||||
|
||||
; renormalize normal
|
||||
dp3 r1.w, r1, r1
|
||||
rsq r1.w, r1.w
|
||||
mul r1, r1, r1.w
|
||||
|
||||
; calculate light vector
|
||||
m4x4 r6, v0, c10 ; vertex into world position
|
||||
add r2, c8, -r6 ; vtxpos - lightpos
|
||||
|
||||
; normalize light vector
|
||||
dp3 r2.w, r2, r2
|
||||
rsq r2.w, r2.w
|
||||
mul r2, r2, r2.w
|
||||
|
||||
; calculate light color
|
||||
dp3 r3, r1, r2 ; dp3 with negative light vector
|
||||
lit r5, r3 ; clamp to zero if r3 < 0, r5 has diffuce component in r5.y
|
||||
mul oD0, r5.y, c9 ; ouput diffuse color
|
||||
mov oT0, v3 ; store texture coordinates
|
BIN
media/demoback.jpg
Normal file
After Width: | Height: | Size: 95 KiB |
BIN
media/detailmap3.jpg
Normal file
After Width: | Height: | Size: 90 KiB |
BIN
media/directxlogo.png
Normal file
After Width: | Height: | Size: 9.7 KiB |
BIN
media/dotnetback.jpg
Normal file
After Width: | Height: | Size: 48 KiB |
51
media/dwarf-Read-Me.txt
Normal file
@ -0,0 +1,51 @@
|
||||
Dwarf lowpoly model Pack
|
||||
Copyright 2004, Psionic Design
|
||||
e-mail: psionic@blueyonder.co.uk
|
||||
|
||||
|
||||
|
||||
INSTALLATION INSTRUCTIONS:
|
||||
|
||||
To install, simply unzip to your hard drive with the "Use Folder Names" option turned on. And that's it you're ready to go!
|
||||
|
||||
|
||||
|
||||
USAGE INFORMATION:
|
||||
|
||||
Each zip contains the models, textures and animation info for that particular format!
|
||||
|
||||
Please Read the "animationinfo.txt" file included in each zip for the exact frames of animation to use
|
||||
|
||||
Credits to me "Psionic" are really appreciated but are not essential ;-)
|
||||
|
||||
Any questions, screenshots of him in use etc drop by my site or email me at:-
|
||||
|
||||
website: http://www.psionic3d.co.uk
|
||||
email: psionic@blueyonder.co.uk
|
||||
|
||||
|
||||
|
||||
|
||||
WHAT'S INCLUDED IN THE ZIP:
|
||||
|
||||
ReadMe.txt - This file
|
||||
b3d.zip - Blitz 3D Format models and textures
|
||||
ms3d.zip - Milkshape 3D Format models and textures
|
||||
x.zip - DarkBasic Direct X 8 Format models and textures
|
||||
|
||||
|
||||
|
||||
RESTRICTIONS:
|
||||
|
||||
This model pack is available for use in freeware, shareware, commercial games/software with the following restrictions:-
|
||||
|
||||
**You may not sell/re-sell this model pack or claim it as your own.
|
||||
***You may not redistribute this pack in some other model pack through a website or on a compilation CD of any kind, without my written consent.
|
||||
|
||||
|
||||
Psi
|
||||
http://www.psionic3d.co.uk
|
||||
|
||||
|
||||
|
||||
|
BIN
media/dwarf.jpg
Normal file
After Width: | Height: | Size: 82 KiB |
18468
media/dwarf.x
Normal file
BIN
media/earth.jpg
Normal file
After Width: | Height: | Size: 24 KiB |
20711
media/earth.x
Normal file
BIN
media/earthbump.jpg
Normal file
After Width: | Height: | Size: 24 KiB |
BIN
media/enano.jpg
Normal file
After Width: | Height: | Size: 19 KiB |
BIN
media/example.irr
Normal file
BIN
media/example_screenshots/001shot.jpg
Normal file
After Width: | Height: | Size: 6.0 KiB |
BIN
media/example_screenshots/002shot.jpg
Normal file
After Width: | Height: | Size: 19 KiB |
BIN
media/example_screenshots/003shot.jpg
Normal file
After Width: | Height: | Size: 5.8 KiB |
BIN
media/example_screenshots/004shot.jpg
Normal file
After Width: | Height: | Size: 7.9 KiB |
BIN
media/example_screenshots/005shot.jpg
Normal file
After Width: | Height: | Size: 11 KiB |
BIN
media/example_screenshots/006shot.jpg
Normal file
After Width: | Height: | Size: 10 KiB |
BIN
media/example_screenshots/007shot.jpg
Normal file
After Width: | Height: | Size: 24 KiB |
BIN
media/example_screenshots/008shot.jpg
Normal file
After Width: | Height: | Size: 26 KiB |
BIN
media/example_screenshots/009shot.jpg
Normal file
After Width: | Height: | Size: 20 KiB |
BIN
media/example_screenshots/010shot.jpg
Normal file
After Width: | Height: | Size: 18 KiB |
BIN
media/example_screenshots/011shot.jpg
Normal file
After Width: | Height: | Size: 19 KiB |
BIN
media/example_screenshots/012shot.jpg
Normal file
After Width: | Height: | Size: 20 KiB |
BIN
media/example_screenshots/013shot.jpg
Normal file
After Width: | Height: | Size: 8.6 KiB |
BIN
media/example_screenshots/014shot.jpg
Normal file
After Width: | Height: | Size: 20 KiB |
BIN
media/example_screenshots/015shot.jpg
Normal file
After Width: | Height: | Size: 21 KiB |
BIN
media/example_screenshots/016shot.jpg
Normal file
After Width: | Height: | Size: 12 KiB |
BIN
media/example_screenshots/017shot.jpg
Normal file
After Width: | Height: | Size: 8.8 KiB |
BIN
media/example_screenshots/018shot.jpg
Normal file
After Width: | Height: | Size: 26 KiB |
BIN
media/example_screenshots/019shot.jpg
Normal file
After Width: | Height: | Size: 4.4 KiB |
BIN
media/example_screenshots/020shot.jpg
Normal file
After Width: | Height: | Size: 11 KiB |
BIN
media/example_screenshots/021shot.jpg
Normal file
After Width: | Height: | Size: 24 KiB |
BIN
media/example_screenshots/022shot.jpg
Normal file
After Width: | Height: | Size: 15 KiB |
BIN
media/example_screenshots/023shot.jpg
Normal file
After Width: | Height: | Size: 12 KiB |
BIN
media/example_screenshots/024shot.jpg
Normal file
After Width: | Height: | Size: 16 KiB |
BIN
media/example_screenshots/025shot.jpg
Normal file
After Width: | Height: | Size: 9.1 KiB |
BIN
media/example_screenshots/026shot.jpg
Normal file
After Width: | Height: | Size: 11 KiB |
BIN
media/example_screenshots/027shot.jpg
Normal file
After Width: | Height: | Size: 18 KiB |
BIN
media/example_screenshots/028shot.jpg
Normal file
After Width: | Height: | Size: 25 KiB |
BIN
media/faerie.md2
Normal file
BIN
media/faerie2.bmp
Normal file
After Width: | Height: | Size: 42 KiB |
BIN
media/fire.bmp
Normal file
After Width: | Height: | Size: 24 KiB |
BIN
media/fireball.bmp
Normal file
After Width: | Height: | Size: 5.1 KiB |
BIN
media/fontcourier.bmp
Normal file
After Width: | Height: | Size: 192 KiB |
BIN
media/fonthaettenschweiler.bmp
Normal file
After Width: | Height: | Size: 192 KiB |
BIN
media/fontlucida.png
Normal file
After Width: | Height: | Size: 19 KiB |
BIN
media/gun.jpg
Normal file
After Width: | Height: | Size: 25 KiB |
BIN
media/gun.md2
Normal file
BIN
media/help.png
Normal file
After Width: | Height: | Size: 881 B |
BIN
media/icon_crosshairs16x16bw1.png
Normal file
After Width: | Height: | Size: 203 B |
BIN
media/icon_crosshairs16x16bw2.png
Normal file
After Width: | Height: | Size: 192 B |
BIN
media/icon_crosshairs16x16bw3.png
Normal file
After Width: | Height: | Size: 208 B |
BIN
media/icon_crosshairs16x16col.png
Normal file
After Width: | Height: | Size: 560 B |
BIN
media/iconlist.png
Normal file
After Width: | Height: | Size: 30 KiB |