Commit b6e7321f authored by cvet's avatar cvet

Added core resources for launch game.

git-svn-id: https://xp-dev.com/svn/fonline_sdk@765 71b6ff52-6597-447a-9a87-58edf7a03249
parent 852ebcf7
#version 110
#ifdef VERTEX_SHADER
uniform mat4 ProjectionMatrix;
attribute vec2 InPosition;
attribute vec4 InColor;
attribute vec2 InTexCoord;
attribute vec2 InTexEggCoord;
varying vec4 Color;
varying vec2 TexCoord;
varying vec2 TexEggCoord;
void main( void )
{
gl_Position = ProjectionMatrix * vec4( InPosition, 0.0, 1.0 );
Color = InColor;
TexCoord = InTexCoord;
TexEggCoord = InTexEggCoord;
}
#endif
#ifdef FRAGMENT_SHADER
uniform sampler2D ColorMap;
uniform sampler2D EggMap;
varying vec4 Color;
varying vec2 TexCoord;
varying vec2 TexEggCoord;
void main( void )
{
vec4 texColor = texture2D( ColorMap, TexCoord );
gl_FragColor.rgb = ( texColor.rgb * Color.rgb ) * 2.0;
gl_FragColor.a = texColor.a * Color.a;
if( TexEggCoord.x >= 0.0 )
gl_FragColor.a *= texture2D( EggMap, TexEggCoord ).a;
}
#endif
#version 110
#ifdef VERTEX_SHADER
uniform mat4 ProjectionMatrix;
attribute vec2 InPosition;
attribute vec4 InColor;
attribute vec2 InTexCoord;
varying vec4 Color;
varying vec2 TexCoord;
void main( void )
{
gl_Position = ProjectionMatrix * vec4( InPosition, 0.0, 1.0 );
Color = InColor;
TexCoord = InTexCoord;
}
#endif
#ifdef FRAGMENT_SHADER
uniform sampler2D ColorMap;
varying vec4 Color;
varying vec2 TexCoord;
void main( void )
{
vec4 texColor = texture2D( ColorMap, TexCoord );
gl_FragColor.rgb = ( texColor.rgb * Color.rgb ) * 2.0;
gl_FragColor.a = texColor.a * Color.a;
}
#endif
Effect Passes 2
Effect Pass 0 Shadow
#version 110
#ifdef PASS1
#ifdef VERTEX_SHADER
uniform mat4 ProjectionMatrix;
uniform mat4 WorldMatrices[ MAX_BONES ];
uniform vec4 Texture1AtlasOffset;
const vec3 LightDir = vec3( 0.0, 0.0, 1.0 );
attribute vec3 InPosition;
attribute vec3 InNormal;
attribute vec2 InTexCoord;
attribute vec2 InTexCoordBase;
attribute vec3 InTangent;
attribute vec3 InBinormal;
attribute vec4 InBlendWeights;
attribute vec4 InBlendIndices;
varying vec2 TexCoord;
varying vec2 TexCoord2;
varying vec3 LightVec;
void main( void )
{
// Skinning
vec4 weights = InBlendWeights;
vec4 indices = InBlendIndices;
vec4 position = vec4( 0.0 );
vec3 normal = vec3( 0.0 );
vec3 tangent = vec3( 0.0 );
vec3 binormal = vec3( 0.0 );
for( int i = 0; i < 4; i++ )
{
mat4 m44 = WorldMatrices[ int( indices.x ) ];
mat3 m33 = mat3( m44[ 0 ].xyz, m44[ 1 ].xyz, m44[ 2 ].xyz );
float w = weights.x;
position += m44 * vec4( InPosition, 1.0 ) * w;
normal += m33 * InNormal * w;
tangent += m33 * InTangent * w;
binormal += m33 * InBinormal * w;
weights = weights.yzwx;
indices = indices.yzwx;
}
// Position
gl_Position = ProjectionMatrix * position;
// Normalization
normal = normalize( normal );
tangent = normalize( tangent );
binormal = normalize( binormal );
// Tangent space
LightVec.x = dot(LightDir, tangent);
LightVec.y = dot(LightDir, binormal);
LightVec.z = dot(LightDir, normal);
LightVec = normalize(LightVec);
// Pass to fragment shader
TexCoord = InTexCoord;
TexCoord2.x = ( InTexCoordBase.x * Texture1AtlasOffset.z ) + Texture1AtlasOffset.x;
TexCoord2.y = ( InTexCoordBase.y * Texture1AtlasOffset.w ) + Texture1AtlasOffset.y;
}
#endif
#ifdef FRAGMENT_SHADER
uniform sampler2D ColorMap;
uniform sampler2D Texture1;
const vec3 AmbientColor = vec3( 0.0, 0.0, 0.0 );
varying vec2 TexCoord;
varying vec2 TexCoord2;
varying vec3 LightVec;
void main( void )
{
vec3 normal = 2.0 * texture2D( Texture1, TexCoord2 ).rgb - 1.0;
normal = normalize( normal );
float lamberFactor = max( 0.0, dot( LightVec, normal ) ) ;
vec4 color;
color.rgb = AmbientColor + lamberFactor;
color.a = 1.0;
gl_FragColor = texture2D( ColorMap, TexCoord ) * color;
}
#endif
#endif // PASS1
#ifdef PASS0
#ifdef VERTEX_SHADER
uniform mat4 ProjectionMatrix;
uniform mat4 WorldMatrices[ MAX_BONES ];
uniform vec3 GroundPosition;
attribute vec3 InPosition;
attribute vec2 InTexCoord;
attribute vec4 InBlendWeights;
attribute vec4 InBlendIndices;
varying vec2 TexCoord;
const float CameraAngleCos = 0.9010770213221; // cos( 25.7 )
const float CameraAngleSin = 0.4336590845875; // sin( 25.7 )
const float ShadowAngleTan = 0.2548968037538; // tan( 14.3 )
void main( void )
{
// Skinning
vec4 weights = InBlendWeights;
vec4 indices = InBlendIndices;
vec4 position = vec4( 0.0 );
for( int i = 0; i < 4; i++ )
{
mat4 m44 = WorldMatrices[ int( indices.x ) ];
float w = weights.x;
position += m44 * vec4( InPosition, 1.0 ) * w;
weights = weights.yzwx;
indices = indices.yzwx;
}
// Calculate shadow position
float d = ( position.y - GroundPosition.y ) * CameraAngleCos;
d -= ( GroundPosition.z - position.z ) * CameraAngleSin;
position.y -= d * CameraAngleCos;
d *= ShadowAngleTan;
position.y += d * CameraAngleSin;
position.z -= 10.0;
// Position
gl_Position = ProjectionMatrix * position;
// Pass to fragment shader
TexCoord = InTexCoord;
}
#endif
#ifdef FRAGMENT_SHADER
uniform sampler2D ColorMap;
varying vec2 TexCoord;
void main( void )
{
gl_FragColor.rgb = vec3( 0.0 );
gl_FragColor.a = texture2D( ColorMap, TexCoord ).a;
}
#endif
#endif // PASS0
Effect Passes 2
Effect Pass 0 Shadow
#version 110
#ifdef PASS1
#ifdef VERTEX_SHADER
uniform mat4 ProjectionMatrix;
uniform mat4 WorldMatrices[ MAX_BONES ];
const vec3 LightDir = vec3( 0.0, 0.0, 1.0 );
const vec3 AmbientColor = vec3( 0.0, 0.0, 0.0 );
attribute vec3 InPosition;
attribute vec3 InNormal;
attribute vec2 InTexCoord;
attribute vec4 InBlendWeights;
attribute vec4 InBlendIndices;
varying vec4 Color;
varying vec2 TexCoord;
void main( void )
{
// Skinning
vec4 weights = InBlendWeights;
vec4 indices = InBlendIndices;
vec4 position = vec4( 0.0 );
vec3 normal = vec3( 0.0 );
for( int i = 0; i < 4; i++ )
{
mat4 m44 = WorldMatrices[ int( indices.x ) ];
mat3 m33 = mat3( m44[ 0 ].xyz, m44[ 1 ].xyz, m44[ 2 ].xyz );
float w = weights.x;
position += m44 * vec4( InPosition, 1.0 ) * w;
normal += m33 * InNormal * w;
weights = weights.yzwx;
indices = indices.yzwx;
}
// Position
gl_Position = ProjectionMatrix * position;
// Normal
normal = normalize( normal );
// Shade
Color.rgb = AmbientColor + max( 0.0, dot( normal, LightDir ) );
Color.a = 1.0;
// Pass to fragment shader
TexCoord = InTexCoord;
}
#endif
#ifdef FRAGMENT_SHADER
uniform sampler2D ColorMap;
varying vec4 Color;
varying vec2 TexCoord;
void main( void )
{
gl_FragColor = texture2D( ColorMap, TexCoord ) * Color;
}
#endif
#endif // PASS1
#ifdef PASS0
#ifdef VERTEX_SHADER
uniform mat4 ProjectionMatrix;
uniform mat4 WorldMatrices[ MAX_BONES ];
uniform vec3 GroundPosition;
attribute vec3 InPosition;
attribute vec2 InTexCoord;
attribute vec4 InBlendWeights;
attribute vec4 InBlendIndices;
varying vec2 TexCoord;
const float CameraAngleCos = 0.9010770213221; // cos( 25.7 )
const float CameraAngleSin = 0.4336590845875; // sin( 25.7 )
const float ShadowAngleTan = 0.2548968037538; // tan( 14.3 )
void main( void )
{
// Skinning
vec4 weights = InBlendWeights;
vec4 indices = InBlendIndices;
vec4 position = vec4( 0.0 );
for( int i = 0; i < 4; i++ )
{
mat4 m44 = WorldMatrices[ int( indices.x ) ];
float w = weights.x;
position += m44 * vec4( InPosition, 1.0 ) * w;
weights = weights.yzwx;
indices = indices.yzwx;
}
// Calculate shadow position
float d = ( position.y - GroundPosition.y ) * CameraAngleCos;
d -= ( GroundPosition.z - position.z ) * CameraAngleSin;
position.y -= d * CameraAngleCos;
d *= ShadowAngleTan;
position.y += d * CameraAngleSin;
position.z -= 10.0;
// Position
gl_Position = ProjectionMatrix * position;
// Pass to fragment shader
TexCoord = InTexCoord;
}
#endif
#ifdef FRAGMENT_SHADER
uniform sampler2D ColorMap;
varying vec2 TexCoord;
void main( void )
{
gl_FragColor.rgb = vec3( 0.0 );
gl_FragColor.a = texture2D( ColorMap, TexCoord ).a;
}
#endif
#endif // PASS0
#version 110
#ifdef VERTEX_SHADER
uniform mat4 ProjectionMatrix;
attribute vec2 InPosition;
attribute vec4 InColor;
attribute vec2 InTexCoord;
varying vec4 Color;
varying vec2 TexCoord;
void main( void )
{
gl_Position = ProjectionMatrix * vec4( InPosition, 0.0, 1.0 );
Color = InColor;
TexCoord = InTexCoord;
}
#endif
#ifdef FRAGMENT_SHADER
uniform sampler2D ColorMap;
uniform vec4 ColorMapSize;
uniform float ColorMapWidth;
uniform float ColorMapHeight;
uniform vec4 SpriteBorder;
uniform float TimeGame;
varying vec4 Color;
varying vec2 TexCoord;
vec4 border = SpriteBorder;
bool CheckPixel( float x, float y )
{
return texture2D( ColorMap, vec2( x, y ) ).a > 0.1;
}
void main( void )
{
float l = TexCoord.x - ColorMapSize.z;
float t = TexCoord.y - ColorMapSize.w;
float r = TexCoord.x + ColorMapSize.z;
float b = TexCoord.y + ColorMapSize.w;
if( border.w < border.y )
border.yw = border.wy;
bool checkPixelResult = false;
if( l < border.x )
checkPixelResult = CheckPixel( r, TexCoord.y );
else if( r > border.z )
checkPixelResult = CheckPixel( l, TexCoord.y );
else if( t < border.y )
checkPixelResult = CheckPixel( TexCoord.x, b );
else if( b > border.w )
checkPixelResult = CheckPixel( TexCoord.x, t );
else if( texture2D( ColorMap, TexCoord ).a < 0.1)
checkPixelResult = CheckPixel( l, TexCoord.y ) || CheckPixel( r, TexCoord.y ) ||
CheckPixel( TexCoord.x, t ) || CheckPixel( TexCoord.x, b );
if( checkPixelResult )
{
gl_FragColor = Color;
if( gl_FragColor.a > 0.1 )
{
float v = ( TexCoord.y - border.y ) / ( border.w - border.y );
v += 1.0 - mod( TimeGame, 2.0 );
if( v > 1.0 )
v = 2.0 - v;
else if( v < 0.0 )
v = -v;
gl_FragColor.rgb += v * 0.60 - 0.30;
gl_FragColor.rgb = clamp( gl_FragColor.rgb, 0.0, 1.0 );
}
else
{
gl_FragColor.a = 1.0;
}
}
else
{
discard;
}
}
#endif
#version 110
const float FogBlackout = 0.2;
const float AttackBlackout = 0.4;
const float AttackAroundShining = 0.4;
#ifdef VERTEX_SHADER
uniform mat4 ProjectionMatrix;
attribute vec2 InPosition;
attribute vec2 InTexCoord;
varying vec2 TexCoord;
void main( void )
{
gl_Position = ProjectionMatrix * vec4( InPosition, 0.0, 1.0 );
TexCoord = InTexCoord;
}
#endif
#ifdef FRAGMENT_SHADER
uniform sampler2D ColorMap;
varying vec2 TexCoord;
void main( void )
{
vec4 tex = texture2D( ColorMap, TexCoord );
float fog = tex.r;
float attack = tex.g;
float attackDist = tex.b;
float a = 1.0 - max( fog, FogBlackout );
if( attackDist > 0.0 )
{
a = max( attack * AttackBlackout, a );
gl_FragColor = vec4( attack - a, 0.0, 0.0, a - max( AttackAroundShining - attackDist, 0.0 ) );
}
else
{
if( a == 0.0 )
discard;
gl_FragColor = vec4( 0.0, 0.0, 0.0, a );
}
}
#endif
Effect Passes 2
Effect Pass 0 BlendFunc GL_DST_COLOR GL_ONE
Effect Pass 1 BlendFunc GL_DST_COLOR GL_ONE
#version 110
#ifdef VERTEX_SHADER
uniform mat4 ProjectionMatrix;
attribute vec2 InPosition;
attribute vec2 InTexCoord;
varying vec2 TexCoord;
void main( void )
{
gl_Position = ProjectionMatrix * vec4( InPosition, 0.0, 1.0 );
TexCoord = InTexCoord;
}
#endif
#ifdef FRAGMENT_SHADER
uniform sampler2D ColorMap;
varying vec2 TexCoord;
void main( void )
{
vec4 tex = texture2D( ColorMap, TexCoord );
if( tex.a == 0.0 )
discard;
#ifdef PASS0
gl_FragColor = vec4( tex.a, tex.a, tex.a, 1.0 );
#endif
#ifdef PASS1
gl_FragColor = vec4( tex.r, tex.g, tex.b, 1.0 );
#endif
}
#endif
#version 110
#ifdef VERTEX_SHADER
uniform mat4 ProjectionMatrix;
attribute vec2 InPosition;
attribute vec2 InTexCoord;
varying vec2 TexCoord;
void main( void )
{
gl_Position = ProjectionMatrix * vec4( InPosition, 0.0, 1.0 );
TexCoord = InTexCoord;
}
#endif
#ifdef FRAGMENT_SHADER
uniform sampler2D ColorMap;
varying vec2 TexCoord;
void main( void )
{
gl_FragColor = texture2D( ColorMap, TexCoord );
}
#endif
#version 110
#ifdef VERTEX_SHADER
uniform mat4 ProjectionMatrix;
attribute vec2 InPosition;
attribute vec2 InTexCoord;
varying vec2 TexCoord;
void main( void )
{
gl_Position = ProjectionMatrix * vec4( InPosition, 0.0, 1.0 );
TexCoord = InTexCoord;
}
#endif
#ifdef FRAGMENT_SHADER
uniform sampler2D ColorMap;
varying vec2 TexCoord;
void main( void )
{
gl_FragColor = texture2D( ColorMap, TexCoord );
gl_FragColor.rgb = vec3( ( gl_FragColor.r + gl_FragColor.g + gl_FragColor.b ) / 3.0 );
if( gl_FragColor.r < 0.2 || gl_FragColor.r > 0.9 )
gl_FragColor.r = 0.0;
else
gl_FragColor.r = 1.0;
if( gl_FragColor.g < 0.2 || gl_FragColor.g > 0.9 )
gl_FragColor.g = 0.0;
else
gl_FragColor.g = 1.0;
if( gl_FragColor.b < 0.2 || gl_FragColor.b > 0.9 )
gl_FragColor.b = 0.0;
else
gl_FragColor.b = 1.0;
}
#endif
#version 110
#ifdef VERTEX_SHADER
uniform mat4 ProjectionMatrix;