axmol/tests/cpp-tests/Resources/Sprite3DTest/simple_shadow.frag

23 lines
654 B
GLSL
Raw Normal View History

#ifdef GL_ES
2014-12-19 15:31:06 +08:00
varying mediump vec2 v_texture_coord;
varying mediump vec4 v_position;
#else
2014-12-19 15:31:06 +08:00
varying vec2 v_texture_coord;
varying vec4 v_position;
#endif
uniform sampler2D u_sampler0;
uniform sampler2D u_sampler1;
uniform vec3 u_target_pos;
uniform vec4 u_color;
void main(void)
{
2014-12-22 14:17:48 +08:00
float Radius = 4.0;//project range
vec3 UVector = vec3(1.0, 0.0, 0.0)/(2.0 * Radius);
vec3 VVector = vec3(0.0, 0.0, -1.0)/(-2.0 * Radius);
vec2 coord;
2014-12-22 14:17:48 +08:00
coord.x = dot(v_position.xyz - u_target_pos, UVector) + 0.5;
coord.y = dot(v_position.xyz - u_target_pos, VVector) + 0.5;
gl_FragColor = u_color*texture2D(u_sampler0,v_texture_coord)*texture2D(u_sampler1,coord);
}