76 lines
1.7 KiB
GLSL
76 lines
1.7 KiB
GLSL
#version 300 es
|
|
uniform int u_type;
|
|
uniform mat4 u_mvMatrix;
|
|
uniform mat4 u_projMatrix;
|
|
uniform vec4 u_light_dir;
|
|
uniform int u_cmd;
|
|
uniform float u_time;
|
|
uniform float u_shadow_offset;
|
|
in vec4 pos;
|
|
in vec2 tex;
|
|
in vec4 nor;
|
|
out float _type;
|
|
out float _flag;
|
|
out float _cmd;
|
|
out float _off;
|
|
out float _time;
|
|
out vec2 _tex;
|
|
out vec3 _nor;
|
|
out vec3 _v1;
|
|
out vec3 _v2;
|
|
out vec4 _back;
|
|
void main()
|
|
{
|
|
_type = float(u_type % 100);
|
|
_flag = float(u_type / 100);
|
|
vec4 p = pos;
|
|
_tex = tex;
|
|
_nor = nor.xzy;
|
|
_cmd = float(u_cmd);
|
|
_time = u_time;
|
|
if (_cmd == 0.0)
|
|
_off = 0.0;
|
|
else if (abs(_cmd) < 3.0)
|
|
_off = pos.x/500.0 + 0.5;
|
|
else
|
|
_off = pos.y/1000.0 + 0.5;
|
|
if (_type > 0.0 && _type < 10.0)
|
|
{
|
|
if (_flag < 10.0)
|
|
{
|
|
mat4 m = u_projMatrix * u_mvMatrix;
|
|
float dk = (2.0 - 0.1*pow((5.0-_flag),2.0)) * u_shadow_offset;
|
|
float dx = 0.05 * (_type==1.0 ? dk/4.0 : dk);
|
|
float dz = -0.20 * dk * length(m[0].xyz)*110.0;
|
|
p *= vec4(1.0+dx,1,1,1);
|
|
p = m * p;
|
|
p += vec4(0,dz,8,0);
|
|
gl_Position = p;
|
|
}
|
|
else
|
|
{
|
|
if (_type == 1.0)
|
|
{
|
|
_back = vec4(0.2,0.2,0.2,1);
|
|
if (pos.z > 180.0 && pos.z < 250.0)
|
|
{
|
|
if (_flag == 40.0)
|
|
_back = vec4(1,0,0,1);
|
|
else if (_flag == 50.0 || _flag == 20.0 && pos.x < -50.0 || _flag == 30.0 && pos.x > 50.0)
|
|
_back = vec4(1,1,0,1);
|
|
}
|
|
}
|
|
_v1 = vec3(u_light_dir.x, -u_light_dir.y, 0);
|
|
_v1 = (u_mvMatrix * vec4(_v1,0)).xyz;
|
|
_v1.y = length(_v1) * -1.2;
|
|
_v2 = (u_mvMatrix * vec4(0,-1,_type==1.0?-0.5:-0.25, 0)).xyz;
|
|
gl_Position = u_projMatrix * u_mvMatrix * p;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (_type == 10.0 && _flag > 0.0)
|
|
p.x *= _flag / 100.0;
|
|
gl_Position = u_projMatrix * u_mvMatrix * p;
|
|
}
|
|
} |