axmol/tests/cpp-tests/Content/Shaders/example_Noisy.fsh

34 lines
867 B
Plaintext
Raw Normal View History

// Shader taken from: http://webglsamples.googlecode.com/hg/electricflower/electricflower.html
#ifdef GL_ES
precision mediump float;
#endif
varying vec4 v_fragmentColor;
varying vec2 v_texCoord;
uniform vec2 resolution;
2022-07-04 21:26:48 +08:00
uniform sampler2D u_tex0;
2019-03-26 13:45:03 +08:00
uniform vec4 u_Time;
2019-09-04 09:58:40 +08:00
uniform vec2 u_screenSize;
const float intensity = 0.05;
vec3 noise(vec2 uv)
{
2019-03-26 13:45:03 +08:00
vec2 p = abs(sin(uv * 13.0 + uv.x * u_Time[1] * sin(uv.y)));
2019-03-26 13:45:03 +08:00
return vec3(sin (0.2 * u_Time[1] + sin(p * 0.5) * u_Time[1] / cos(50.0)) * 10.0,0.3+0.5 * abs(sin(u_Time[1] * tan(5.0))));
}
void main(void)
{
2019-09-04 09:58:40 +08:00
#ifdef METAL
vec2 fragCoord = vec2(gl_FragCoord.x, u_screenSize.y - gl_FragCoord.y);
#else
vec2 fragCoord = gl_FragCoord.xy;
#endif
gl_FragColor.xyz = intensity * noise(fragCoord / sin(resolution.xy * u_Time[1] * 0.01)) + (1. - intensity) *
2022-07-04 21:26:48 +08:00
texture2D(u_tex0,v_texCoord.xy).xyz;
gl_FragColor.w = 1.;
}