Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Vertex shader is default
- // Fragment shader
- varying vec2 v_vTexcoord;
- varying vec4 v_vColour;
- uniform vec2 u_resolution;
- uniform float u_opacity;
- vec2 curveRemapUV(vec2 orig_uv)
- {
- // as we near the edge of our screen apply greater distortion using a cubic function
- vec2 uv = vec2(orig_uv.x * 2.0 - 1.0, orig_uv.y * 2.0 - 1.0);
- vec2 offset;
- offset.x = abs(uv.y) / 3.0;
- offset.y = abs(uv.x) / 3.0;
- uv = uv + uv * offset * offset;
- uv = uv * 0.5 + 0.5;
- return uv;
- }
- vec4 vignetteIntensity(vec2 uv, vec2 resolution, float opacity)
- {
- float intensity = uv.x * uv.y * (1.0 - uv.x) * (1.0 - uv.y);
- return vec4(vec3(clamp(pow((resolution.x / 4.0) * intensity, opacity), 0.0, 1.0)), 1.0);
- }
- vec4 scanLineIntensity(float uv, float resolution, float opacity)
- {
- float intensity = sin(uv * resolution * 3.1415926 * 2.0);
- intensity = ((0.5 * intensity) + 0.5) * 0.9 + 0.1;
- return vec4(vec3(pow(intensity, opacity)), 1.0);
- }
- void main()
- {
- vec2 remappedUV = curveRemapUV(vec2(v_vTexcoord.x, v_vTexcoord.y));
- if (remappedUV.x < 0.0 || remappedUV.y < 0.0 || remappedUV.x > 1.0 || remappedUV.y > 1.0){
- gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);
- } else {
- vec4 base_col = texture2D( gm_BaseTexture, remappedUV );
- base_col *= vignetteIntensity(remappedUV, u_resolution, 1.0);
- base_col *= scanLineIntensity(v_vTexcoord.x, u_resolution.y * 0.75, u_opacity); // 2.0, 0.5
- base_col *= scanLineIntensity(v_vTexcoord.y, u_resolution.x * 0.75, u_opacity);
- gl_FragColor = v_vColour * base_col;
- }
- //base_col *= scanLineIntensity(v_vTexcoord.x, RES_H, OPACITY);
- //base_col *= scanLineIntensity(v_vTexcoord.y, RES_W, OPACITY);
- //gl_FragColor = v_vColour * base_col;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement