Merge pull request #1038 from cgwg/crt-geom

Added crt-geom and crt-geom-deluxe shaders for bgfx.
This commit is contained in:
Vas Crabb 2016-07-04 09:36:08 +10:00 committed by GitHub
commit 75446b66c8
88 changed files with 1306 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 153 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 152 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 159 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 156 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 159 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 159 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 156 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 164 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 168 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 150 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 171 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 176 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 180 B

View File

@ -0,0 +1,238 @@
{
"name": "CRT-geom",
"author": "cgwg",
"sliders": [
{ "type": "float",
"name": "aperture_strength",
"text": "Shadow mask strength",
"default": 0.4,
"max" : 1.0,
"min" : 0.0,
"step" : 0.05,
"format": "%1.2f",
"screen": "raster" },
{ "type": "float",
"name": "phosphor_power",
"text": "Phosphor decay power",
"default": 1.2,
"max" : 3.0,
"min" : 0.5,
"step" : 0.05,
"format": "%1.2f",
"screen": "raster" },
{ "type": "float",
"name": "phosphor_amplitude",
"text": "Phosphor persistence amplitude",
"default": 0.04,
"max" : 0.2,
"min" : 0.0,
"step" : 0.01,
"format": "%1.2f",
"screen": "raster" },
{ "type": "float",
"name": "halation",
"text": "Halation amplitude",
"default": 0.1,
"max" : 0.3,
"min" : 0.0,
"step" : 0.01,
"format": "%1.2f",
"screen": "raster" },
{ "type": "float",
"name": "blurwidth",
"text": "Halation blur width",
"default": 2.0,
"max" : 4.0,
"min" : 0.1,
"step" : 0.1,
"format": "%1.1f",
"screen": "raster" },
{ "type": "float",
"name": "curvature",
"text": "Enable curvature",
"default": 1.0,
"max" : 1.0,
"min" : 0.0,
"step" : 1.0,
"format": "%1.0f",
"screen": "raster" },
{ "type": "float",
"name": "R",
"text": "Radius of curvature",
"default": 3.5,
"max" : 10.0,
"min" : 0.5,
"step" : 0.1,
"format": "%1.1f",
"screen": "raster" },
{ "type": "float",
"name": "d",
"text": "Distance to screen",
"default": 2.0,
"max" : 10.0,
"min" : 0.1,
"step" : 0.1,
"format": "%1.1f",
"screen": "raster" },
{ "type": "vec2",
"name": "angle",
"text": "Tilt ",
"default": [ 0.0,-0.05 ],
"max" : [ 1.0, 1.0 ],
"min" : [-1.0,-1.0 ],
"step" : 0.01,
"format": "%1.2f",
"screen": "raster" },
{ "type": "float",
"name": "cornersize",
"text": "Rounded corner size",
"default": 0.01,
"max" : 0.10,
"min" : 0.00,
"step" : 0.01,
"format": "%1.2f",
"screen": "raster" },
{ "type": "float",
"name": "cornersmooth",
"text": "Border smoothness",
"default": 1000,
"max" : 2000,
"min" : 100,
"step" : 100,
"format": "%1.0f",
"screen": "raster" },
{ "type": "vec2",
"name": "overscan",
"text": "Overscan ",
"default": [ 1.0, 1.0 ],
"max" : [ 1.2, 1.2 ],
"min" : [ 0.8, 0.8 ],
"step" : 0.02,
"format": "%1.2f",
"screen": "raster" },
{ "type": "float",
"name": "CRTgamma",
"text": "Gamma of simulated CRT",
"default": 2.4,
"max" : 4.0,
"min" : 0.7,
"step" : 0.05,
"format": "%1.2f",
"screen": "raster" },
{ "type": "float",
"name": "monitorgamma",
"text": "Gamma of output display",
"default": 2.2,
"max" : 4.0,
"min" : 0.7,
"step" : 0.05,
"format": "%1.2f",
"screen": "raster" },
{ "type": "vec2",
"name": "aspect",
"text": "Aspect ratio ",
"default": [ 1.0, 0.75 ],
"max" : [ 1.0, 1.0 ],
"min" : [ 0.3, 0.3 ],
"step" : 0.01,
"format": "%1.2f",
"screen": "raster" }
],
"targets": [
{ "name": "internal1",
"mode": "guest"
},
{ "name": "internal2",
"mode": "guest"
},
{ "name": "blur",
"mode": "guest"
},
{ "name": "phosphor",
"mode": "guest"
}
],
"passes": [
{
"effect": "crt-geom/phosphor_apply",
"name": "phosphor apply",
"uniforms": [
{ "uniform": "u_phosphor_power", "slider": "phosphor_power" },
{ "uniform": "u_phosphor_amplitude","slider": "phosphor_amplitude" },
{ "uniform": "u_gamma", "slider": "CRTgamma" }
],
"input": [
{ "sampler": "s_screen", "target": "screen" },
{ "sampler": "s_phosphor", "target": "phosphor" }
],
"output": "internal1"
},
{
"effect": "crt-geom/phosphor_update",
"name": "phosphor update",
"uniforms": [
{ "uniform": "u_phosphor_power", "slider": "phosphor_power" },
{ "uniform": "u_phosphor_amplitude","slider": "phosphor_amplitude" },
{ "uniform": "u_gamma", "slider": "CRTgamma" }
],
"input": [
{ "sampler": "s_screen", "target": "screen" },
{ "sampler": "s_phosphor", "target": "phosphor" }
],
"output": "phosphor"
},
{
"effect": "crt-geom/gaussx",
"name": "Gaussian blur x",
"uniforms": [
{ "uniform": "u_width", "slider": "blurwidth" },
{ "uniform": "u_aspect","slider": "aspect" },
{ "uniform": "u_gamma", "slider": "CRTgamma" }
],
"input": [
{ "sampler": "s_tex", "target": "internal1" }
],
"output": "internal2"
},
{
"effect": "crt-geom/gaussy",
"name": "Gaussian blur y",
"uniforms": [
{ "uniform": "u_width", "slider": "blurwidth" },
{ "uniform": "u_aspect","slider": "aspect" },
{ "uniform": "u_gamma", "slider": "CRTgamma" }
],
"input": [
{ "sampler": "s_tex", "target": "internal2" }
],
"output": "blur"
},
{
"effect": "crt-geom/crt-geom-deluxe",
"name": "CRT",
"uniforms": [
{ "uniform": "curvature", "slider": "curvature" },
{ "uniform": "R", "slider": "R" },
{ "uniform": "d", "slider": "d" },
{ "uniform": "angle", "slider": "angle" },
{ "uniform": "cornersize", "slider": "cornersize" },
{ "uniform": "cornersmooth","slider": "cornersmooth" },
{ "uniform": "overscan", "slider": "overscan" },
{ "uniform": "aspect", "slider": "aspect" },
{ "uniform": "CRTgamma", "slider": "CRTgamma" },
{ "uniform": "monitorgamma","slider": "monitorgamma" },
{ "uniform": "aperture_strength","slider": "aperture_strength" },
{ "uniform": "halation", "slider": "halation" }
],
"input": [
{ "sampler": "mpass_texture", "target": "internal1" },
{ "sampler": "mask_texture", "texture": "bgfx/chains/crt-geom/aperture_1_2_bgr.png", "selection": "Shadow mask" },
{ "sampler": "blur_texture", "target": "blur" }
],
"output": "output"
}
]
}

134
bgfx/chains/crt-geom.json Normal file
View File

@ -0,0 +1,134 @@
{
"name": "CRT-geom",
"author": "cgwg",
"sliders": [
{ "type": "float",
"name": "aperture_strength",
"text": "Shadow mask strength",
"default": 0.4,
"max" : 1.0,
"min" : 0.0,
"step" : 0.05,
"format": "%1.2f",
"screen": "raster" },
{ "type": "float",
"name": "curvature",
"text": "Enable curvature",
"default": 1.0,
"max" : 1.0,
"min" : 0.0,
"step" : 1.0,
"format": "%1.0f",
"screen": "raster" },
{ "type": "float",
"name": "R",
"text": "Radius of curvature",
"default": 3.5,
"max" : 10.0,
"min" : 0.5,
"step" : 0.1,
"format": "%1.1f",
"screen": "raster" },
{ "type": "float",
"name": "d",
"text": "Distance to screen",
"default": 2.0,
"max" : 10.0,
"min" : 0.1,
"step" : 0.1,
"format": "%1.1f",
"screen": "raster" },
{ "type": "vec2",
"name": "angle",
"text": "Tilt ",
"default": [ 0.0,-0.05 ],
"max" : [ 1.0, 1.0 ],
"min" : [-1.0,-1.0 ],
"step" : 0.01,
"format": "%1.2f",
"screen": "raster" },
{ "type": "float",
"name": "cornersize",
"text": "Rounded corner size",
"default": 0.01,
"max" : 0.10,
"min" : 0.00,
"step" : 0.01,
"format": "%1.2f",
"screen": "raster" },
{ "type": "float",
"name": "cornersmooth",
"text": "Border smoothness",
"default": 1000,
"max" : 2000,
"min" : 100,
"step" : 100,
"format": "%1.0f",
"screen": "raster" },
{ "type": "vec2",
"name": "overscan",
"text": "Overscan ",
"default": [ 1.0, 1.0 ],
"max" : [ 1.2, 1.2 ],
"min" : [ 0.8, 0.8 ],
"step" : 0.02,
"format": "%1.2f",
"screen": "raster" },
{ "type": "float",
"name": "CRTgamma",
"text": "Gamma of simulated CRT",
"default": 2.4,
"max" : 4.0,
"min" : 0.7,
"step" : 0.05,
"format": "%1.2f",
"screen": "raster" },
{ "type": "float",
"name": "monitorgamma",
"text": "Gamma of output display",
"default": 2.2,
"max" : 4.0,
"min" : 0.7,
"step" : 0.05,
"format": "%1.2f",
"screen": "raster" },
{ "type": "vec2",
"name": "aspect",
"text": "Aspect ratio ",
"default": [ 1.0, 0.75 ],
"max" : [ 1.0, 1.0 ],
"min" : [ 0.3, 0.3 ],
"step" : 0.01,
"format": "%1.2f",
"screen": "raster" }
],
"targets": [
],
"passes": [
{
"effect": "crt-geom/crt-geom",
"name": "CRT",
"uniforms": [
{ "uniform": "curvature", "slider": "curvature" },
{ "uniform": "R", "slider": "R" },
{ "uniform": "d", "slider": "d" },
{ "uniform": "angle", "slider": "angle" },
{ "uniform": "cornersize", "slider": "cornersize" },
{ "uniform": "cornersmooth","slider": "cornersmooth" },
{ "uniform": "overscan", "slider": "overscan" },
{ "uniform": "aspect", "slider": "aspect" },
{ "uniform": "CRTgamma", "slider": "CRTgamma" },
{ "uniform": "monitorgamma","slider": "monitorgamma" },
{ "uniform": "aperture_strength", "slider": "aperture_strength" }
],
"input": [
{ "sampler": "mpass_texture", "target": "screen" },
{ "sampler": "mask_texture", "texture": "bgfx/chains/crt-geom/aperture_1_2_bgr.png", "selection": "Shadow mask" }
],
"output": "output"
}
]
}

View File

@ -0,0 +1,43 @@
{
"blend": {
"equation": "add",
"srcColor": "1",
"dstColor": "0",
"srcAlpha": "1",
"dstAlpha": "0"
},
"depth": {
"function": "always",
"writeenable": false
},
"cull": {
"mode": "none"
},
"write": {
"rgb": true,
"alpha": true
},
"vertex": "chains/crt-geom/vs_crt-geom",
"fragment": "chains/crt-geom/fs_crt-geom-deluxe",
"uniforms": [
{ "name": "u_tex_size0", "type": "vec4", "values": [ 1.0, 1.0, 0.0, 0.0 ] },
{ "name": "u_tex_size1", "type": "vec4", "values": [ 1.0, 1.0, 0.0, 0.0 ] },
{ "name": "u_quad_dims", "type": "vec4", "values": [ 1.0, 1.0, 0.0, 0.0 ] },
{ "name": "u_rotation_type", "type": "vec4", "values": [ 1.0, 0.0, 0.0, 0.0 ] },
{ "name": "mpass_texture", "type": "int", "values": [ 0 ] },
{ "name": "mask_texture", "type": "int", "values": [ 1 ] },
{ "name": "blur_texture", "type": "int", "values": [ 1 ] },
{ "name": "curvature", "type": "vec4", "values": [ 1.0, 0.0, 0.0, 0.0 ] },
{ "name": "CRTgamma", "type": "vec4", "values": [ 2.4, 0.0, 0.0, 0.0 ] },
{ "name": "monitorgamma", "type": "vec4", "values": [ 2.2, 0.0, 0.0, 0.0 ] },
{ "name": "overscan", "type": "vec4", "values": [ 1.0, 1.0, 0.0, 0.0 ] },
{ "name": "aspect", "type": "vec4", "values": [ 1.0, 0.75,0.0, 0.0 ] },
{ "name": "d", "type": "vec4", "values": [ 2.0, 0.0, 0.0, 0.0 ] },
{ "name": "R", "type": "vec4", "values": [ 3.5, 0.0, 0.0, 0.0 ] },
{ "name": "angle", "type": "vec4", "values": [ 0.0,-0.05,0.0, 0.0 ] },
{ "name": "cornersize", "type": "vec4", "values": [ 0.01,0.0, 0.0, 0.0 ] },
{ "name": "cornersmooth", "type": "vec4", "values": [ 1000.0,0.0,0.0,0.0 ] },
{ "name": "aperture_strength", "type": "vec4", "values": [ 0.25,0.0,0.0,0.0 ] },
{ "name": "halation", "type": "vec4", "values": [ 0.1,0.0,0.0,0.0 ] }
]
}

View File

@ -0,0 +1,41 @@
{
"blend": {
"equation": "add",
"srcColor": "1",
"dstColor": "0",
"srcAlpha": "1",
"dstAlpha": "0"
},
"depth": {
"function": "always",
"writeenable": false
},
"cull": {
"mode": "none"
},
"write": {
"rgb": true,
"alpha": true
},
"vertex": "chains/crt-geom/vs_crt-geom",
"fragment": "chains/crt-geom/fs_crt-geom",
"uniforms": [
{ "name": "u_tex_size0", "type": "vec4", "values": [ 1.0, 1.0, 0.0, 0.0 ] },
{ "name": "u_tex_size1", "type": "vec4", "values": [ 1.0, 1.0, 0.0, 0.0 ] },
{ "name": "u_quad_dims", "type": "vec4", "values": [ 1.0, 1.0, 0.0, 0.0 ] },
{ "name": "u_rotation_type", "type": "vec4", "values": [ 1.0, 0.0, 0.0, 0.0 ] },
{ "name": "mpass_texture", "type": "int", "values": [ 0 ] },
{ "name": "mask_texture", "type": "int", "values": [ 1 ] },
{ "name": "curvature", "type": "vec4", "values": [ 1.0, 0.0, 0.0, 0.0 ] },
{ "name": "CRTgamma", "type": "vec4", "values": [ 2.4, 0.0, 0.0, 0.0 ] },
{ "name": "monitorgamma", "type": "vec4", "values": [ 2.2, 0.0, 0.0, 0.0 ] },
{ "name": "overscan", "type": "vec4", "values": [ 1.0, 1.0, 0.0, 0.0 ] },
{ "name": "aspect", "type": "vec4", "values": [ 1.0, 0.75,0.0, 0.0 ] },
{ "name": "d", "type": "vec4", "values": [ 2.0, 0.0, 0.0, 0.0 ] },
{ "name": "R", "type": "vec4", "values": [ 3.5, 0.0, 0.0, 0.0 ] },
{ "name": "angle", "type": "vec4", "values": [ 0.0,-0.05,0.0, 0.0 ] },
{ "name": "cornersize", "type": "vec4", "values": [ 0.01,0.0, 0.0, 0.0 ] },
{ "name": "cornersmooth", "type": "vec4", "values": [ 1000.0,0.0,0.0,0.0 ] },
{ "name": "aperture_strength", "type": "vec4", "values": [ 0.25,0.0,0.0,0.0 ] }
]
}

View File

@ -0,0 +1,29 @@
{
"blend": {
"equation": "add",
"srcColor": "1",
"dstColor": "0",
"srcAlpha": "1",
"dstAlpha": "0"
},
"depth": {
"function": "always",
"writeenable": false
},
"cull": {
"mode": "none"
},
"write": {
"rgb": true,
"alpha": true
},
"vertex": "chains/crt-geom/vs_gaussx",
"fragment": "chains/crt-geom/fs_gaussx",
"uniforms": [
{ "name": "s_tex", "type": "int", "values": [ 0 ] },
{ "name": "u_tex_size0", "type": "vec4", "values": [ 1.0, 1.0, 0.0, 0.0 ] },
{ "name": "u_width", "type": "vec4", "values": [ 2.0, 0.0, 0.0, 0.0 ] },
{ "name": "u_aspect", "type": "vec4", "values": [ 1.0,0.75, 0.0, 0.0 ] },
{ "name": "u_gamma", "type": "vec4", "values": [ 2.2, 0.0, 0.0, 0.0 ] }
]
}

View File

@ -0,0 +1,29 @@
{
"blend": {
"equation": "add",
"srcColor": "1",
"dstColor": "0",
"srcAlpha": "1",
"dstAlpha": "0"
},
"depth": {
"function": "always",
"writeenable": false
},
"cull": {
"mode": "none"
},
"write": {
"rgb": true,
"alpha": true
},
"vertex": "chains/crt-geom/vs_gaussy",
"fragment": "chains/crt-geom/fs_gaussy",
"uniforms": [
{ "name": "s_tex", "type": "int", "values": [ 0 ] },
{ "name": "u_tex_size0", "type": "vec4", "values": [ 1.0, 1.0, 0.0, 0.0 ] },
{ "name": "u_width", "type": "vec4", "values": [ 2.0, 0.0, 0.0, 0.0 ] },
{ "name": "u_aspect", "type": "vec4", "values": [ 1.0,0.75, 0.0, 0.0 ] },
{ "name": "u_gamma", "type": "vec4", "values": [ 2.2, 0.0, 0.0, 0.0 ] }
]
}

View File

@ -0,0 +1,29 @@
{
"blend": {
"equation": "add",
"srcColor": "1",
"dstColor": "0",
"srcAlpha": "1",
"dstAlpha": "0"
},
"depth": {
"function": "always",
"writeenable": false
},
"cull": {
"mode": "none"
},
"write": {
"rgb": true,
"alpha": true
},
"vertex": "chains/crt-geom/vs_phosphor_apply",
"fragment": "chains/crt-geom/fs_phosphor_apply",
"uniforms": [
{ "name": "s_screen", "type": "int", "values": [ 0 ] },
{ "name": "s_phosphor", "type": "int", "values": [ 1 ] },
{ "name": "u_phosphor_power", "type": "vec4", "values": [ 1.3, 0.0, 0.0, 0.0 ] },
{ "name": "u_phosphor_amplitude","type": "vec4", "values": [ 0.2, 0.0, 0.0, 0.0 ] },
{ "name": "u_gamma", "type": "vec4", "values": [ 2.2, 0.0, 0.0, 0.0 ] }
]
}

View File

@ -0,0 +1,29 @@
{
"blend": {
"equation": "add",
"srcColor": "1",
"dstColor": "0",
"srcAlpha": "1",
"dstAlpha": "0"
},
"depth": {
"function": "always",
"writeenable": false
},
"cull": {
"mode": "none"
},
"write": {
"rgb": true,
"alpha": true
},
"vertex": "chains/crt-geom/vs_phosphor_update",
"fragment": "chains/crt-geom/fs_phosphor_update",
"uniforms": [
{ "name": "s_screen", "type": "int", "values": [ 0 ] },
{ "name": "s_phosphor", "type": "int", "values": [ 1 ] },
{ "name": "u_phosphor_power", "type": "vec4", "values": [ 1.3, 0.0, 0.0, 0.0 ] },
{ "name": "u_phosphor_amplitude","type": "vec4", "values": [ 0.2, 0.0, 0.0, 0.0 ] },
{ "name": "u_gamma", "type": "vec4", "values": [ 2.2, 0.0, 0.0, 0.0 ] }
]
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,235 @@
$input v_sinangle, v_cosangle, v_stretch, v_one, v_texCoord
/* CRT shader
*
* Copyright (C) 2010-2016 cgwg, Themaister and DOLLS
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*/
#include "common.sh"
// Comment the next line to disable interpolation in linear gamma (and gain speed).
//#define LINEAR_PROCESSING
// Enable 3x oversampling of the beam profile
#define OVERSAMPLE
// Use the older, purely gaussian beam profile
#define USEGAUSSIAN
// Macros.
#define FIX(c) max(abs(c), 1e-5)
#define PI 3.141592653589
SAMPLER2D(mpass_texture, 0);
SAMPLER2D(mask_texture, 1);
SAMPLER2D(blur_texture, 2);
#ifdef LINEAR_PROCESSING
# define TEX2D(c) pow(texture2D(mpass_texture, (c)), vec4(CRTgamma))
#else
# define TEX2D(c) texture2D(mpass_texture, (c))
#endif
// Enable screen curvature.
uniform vec4 curvature;
uniform vec4 u_tex_size0;
uniform vec4 u_tex_size1;
uniform vec4 u_quad_dims;
uniform vec4 aperture_strength;
uniform vec4 CRTgamma;
uniform vec4 monitorgamma;
uniform vec4 overscan;
uniform vec4 aspect;
uniform vec4 d;
uniform vec4 R;
uniform vec4 cornersize;
uniform vec4 cornersmooth;
uniform vec4 halation;
float intersect(vec2 xy , vec2 sinangle, vec2 cosangle)
{
float A = dot(xy,xy)+d.x*d.x;
float B = 2.0*(R.x*(dot(xy,sinangle)-d.x*cosangle.x*cosangle.y)-d.x*d.x);
float C = d.x*d.x + 2.0*R.x*d.x*cosangle.x*cosangle.y;
return (-B-sqrt(B*B-4.0*A*C))/(2.0*A);
}
vec2 bkwtrans(vec2 xy, vec2 sinangle, vec2 cosangle)
{
float c = intersect(xy, sinangle, cosangle);
vec2 pt = vec2_splat(c)*xy;
pt -= vec2_splat(-R.x)*sinangle;
pt /= vec2_splat(R.x);
vec2 tang = sinangle/cosangle;
vec2 poc = pt/cosangle;
float A = dot(tang,tang)+1.0;
float B = -2.0*dot(poc,tang);
float C = dot(poc,poc)-1.0;
float a = (-B+sqrt(B*B-4.0*A*C))/(2.0*A);
vec2 uv = (pt-a*sinangle)/cosangle;
float r = FIX(R.x*acos(a));
return uv*r/sin(r/R.x);
}
vec2 transform(vec2 coord, vec3 stretch, vec2 sinangle, vec2 cosangle)
{
coord = (coord-vec2_splat(0.5))*aspect.xy*stretch.z+stretch.xy;
return (bkwtrans(coord, sinangle, cosangle)/overscan.xy/aspect.xy+vec2_splat(0.5));
}
float corner(vec2 coord)
{
coord = (coord - vec2_splat(0.5)) * overscan.xy + vec2_splat(0.5);
coord = min(coord, vec2_splat(1.0)-coord) * aspect.xy;
vec2 cdist = vec2_splat(cornersize.x);
coord = (cdist - min(coord,cdist));
float dist = sqrt(dot(coord,coord));
return clamp((max(cdist.x,1e-3)-dist)*cornersmooth.x,0.0, 1.0);
}
// Calculate the influence of a scanline on the current pixel.
//
// 'distance' is the distance in texture coordinates from the current
// pixel to the scanline in question.
// 'color' is the colour of the scanline at the horizontal location of
// the current pixel.
vec4 scanlineWeights(float distance, vec4 color)
{
// "wid" controls the width of the scanline beam, for each RGB channel
// The "weights" lines basically specify the formula that gives
// you the profile of the beam, i.e. the intensity as
// a function of distance from the vertical center of the
// scanline. In this case, it is gaussian if width=2, and
// becomes nongaussian for larger widths. Ideally this should
// be normalized so that the integral across the beam is
// independent of its width. That is, for a narrower beam
// "weights" should have a higher peak at the center of the
// scanline than for a wider beam.
#ifdef USEGAUSSIAN
vec4 wid = 0.3 + 0.1 * pow(color, vec4_splat(3.0));
vec4 weights = vec4(distance / wid);
return 0.4 * exp(-weights * weights) / wid;
#else
vec4 wid = 2.0 + 2.0 * pow(color, vec4_splat(4.0));
vec4 weights = vec4_splat(distance / 0.3);
return 1.4 * exp(-pow(weights * inversesqrt(0.5 * wid), wid)) / (0.6 + 0.2 * wid);
#endif
}
void main()
{
// Here's a helpful diagram to keep in mind while trying to
// understand the code:
//
// | | | | |
// -------------------------------
// | | | | |
// | 01 | 11 | 21 | 31 | <-- current scanline
// | | @ | | |
// -------------------------------
// | | | | |
// | 02 | 12 | 22 | 32 | <-- next scanline
// | | | | |
// -------------------------------
// | | | | |
//
// Each character-cell represents a pixel on the output
// surface, "@" represents the current pixel (always somewhere
// in the bottom half of the current scan-line, or the top-half
// of the next scanline). The grid of lines represents the
// edges of the texels of the underlying texture.
// Texture coordinates of the texel containing the active pixel.
vec2 xy;
if (curvature.x > 0.5)
xy = transform(v_texCoord, v_stretch, v_sinangle, v_cosangle);
else
xy = (v_texCoord-vec2_splat(0.5))/overscan.xy+vec2_splat(0.5);
vec2 xy0 = xy;
float cval = corner(xy);
// Of all the pixels that are mapped onto the texel we are
// currently rendering, which pixel are we currently rendering?
vec2 ratio_scale = xy * u_tex_size0.xy - vec2_splat(0.5);
#ifdef OVERSAMPLE
float filter = fwidth(ratio_scale.y);
#endif
vec2 uv_ratio = fract(ratio_scale);
// Snap to the center of the underlying texel.
xy = (floor(ratio_scale) + vec2_splat(0.5)) / u_tex_size0.xy;
// Calculate Lanczos scaling coefficients describing the effect
// of various neighbour texels in a scanline on the current
// pixel.
vec4 coeffs = PI * vec4(1.0 + uv_ratio.x, uv_ratio.x, 1.0 - uv_ratio.x, 2.0 - uv_ratio.x);
// Prevent division by zero.
coeffs = FIX(coeffs);
// Lanczos2 kernel.
coeffs = 2.0 * sin(coeffs) * sin(coeffs / 2.0) / (coeffs * coeffs);
// Normalize.
coeffs /= dot(coeffs, vec4_splat(1.0));
// Calculate the effective colour of the current and next
// scanlines at the horizontal location of the current pixel,
// using the Lanczos coefficients above.
vec4 col = clamp(TEX2D(xy + vec2(-v_one.x, 0.0))*coeffs.x +
TEX2D(xy)*coeffs.y +
TEX2D(xy +vec2(v_one.x, 0.0))*coeffs.z +
TEX2D(xy + vec2(2.0 * v_one.x, 0.0))*coeffs.w , 0.0, 1.0);
vec4 col2 = clamp(TEX2D(xy + vec2(-v_one.x, v_one.y))*coeffs.x +
TEX2D(xy + vec2(0.0, v_one.y))*coeffs.y +
TEX2D(xy + v_one)*coeffs.z +
TEX2D(xy + vec2(2.0 * v_one.x, v_one.y))*coeffs.w , 0.0, 1.0);
#ifndef LINEAR_PROCESSING
col = pow(col , vec4_splat(CRTgamma.x));
col2 = pow(col2, vec4_splat(CRTgamma.x));
#endif
// Calculate the influence of the current and next scanlines on
// the current pixel.
vec4 weights = scanlineWeights(uv_ratio.y, col);
vec4 weights2 = scanlineWeights(1.0 - uv_ratio.y, col2);
#ifdef OVERSAMPLE
uv_ratio.y =uv_ratio.y+1.0/3.0*filter;
weights = (weights+scanlineWeights(uv_ratio.y, col))/3.0;
weights2=(weights2+scanlineWeights(abs(1.0-uv_ratio.y), col2))/3.0;
uv_ratio.y =uv_ratio.y-2.0/3.0*filter;
weights=weights+scanlineWeights(abs(uv_ratio.y), col)/3.0;
weights2=weights2+scanlineWeights(abs(1.0-uv_ratio.y), col2)/3.0;
#endif
vec3 mul_res = (col * weights + col2 * weights2).rgb;
// halation and corners
vec3 blur = pow(texture2D(blur_texture,xy0).rgb, vec3_splat(CRTgamma.x));
mul_res = mix(mul_res, blur, halation.x) * vec3_splat(cval);
// Convert the image gamma for display on our output device.
mul_res = pow(mul_res, vec3_splat(1.0 / monitorgamma.x));
// Shadow mask
xy = v_texCoord.xy * u_quad_dims.xy / u_tex_size1.xy;
vec3 mask = texture2D(mask_texture, xy).rgb;
mask = mix(vec3_splat(1.0), mask, aperture_strength.x);
gl_FragColor = vec4(mul_res*mask, col.a);
}

View File

@ -0,0 +1,227 @@
$input v_sinangle, v_cosangle, v_stretch, v_one, v_texCoord
/* CRT shader
*
* Copyright (C) 2010-2016 cgwg, Themaister and DOLLS
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*/
#include "common.sh"
// Comment the next line to disable interpolation in linear gamma (and gain speed).
//#define LINEAR_PROCESSING
// Enable 3x oversampling of the beam profile
#define OVERSAMPLE
// Use the older, purely gaussian beam profile
#define USEGAUSSIAN
// Macros.
#define FIX(c) max(abs(c), 1e-5)
#define PI 3.141592653589
SAMPLER2D(mpass_texture, 0);
SAMPLER2D(mask_texture, 1);
#ifdef LINEAR_PROCESSING
# define TEX2D(c) pow(texture2D(mpass_texture, (c)), vec4(CRTgamma))
#else
# define TEX2D(c) texture2D(mpass_texture, (c))
#endif
// Enable screen curvature.
uniform vec4 curvature;
uniform vec4 u_tex_size0;
uniform vec4 u_tex_size1;
uniform vec4 u_quad_dims;
uniform vec4 aperture_strength;
uniform vec4 CRTgamma;
uniform vec4 monitorgamma;
uniform vec4 overscan;
uniform vec4 aspect;
uniform vec4 d;
uniform vec4 R;
uniform vec4 cornersize;
uniform vec4 cornersmooth;
float intersect(vec2 xy , vec2 sinangle, vec2 cosangle)
{
float A = dot(xy,xy)+d.x*d.x;
float B = 2.0*(R.x*(dot(xy,sinangle)-d.x*cosangle.x*cosangle.y)-d.x*d.x);
float C = d.x*d.x + 2.0*R.x*d.x*cosangle.x*cosangle.y;
return (-B-sqrt(B*B-4.0*A*C))/(2.0*A);
}
vec2 bkwtrans(vec2 xy, vec2 sinangle, vec2 cosangle)
{
float c = intersect(xy, sinangle, cosangle);
vec2 pt = vec2_splat(c)*xy;
pt -= vec2_splat(-R.x)*sinangle;
pt /= vec2_splat(R.x);
vec2 tang = sinangle/cosangle;
vec2 poc = pt/cosangle;
float A = dot(tang,tang)+1.0;
float B = -2.0*dot(poc,tang);
float C = dot(poc,poc)-1.0;
float a = (-B+sqrt(B*B-4.0*A*C))/(2.0*A);
vec2 uv = (pt-a*sinangle)/cosangle;
float r = FIX(R.x*acos(a));
return uv*r/sin(r/R.x);
}
vec2 transform(vec2 coord, vec3 stretch, vec2 sinangle, vec2 cosangle)
{
coord = (coord-vec2_splat(0.5))*aspect.xy*stretch.z+stretch.xy;
return (bkwtrans(coord, sinangle, cosangle)/overscan.xy/aspect.xy+vec2_splat(0.5));
}
float corner(vec2 coord)
{
coord = (coord - vec2_splat(0.5)) * overscan.xy + vec2_splat(0.5);
coord = min(coord, vec2_splat(1.0)-coord) * aspect.xy;
vec2 cdist = vec2_splat(cornersize.x);
coord = (cdist - min(coord,cdist));
float dist = sqrt(dot(coord,coord));
return clamp((max(cdist.x,1e-3)-dist)*cornersmooth.x,0.0, 1.0);
}
// Calculate the influence of a scanline on the current pixel.
//
// 'distance' is the distance in texture coordinates from the current
// pixel to the scanline in question.
// 'color' is the colour of the scanline at the horizontal location of
// the current pixel.
vec4 scanlineWeights(float distance, vec4 color)
{
// "wid" controls the width of the scanline beam, for each RGB channel
// The "weights" lines basically specify the formula that gives
// you the profile of the beam, i.e. the intensity as
// a function of distance from the vertical center of the
// scanline. In this case, it is gaussian if width=2, and
// becomes nongaussian for larger widths. Ideally this should
// be normalized so that the integral across the beam is
// independent of its width. That is, for a narrower beam
// "weights" should have a higher peak at the center of the
// scanline than for a wider beam.
#ifdef USEGAUSSIAN
vec4 wid = 0.3 + 0.1 * pow(color, vec4_splat(3.0));
vec4 weights = vec4(distance / wid);
return 0.4 * exp(-weights * weights) / wid;
#else
vec4 wid = 2.0 + 2.0 * pow(color, vec4_splat(4.0));
vec4 weights = vec4_splat(distance / 0.3);
return 1.4 * exp(-pow(weights * inversesqrt(0.5 * wid), wid)) / (0.6 + 0.2 * wid);
#endif
}
void main()
{
// Here's a helpful diagram to keep in mind while trying to
// understand the code:
//
// | | | | |
// -------------------------------
// | | | | |
// | 01 | 11 | 21 | 31 | <-- current scanline
// | | @ | | |
// -------------------------------
// | | | | |
// | 02 | 12 | 22 | 32 | <-- next scanline
// | | | | |
// -------------------------------
// | | | | |
//
// Each character-cell represents a pixel on the output
// surface, "@" represents the current pixel (always somewhere
// in the bottom half of the current scan-line, or the top-half
// of the next scanline). The grid of lines represents the
// edges of the texels of the underlying texture.
// Texture coordinates of the texel containing the active pixel.
vec2 xy;
if (curvature.x > 0.5)
xy = transform(v_texCoord, v_stretch, v_sinangle, v_cosangle);
else
xy = (v_texCoord-vec2_splat(0.5))/overscan.xy+vec2_splat(0.5);
float cval = corner(xy);
// Of all the pixels that are mapped onto the texel we are
// currently rendering, which pixel are we currently rendering?
vec2 ratio_scale = xy * u_tex_size0.xy - vec2_splat(0.5);
#ifdef OVERSAMPLE
float filter = fwidth(ratio_scale.y);
#endif
vec2 uv_ratio = fract(ratio_scale);
// Snap to the center of the underlying texel.
xy = (floor(ratio_scale) + vec2_splat(0.5)) / u_tex_size0.xy;
// Calculate Lanczos scaling coefficients describing the effect
// of various neighbour texels in a scanline on the current
// pixel.
vec4 coeffs = PI * vec4(1.0 + uv_ratio.x, uv_ratio.x, 1.0 - uv_ratio.x, 2.0 - uv_ratio.x);
// Prevent division by zero.
coeffs = FIX(coeffs);
// Lanczos2 kernel.
coeffs = 2.0 * sin(coeffs) * sin(coeffs / 2.0) / (coeffs * coeffs);
// Normalize.
coeffs /= dot(coeffs, vec4_splat(1.0));
// Calculate the effective colour of the current and next
// scanlines at the horizontal location of the current pixel,
// using the Lanczos coefficients above.
vec4 col = clamp(TEX2D(xy + vec2(-v_one.x, 0.0))*coeffs.x +
TEX2D(xy)*coeffs.y +
TEX2D(xy +vec2(v_one.x, 0.0))*coeffs.z +
TEX2D(xy + vec2(2.0 * v_one.x, 0.0))*coeffs.w , 0.0, 1.0);
vec4 col2 = clamp(TEX2D(xy + vec2(-v_one.x, v_one.y))*coeffs.x +
TEX2D(xy + vec2(0.0, v_one.y))*coeffs.y +
TEX2D(xy + v_one)*coeffs.z +
TEX2D(xy + vec2(2.0 * v_one.x, v_one.y))*coeffs.w , 0.0, 1.0);
#ifndef LINEAR_PROCESSING
col = pow(col , vec4_splat(CRTgamma.x));
col2 = pow(col2, vec4_splat(CRTgamma.x));
#endif
// Calculate the influence of the current and next scanlines on
// the current pixel.
vec4 weights = scanlineWeights(uv_ratio.y, col);
vec4 weights2 = scanlineWeights(1.0 - uv_ratio.y, col2);
#ifdef OVERSAMPLE
uv_ratio.y =uv_ratio.y+1.0/3.0*filter;
weights = (weights+scanlineWeights(uv_ratio.y, col))/3.0;
weights2=(weights2+scanlineWeights(abs(1.0-uv_ratio.y), col2))/3.0;
uv_ratio.y =uv_ratio.y-2.0/3.0*filter;
weights=weights+scanlineWeights(abs(uv_ratio.y), col)/3.0;
weights2=weights2+scanlineWeights(abs(1.0-uv_ratio.y), col2)/3.0;
#endif
vec3 mul_res = (col * weights + col2 * weights2).rgb * vec3_splat(cval);
// Convert the image gamma for display on our output device.
mul_res = pow(mul_res, vec3_splat(1.0 / monitorgamma.x));
// Color the texel.
xy = v_texCoord.xy * u_quad_dims.xy / u_tex_size1.xy;
vec3 mask = texture2D(mask_texture, xy).rgb;
mask = mix(vec3_splat(1.0), mask, aperture_strength.x);
gl_FragColor = vec4(mul_res*mask, col.a);
}

View File

@ -0,0 +1,29 @@
$input v_texCoord, v_coeffs
#include "common.sh"
uniform vec4 u_gamma;
uniform vec4 u_tex_size0;
SAMPLER2D(s_tex, 0);
#define TEX2D(v) pow(texture2D(s_tex, v).rgb, vec3_splat(u_gamma.x))
void main()
{
vec3 sum = vec3_splat(0.0);
float onex = 1.0/u_tex_size0.x;
sum += TEX2D(v_texCoord + vec2(-4.0 * onex, 0.0)) * vec3_splat(v_coeffs.w);
sum += TEX2D(v_texCoord + vec2(-3.0 * onex, 0.0)) * vec3_splat(v_coeffs.z);
sum += TEX2D(v_texCoord + vec2(-2.0 * onex, 0.0)) * vec3_splat(v_coeffs.y);
sum += TEX2D(v_texCoord + vec2(-1.0 * onex, 0.0)) * vec3_splat(v_coeffs.x);
sum += TEX2D(v_texCoord);
sum += TEX2D(v_texCoord + vec2(+1.0 * onex, 0.0)) * vec3_splat(v_coeffs.x);
sum += TEX2D(v_texCoord + vec2(+2.0 * onex, 0.0)) * vec3_splat(v_coeffs.y);
sum += TEX2D(v_texCoord + vec2(+3.0 * onex, 0.0)) * vec3_splat(v_coeffs.z);
sum += TEX2D(v_texCoord + vec2(+4.0 * onex, 0.0)) * vec3_splat(v_coeffs.w);
float norm = 1.0 / (1.0 + 2.0*(v_coeffs.x+v_coeffs.y+v_coeffs.z+v_coeffs.w));
gl_FragColor = vec4( pow(sum*vec3_splat(norm), vec3_splat(1.0/u_gamma.x)), 1.0 );
}

View File

@ -0,0 +1,29 @@
$input v_texCoord, v_coeffs
#include "common.sh"
uniform vec4 u_gamma;
uniform vec4 u_tex_size0;
SAMPLER2D(s_tex, 0);
#define TEX2D(v) pow(texture2D(s_tex, v).rgb, vec3_splat(u_gamma.x))
void main()
{
vec3 sum = vec3_splat(0.0);
float oney = 1.0/u_tex_size0.y;
sum += TEX2D(v_texCoord + vec2(0.0, -4.0 * oney)) * vec3_splat(v_coeffs.w);
sum += TEX2D(v_texCoord + vec2(0.0, -3.0 * oney)) * vec3_splat(v_coeffs.z);
sum += TEX2D(v_texCoord + vec2(0.0, -2.0 * oney)) * vec3_splat(v_coeffs.y);
sum += TEX2D(v_texCoord + vec2(0.0, -1.0 * oney)) * vec3_splat(v_coeffs.x);
sum += TEX2D(v_texCoord);
sum += TEX2D(v_texCoord + vec2(0.0, +1.0 * oney)) * vec3_splat(v_coeffs.x);
sum += TEX2D(v_texCoord + vec2(0.0, +2.0 * oney)) * vec3_splat(v_coeffs.y);
sum += TEX2D(v_texCoord + vec2(0.0, +3.0 * oney)) * vec3_splat(v_coeffs.z);
sum += TEX2D(v_texCoord + vec2(0.0, +4.0 * oney)) * vec3_splat(v_coeffs.w);
float norm = 1.0 / (1.0 + 2.0*(v_coeffs.x+v_coeffs.y+v_coeffs.z+v_coeffs.w));
gl_FragColor = vec4( pow(sum*vec3_splat(norm), vec3_splat(1.0/u_gamma.x)), 1.0 );
}

View File

@ -0,0 +1,25 @@
$input v_texCoord
#include "common.sh"
SAMPLER2D(s_screen, 0);
SAMPLER2D(s_phosphor, 1);
uniform vec4 u_phosphor_power;
uniform vec4 u_phosphor_amplitude;
uniform vec4 u_gamma;
void main()
{
vec4 screen = texture2D(s_screen, v_texCoord);
vec4 phosphor = texture2D(s_phosphor, v_texCoord);
vec3 cscrn = pow(screen.rgb, vec3_splat(u_gamma.x));
vec3 cphos = pow(phosphor.rgb, vec3_splat(u_gamma.x));
cphos *= vec3_splat( u_phosphor_amplitude.x / pow(255.0*phosphor.a,u_phosphor_power.x) );
vec3 col = pow(cscrn + cphos, vec3_splat(1.0/u_gamma.x));
gl_FragColor = vec4(col, 1.0);
}

View File

@ -0,0 +1,24 @@
$input v_texCoord
#include "common.sh"
SAMPLER2D(s_screen, 0);
SAMPLER2D(s_phosphor, 1);
uniform vec4 u_phosphor_power;
uniform vec4 u_phosphor_amplitude;
uniform vec4 u_gamma;
void main()
{
vec4 screen = texture2D(s_screen, v_texCoord);
vec4 phosphor = texture2D(s_phosphor, v_texCoord);
vec3 lum = vec3(0.299,0.587,0.114);
float bscrn = dot(pow(screen.rgb,vec3_splat(u_gamma.x)),lum);
float bphos = dot(pow(phosphor.rgb,vec3_splat(u_gamma.x)),lum);
//bscrn /= pow(1.0,u_phosphor_power.x);
bphos /= pow(1.0+255.0*phosphor.a,u_phosphor_power.x);
gl_FragColor = ( bscrn > bphos ? vec4(screen.rgb,1.0/255.0) : vec4(phosphor.rgb,phosphor.a+1.0/255.0) );
}

View File

@ -0,0 +1,11 @@
vec2 v_texCoord : TEXCOORD0 = vec2(0.0, 0.0);
vec3 v_stretch : TEXCOORD1 = vec3(0.0,0.0,0.0);
vec2 v_sinangle : TEXCOORD2 = vec2(0.0,0.0);
vec2 v_cosangle : TEXCOORD3 = vec2(0.0,0.0);
vec2 v_one : TEXCOORD4 = vec2(0.0,0.0);
vec4 v_coeffs : TEXCOORD5 = vec4(0.0,0.0,0.0,0.0);
vec3 a_position : POSITION;
vec4 a_color0 : COLOR0;
vec2 a_texcoord0 : TEXCOORD0;

View File

@ -0,0 +1,96 @@
$input a_position, a_texcoord0, a_color0
$output v_sinangle, v_cosangle, v_stretch, v_one, v_texCoord
/* CRT shader
*
* Copyright (C) 2010-2012 cgwg, Themaister and DOLLS
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*/
#include "common.sh"
uniform vec4 aspect;
uniform vec4 d;
uniform vec4 R;
uniform vec4 angle;
uniform vec4 u_tex_size0;
uniform vec4 u_rotation_type;
#define FIX(c) max(abs(c), 1e-5)
float intersect(vec2 xy , vec2 sinangle, vec2 cosangle)
{
float A = dot(xy,xy)+d.x*d.x;
float B = 2.0*(R.x*(dot(xy,sinangle)-d.x*cosangle.x*cosangle.y)-d.x*d.x);
float C = d.x*d.x + 2.0*R.x*d.x*cosangle.x*cosangle.y;
return (-B-sqrt(B*B-4.0*A*C))/(2.0*A);
}
vec2 bkwtrans(vec2 xy, vec2 sinangle, vec2 cosangle)
{
float c = intersect(xy, sinangle, cosangle);
vec2 pt = vec2_splat(c)*xy;
pt -= vec2_splat(-R.x)*sinangle;
pt /= vec2_splat(R.x);
vec2 tang = sinangle/cosangle;
vec2 poc = pt/cosangle;
float A = dot(tang,tang)+1.0;
float B = -2.0*dot(poc,tang);
float C = dot(poc,poc)-1.0;
float a = (-B+sqrt(B*B-4.0*A*C))/(2.0*A);
vec2 uv = (pt-a*sinangle)/cosangle;
float r = FIX(R.x*acos(a));
return uv*r/sin(r/R.x);
}
vec2 fwtrans(vec2 uv, vec2 sinangle, vec2 cosangle)
{
float r = FIX(sqrt(dot(uv,uv)));
uv *= sin(r/R.x)/r;
float x = 1.0-cos(r/R.x);
float D = d.x/R.x + x*cosangle.x*cosangle.y+dot(uv,sinangle);
return d.x*(uv*cosangle-x*sinangle)/D;
}
vec3 maxscale(vec2 sinangle, vec2 cosangle)
{
vec2 c = bkwtrans(-R.x * sinangle / (1.0 + R.x/d.x*cosangle.x*cosangle.y), sinangle, cosangle);
vec2 a = vec2(0.5,0.5)*aspect.xy;
vec2 lo = vec2(fwtrans(vec2(-a.x,c.y), sinangle, cosangle).x,
fwtrans(vec2(c.x,-a.y), sinangle, cosangle).y)/aspect.xy;
vec2 hi = vec2(fwtrans(vec2(+a.x,c.y), sinangle, cosangle).x,
fwtrans(vec2(c.x,+a.y), sinangle, cosangle).y)/aspect.xy;
return vec3((hi+lo)*aspect.xy*0.5,max(hi.x-lo.x,hi.y-lo.y));
}
void main()
{
// Do the standard vertex processing.
gl_Position = mul(u_viewProj, vec4(a_position.xy, 0.0, 1.0));
v_texCoord = a_texcoord0;
// Precalculate a bunch of useful values we'll need in the fragment
// shader.
vec2 ang;
// if (u_rotation_type.x < 0.5)
// ang = vec2(0.0,angle.x);
// else if (u_rotation_type.x < 1.5)
// ang = vec2(angle.x,0.0);
// else if (u_rotation_type.x < 2.5)
// ang = vec2(0.0,-angle.x);
// else
// ang = vec2(-angle.x,0.0);
ang = angle.xy;
v_sinangle = sin(ang);
v_cosangle = cos(ang);
v_stretch = maxscale(v_sinangle, v_cosangle);
// The size of one texel, in texture-coordinates.
v_one = 1.0 / u_tex_size0.xy;
}

View File

@ -0,0 +1,18 @@
$input a_position, a_texcoord0, a_color0
$output v_texCoord, v_coeffs
#include "common.sh"
uniform vec4 u_tex_size0;
uniform vec4 u_width;
uniform vec4 u_aspect;
void main()
{
float wid = u_width.x*u_tex_size0.x/(320.*u_aspect.x);;
v_coeffs = exp(vec4(1.,4.,9.,16.)*vec4_splat(-1.0/wid/wid));
// Do the standard vertex processing.
gl_Position = mul(u_viewProj, vec4(a_position.xy, 0.0, 1.0));
v_texCoord = a_texcoord0;
}

View File

@ -0,0 +1,18 @@
$input a_position, a_texcoord0, a_color0
$output v_texCoord, v_coeffs
#include "common.sh"
uniform vec4 u_tex_size0;
uniform vec4 u_width;
uniform vec4 u_aspect;
void main()
{
float wid = u_width.x*u_tex_size0.y/(320.*u_aspect.y);
v_coeffs = exp(vec4(1.,4.,9.,16.)*vec4_splat(-1.0/wid/wid));
// Do the standard vertex processing.
gl_Position = mul(u_viewProj, vec4(a_position.xy, 0.0, 1.0));
v_texCoord = a_texcoord0;
}

View File

@ -0,0 +1,11 @@
$input a_position, a_texcoord0, a_color0
$output v_texCoord
#include "common.sh"
void main()
{
// Do the standard vertex processing.
gl_Position = mul(u_viewProj, vec4(a_position.xy, 0.0, 1.0));
v_texCoord = a_texcoord0;
}

View File

@ -0,0 +1,11 @@
$input a_position, a_texcoord0, a_color0
$output v_texCoord
#include "common.sh"
void main()
{
// Do the standard vertex processing.
gl_Position = mul(u_viewProj, vec4(a_position.xy, 0.0, 1.0));
v_texCoord = a_texcoord0;
}