From c20c71c02871bb008e822d2708f0c8e8e493091f Mon Sep 17 00:00:00 2001 From: Keil Miller Jr Date: Sun, 20 Aug 2017 17:01:53 -0400 Subject: [PATCH] Added rotated param Signed-off-by: Keil Miller Jr --- CRT-lottes_rgb32_dir.fsh | 35 +++++++++++++++++++++++------------ module.nut | 11 +++++++++-- 2 files changed, 32 insertions(+), 14 deletions(-) diff --git a/CRT-lottes_rgb32_dir.fsh b/CRT-lottes_rgb32_dir.fsh index b37fb52..0ccc5b0 100644 --- a/CRT-lottes_rgb32_dir.fsh +++ b/CRT-lottes_rgb32_dir.fsh @@ -12,7 +12,8 @@ // // Comment these out to disable the corresponding effect. -uniform float CURVATURE; // Curved or Flat style. +#define ROTATED +#define CURVATURE; // Curved or Flat style. #define YUV // Saturation and Tint #define GAMMA_CONTRAST_BOOST //Expands contrast and makes image brighter but causes clipping. //#define ORIGINAL_SCANLINES //Enable to use the original scanlines. @@ -48,6 +49,10 @@ uniform float blackClip; uniform float brightMult; const vec3 gammaBoost = vec3(1.0/1.2, 1.0/1.2, 1.0/1.2);//An extra per channel gamma adjustment applied at the end. +// AttractMode FE Variables +uniform float rotated; +uniform float curvature; + //Here are the Tint/Saturation/GammaContrastBoost Variables. Comment out "#define YUV" and "#define GAMMA_CONTRAST_BOOST" to disable these altogether. const float PI = 3.1415926535; float U = cos(tint*PI/180.0); @@ -171,6 +176,9 @@ vec3 Tri(vec2 pos) // Shadow mask. vec3 Mask(vec2 pos) { +#ifdef ROTATED + if (rotated == 1.0) { pos.xy=pos.yx; } +#endif // Very compressed TV style shadow mask. if (aperature_type == 1.0) { @@ -245,19 +253,22 @@ void main(void) { gl_FragColor.a = 1.0; - // Curved style - if (CURVATURE == 1.0) - { - vec2 pos = radialDistortion(texCoord);//CURVATURE - //FINAL// - gl_FragColor.rgb = Tri(pos) * Mask(gl_FragCoord.xy) * vec3(corner(pos)); - } - // Flat style - else - { + #ifdef CURVATURE + if (curvature == 1.0) + { + vec2 pos = radialDistortion(texCoord);//CURVATURE + //FINAL// + gl_FragColor.rgb = Tri(pos) * Mask(gl_FragCoord.xy) * vec3(corner(pos)); + } + else + { + vec2 pos = gl_TexCoord[0].xy; + gl_FragColor.rgb = Tri(pos) * Mask(gl_FragCoord.xy); + } + #else vec2 pos = gl_TexCoord[0].xy; gl_FragColor.rgb = Tri(pos) * Mask(gl_FragCoord.xy); - } + #endif #ifdef YUV gl_FragColor.rgb = vec3(dot(YUVr,gl_FragColor.rgb), dot(YUVg,gl_FragColor.rgb), dot(YUVb,gl_FragColor.rgb)); diff --git a/module.nut b/module.nut index e90b2dc..b4d3221 100644 --- a/module.nut +++ b/module.nut @@ -1,7 +1,7 @@ class CrtLottes { shader = null; - constructor(w=640, h=480, c=0, a=2.0, v=fe.module_dir+"CRT-lottes.vsh", f=fe.module_dir+"CRT-lottes_rgb32_dir.fsh") { + constructor(w=640, h=480, c=0, a=2.0, r=1.0, v=fe.module_dir+"CRT-lottes.vsh", f=fe.module_dir+"CRT-lottes_rgb32_dir.fsh") { shader = fe.add_shader(Shader.VertexAndFragment, v, f); curvature(c); @@ -17,13 +17,14 @@ class CrtLottes { tint(); backClip(); brightMult(); + rotated(r); setTextures(w, h); } function curvature(val=0) { // 0 = Flat // 1.0 = Curved - shader.set_param("CURVATURE", val); + shader.set_param("curvature", val); } function aperature(val=2.0) { @@ -85,6 +86,12 @@ class CrtLottes { // Multiplies the color settings by this amount if GAMMA_CONTRAST_BOOST is defined shader.set_param("brightMult", val); } + + function rotated(val=1.0) { + // 0 = Scan line orientation vertical. + // 1.0 = Scan line orientation horizontal. + shader.set_param("rotated", val); + } function setTextures(w=640, h=480) { shader.set_param("color_texture_sz", w, h);