Toshihiro Shimizu 890ddd
#ifdef GL_ES
Toshihiro Shimizu 890ddd
precision mediump float;
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
uniform mat3  outputToWorld;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
uniform vec4  color;
Toshihiro Shimizu 890ddd
uniform int   blades;
Toshihiro Shimizu 890ddd
uniform float intensity;
Toshihiro Shimizu 890ddd
uniform float angle;
Toshihiro Shimizu 890ddd
uniform float bias;
Toshihiro Shimizu 890ddd
uniform float sharpness;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
float blades_ = float(blades);
Toshihiro Shimizu 890ddd
float angle_  = radians(angle);
Toshihiro Shimizu 890ddd
float bias_   = .01 * bias;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// never watch into the sun ;)
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void main( void )
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
  vec2 p = .03 * (outputToWorld * vec3(gl_FragCoord.xy, 1.0)).xy;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
  float a = atan(p.y, p.x) - angle_;
Toshihiro Shimizu 890ddd
	float blade  = intensity * clamp(pow(sin(a * blades_) + bias_, sharpness), 0.0, 1.0);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
  gl_FragColor = vec4(color.rgb * color.a, color.a);            // Premultiplication
Toshihiro Shimizu 890ddd
  gl_FragColor = gl_FragColor * (1.0 + blade) / length(p);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd