Skip to content

Commit

Permalink
Added rotated param
Browse files Browse the repository at this point in the history
Signed-off-by: Keil Miller Jr <keilmillerjr@me.com>
  • Loading branch information
keilmillerjr committed Aug 20, 2017
1 parent b0accde commit c20c71c
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 14 deletions.
35 changes: 23 additions & 12 deletions CRT-lottes_rgb32_dir.fsh
Expand Up @@ -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.
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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));
Expand Down
11 changes: 9 additions & 2 deletions 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);
Expand All @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit c20c71c

Please sign in to comment.