-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated and new shaders. Shaders folder path accessible from a global variable. Shaders create shader variable and use set_default function to set default parameters. Updated readme. This commit will break existing usage of the module, and layouts must be updated.
- Loading branch information
1 parent
c20c71c
commit 3dd73e6
Showing
12 changed files
with
1,255 additions
and
207 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,126 +1,122 @@ | ||
class CrtLottes { | ||
::shadersDirectory <- fe.module_dir + "shaders/"; | ||
::shadersDir <- shadersDirectory; | ||
|
||
class Bloom { | ||
shader = null; | ||
|
||
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); | ||
aperature(a); | ||
distortion(); | ||
cornerSize(); | ||
cornerSmooth(); | ||
hardScan(); | ||
hardPix(); | ||
maskDark(); | ||
maskLight(); | ||
saturation(); | ||
tint(); | ||
backClip(); | ||
brightMult(); | ||
rotated(r); | ||
setTextures(w, h); | ||
constructor() { | ||
shader = fe.add_shader(Shader.Fragment, shadersDir + "bloom.fsh"); | ||
set_default(); | ||
} | ||
|
||
function curvature(val=0) { | ||
// 0 = Flat | ||
// 1.0 = Curved | ||
shader.set_param("curvature", val); | ||
function set_default() { | ||
shader.set_param("bloom_spread", 0.000695); | ||
shader.set_param("bloom_power", 0.228); | ||
shader.set_texture_param("mpass_texture"); | ||
} | ||
} | ||
|
||
function aperature(val=2.0) { | ||
// 0 = VGA style shadow mask. | ||
// 1.0 = Very compressed TV style shadow mask. | ||
// 2.0 = Aperture-grille. | ||
shader.set_param("aperature_type", val); | ||
} | ||
class BloomMultipass { | ||
shader = null; | ||
|
||
function distortion(val=0.1) { | ||
shader.set_param("distortion", val); | ||
constructor() { | ||
shader = fe.add_shader(Shader.VertexAndFragment, shadersDir + "bloomMultipass.vsh", shadersDir + "bloomMultipass.fsh"); | ||
set_default(); | ||
} | ||
|
||
function cornerSize(val=0.038) { | ||
shader.set_param("cornersize", val); | ||
function set_default() { | ||
shader.set_texture_param("source"); | ||
shader.set_param("sourceSize", 320, 240); | ||
} | ||
} | ||
|
||
function cornerSmooth(val=400.0) { | ||
// Accepts values 100-1000 | ||
shader.set_param("cornersmooth", val); | ||
} | ||
class CrtCgwg { | ||
shader = null; | ||
|
||
function hardScan(val=-10.0) { | ||
// -8.0 = soft | ||
// -16.0 = medium | ||
shader.set_param("hardScan", val); | ||
constructor() { | ||
shader = fe.add_shader(Shader.VertexAndFragment, shadersDir + "crtCgwg.vsh", shadersDir + "crtCgwg.fsh"); | ||
set_default(); | ||
} | ||
|
||
function hardPix(val=-2.3) { | ||
// -2.0 = soft | ||
// -4.0 = hard | ||
shader.set_param("hardPix", val); | ||
} | ||
function set_default() { | ||
shader.set_param("CRTgamma", 2.4); // gamma of simulated CRT | ||
shader.set_param("monitorgamma", 2.2); // gamma of display monitor (typically 2.2 is correct) | ||
shader.set_param("overscan", 0.99, 0.99); // overscan (e.g. 1.02 for 2% overscan) | ||
shader.set_param("aspect", 1.0, 0.75); // aspect ratio | ||
shader.set_param("d", 1.3); // distance from viewer | ||
shader.set_param("R", 2.5); // radius of curvature - 2.0 to 3.0? | ||
shader.set_param("cornersize", 0.02); // size of curved corners | ||
shader.set_param("cornersmooth", 80); // border smoothness parameter, decrease if borders are too aliased | ||
shader.set_texture_param("texture"); | ||
shader.set_param("inputSize", 320, 240); // size of input | ||
shader.set_param("outputSize", 320, 240); // size of mask | ||
shader.set_param("textureSize", 320, 240); // size drawing to | ||
|
||
function maskDark(val=0.4) { | ||
shader.set_param("maskDark", val); | ||
} | ||
} | ||
|
||
function maskLight(val=1.3) { | ||
shader.set_param("maskLight", val); | ||
} | ||
class CrtLottes { | ||
shader = null; | ||
|
||
function saturation(val=1.25) { | ||
// 1.0 is normal saturation. Increase as needed. | ||
shader.set_param("saturation", val); | ||
constructor() { | ||
shader = fe.add_shader(Shader.VertexAndFragment, shadersDir + "crtLottes.vsh", shadersDir + "crtLottes.fsh"); | ||
set_default(); | ||
} | ||
|
||
function tint(val=0.1) { | ||
// 0.0 is 0.0 degrees of Tint. Adjust as needed. | ||
shader.set_param("tint", val); | ||
function set_default() { | ||
// APERATURE_TYPE | ||
// 0.0 = VGA style shadow mask. | ||
// 1.0 = Very compressed TV style shadow mask. | ||
// 2.0 = Aperture-grille. | ||
shader.set_param("aperature_type", 2.0); | ||
shader.set_param("hardScan", -20.0); // Hardness of Scanline -8.0 = soft -16.0 = medium | ||
shader.set_param("hardPix", -5.0); // Hardness of pixels in scanline -2.0 = soft, -4.0 = hard | ||
shader.set_param("maskDark", 0.4); // Sets how dark a "dark subpixel" is in the aperture pattern. | ||
shader.set_param("maskLight", 1.5); // Sets how dark a "bright subpixel" is in the aperture pattern | ||
shader.set_param("saturation", 1.1); // 1.0 is normal saturation. Increase as needed. | ||
shader.set_param("tint", 0.0); // 0.0 is 0.0 degrees of Tint. Adjust as needed. | ||
shader.set_param("blackClip", 0.02); // Drops the final color value by this amount | ||
shader.set_param("brightMult", 1.2); // Multiplies the color values by this amount if GAMMA_CONTRAST_BOOST is defined | ||
shader.set_param("distortion", 0.15); // 0.0 to 0.2 seems right | ||
shader.set_param("cornersize", 0.03); // 0.0 to 0.1 | ||
shader.set_param("cornersmooth", 80); // Reduce jagginess of corners | ||
shader.set_texture_param("texture"); | ||
shader.set_param("color_texture_sz", 320, 240); | ||
shader.set_param("color_texture_pow2_sz", 320, 240); | ||
} | ||
} | ||
|
||
function backClip(val=0.08) { | ||
// Drops the final color value by this amount if GAMMA_CONTRAST_BOOST is defined | ||
shader.set_param("blackClip", val); | ||
} | ||
class CrtLottesMultipass { | ||
shader = null; | ||
|
||
function brightMult(val=1.25) { | ||
// 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); | ||
constructor() { | ||
shader = fe.add_shader(Shader.VertexAndFragment, shadersDir + "crtLottesMultipass.vsh", shadersDir + "crtLottesMultipass.fsh"); | ||
set_default(); | ||
} | ||
|
||
function setTextures(w=640, h=480) { | ||
shader.set_param("color_texture_sz", w, h); | ||
shader.set_param("color_texture_pow2_sz", w, h); | ||
shader.set_texture_param("mpass_texture"); | ||
function set_default() { | ||
shader.set_texture_param("source"); | ||
shader.set_param("sourceSize", 320, 240); | ||
shader.set_param("outputSize", 320, 240); | ||
} | ||
} | ||
|
||
class RoundCorners { | ||
class RoundedCorners { | ||
shader = null; | ||
|
||
constructor(r, iw, ih, siw=null, sih=null, f=fe.module_dir+"RoundCorners.fsh") { | ||
shader = fe.add_shader(Shader.Fragment, f); | ||
|
||
setRadius(r); | ||
setImgDimensions(iw, ih); | ||
if (!siw || !sih ) setSubImgDimensions(iw, ih); | ||
else setSubImgDimensions(siw, sih); | ||
constructor(...) { | ||
shader = fe.add_shader(Shader.Fragment, shadersDir + "roundedCorners.fsh"); | ||
if (vargv.len() == 3) set_default(vargv[0], vargv[1], vargv[2]); | ||
if (vargv.len() == 5) set_default(vargv[0], vargv[1], vargv[2], vargv[3], vargv[4]); | ||
} | ||
|
||
function setRadius(val) { | ||
shader.set_param("radius", val); | ||
} | ||
|
||
function setImgDimensions(val1, val2) { | ||
shader.set_param("snap_dimensions", val1, val2); | ||
} | ||
|
||
function setSubImgDimensions(val1, val2) { | ||
shader.set_param("subimg_dimensions", val1, val2); | ||
|
||
function set_default(r, iw, ih, siw=null, sih=null) { | ||
shader.set_param("radius", r); | ||
shader.set_param("snap_dimensions", iw, ih); | ||
if (!siw || !sih) { | ||
siw = iw; | ||
sih = ih; | ||
} | ||
shader.set_param("subimg_dimensions", siw, sih); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// | ||
// Bloom shader from http://wp.applesandoranges.eu/?p=14 | ||
// | ||
// Modified by Chris Van Graas | ||
// | ||
uniform float bloom_spread; | ||
uniform float bloom_power; | ||
|
||
uniform sampler2D mpass_texture; | ||
|
||
void main() | ||
{ | ||
vec4 sum = vec4(0); | ||
vec2 texcoord = vec2(gl_TexCoord[0]); | ||
int j; | ||
int i; | ||
|
||
for( i= -4 ;i < 4; i++) | ||
{ | ||
for (j = -3; j < 3; j++) | ||
{ | ||
sum += gl_Color * texture2D(mpass_texture, texcoord + vec2(j, i) * bloom_spread) * bloom_power; | ||
} | ||
} | ||
if (texture2D(mpass_texture, texcoord).r < 0.3) | ||
{ | ||
gl_FragColor = sum*sum*0.012 + gl_Color * texture2D(mpass_texture, texcoord); | ||
} | ||
else | ||
{ | ||
if (texture2D(mpass_texture, texcoord).r < 0.5) | ||
{ | ||
gl_FragColor = sum*sum*0.009 + gl_Color * texture2D(mpass_texture, texcoord); | ||
} | ||
else | ||
{ | ||
gl_FragColor = sum*sum*0.0075 + gl_Color * texture2D(mpass_texture, texcoord); | ||
} | ||
} | ||
} |
Oops, something went wrong.