- [NEW] Nou shader crt
This commit is contained in:
1 parent
107cde3b9f
commit
38e1303451
3 files changed
+70
-12
No files matched your search
@@ -0,0 +1,64 @@
|
||||
varying vec2 tex_coord;
|
||||
varying vec2 pix_coord;
|
||||
|
||||
#if defined(VERTEX)
|
||||
|
||||
void main()
|
||||
{
|
||||
pix_coord = vec2(gl_MultiTexCoord0.x, 1.0-gl_MultiTexCoord0.y)*1.0001;
|
||||
tex_coord = vec2((gl_Vertex.x+1.0)*0.5, (-gl_Vertex.y+1.0)*0.5);
|
||||
vec4 pos = vec4(gl_Vertex.x * 2.0, gl_Vertex.y * 2.0, gl_Vertex.z, gl_Vertex.w);
|
||||
gl_Position = gl_Vertex;
|
||||
}
|
||||
|
||||
#elif defined(FRAGMENT)
|
||||
|
||||
uniform sampler2D Texture;
|
||||
const vec2 screenRes = vec2(640.0, 480.0);
|
||||
|
||||
void main()
|
||||
{
|
||||
vec2 uv = tex_coord;
|
||||
|
||||
// Curvatura suau de pantalla
|
||||
vec2 cc = uv - 0.5;
|
||||
float dist = dot(cc, cc);
|
||||
uv += cc * dist * 0.05;
|
||||
|
||||
float x = sign(pix_coord.x)*floor(abs(pix_coord.x)+0.5);
|
||||
float column = mod(x,4.0);
|
||||
float y = sign(pix_coord.y)*floor(abs(pix_coord.y)+0.5);
|
||||
float row = mod(y,4.0);
|
||||
|
||||
// El que queda fora de la curvatura, es pinta de negre i a aprendre pel cul
|
||||
if (uv.x < 0.0 || uv.x > 1.0 || uv.y < 0.0 || uv.y > 1.0) {
|
||||
gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);
|
||||
return;
|
||||
}
|
||||
vec4 color = texture2D(Texture, uv);
|
||||
|
||||
// Scanlines
|
||||
float scanline = sin(uv.y * screenRes.y * 3.14159265) * 0.15;
|
||||
color.rgb -= scanline;
|
||||
|
||||
// Máscara de subpixels RGB sutil
|
||||
float pixelX = mod(uv.x * screenRes.x, 3.0);
|
||||
vec3 mask = vec3(1.0);
|
||||
if (pixelX < 1.0) {
|
||||
mask = vec3(1.0, 0.85, 0.85);
|
||||
} else if (pixelX < 2.0) {
|
||||
mask = vec3(0.85, 1.0, 0.85);
|
||||
} else {
|
||||
mask = vec3(0.85, 0.85, 1.0);
|
||||
}
|
||||
color.rgb *= mask;
|
||||
|
||||
// Vignetting per a donar profunditat de tubo CRT
|
||||
float vignette = uv.x * uv.y * (1.0 - uv.x) * (1.0 - uv.y);
|
||||
vignette = clamp(pow(16.0 * vignette, 0.25), 0.0, 1.0);
|
||||
color.rgb *= vignette;
|
||||
|
||||
gl_FragColor = color;
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in new issue
Block a user