summary refs log tree commit diff stats
path: root/shaders
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2015-02-19 22:54:40 -0500
committerKelly Rauchenberger <fefferburbia@gmail.com>2015-02-19 22:54:40 -0500
commite3e5a247c58c6e0b45d81ab61314bd8d1bd530ac (patch)
tree261c046c1dac2ee0473fae547b9a15b0ee46f0c4 /shaders
parentcd48894563052baeddff64f6bbc13ccc7fa6e081 (diff)
downloadtherapy-e3e5a247c58c6e0b45d81ab61314bd8d1bd530ac.tar.gz
therapy-e3e5a247c58c6e0b45d81ab61314bd8d1bd530ac.tar.bz2
therapy-e3e5a247c58c6e0b45d81ab61314bd8d1bd530ac.zip
Added ability to resize window (full screen is really laggy though!)
Diffstat (limited to 'shaders')
-rw-r--r--shaders/bloom1.fragment3
-rw-r--r--shaders/bloom2.fragment3
-rw-r--r--shaders/final.fragment14
3 files changed, 9 insertions, 11 deletions
diff --git a/shaders/bloom1.fragment b/shaders/bloom1.fragment index 4940933..cfb2799 100644 --- a/shaders/bloom1.fragment +++ b/shaders/bloom1.fragment
@@ -6,6 +6,7 @@ out vec3 color;
6 6
7uniform sampler2D screenTex; 7uniform sampler2D screenTex;
8uniform float iGlobalTime; 8uniform float iGlobalTime;
9uniform vec2 resolution;
9 10
10float nrand(vec2 n) 11float nrand(vec2 n)
11{ 12{
@@ -45,7 +46,7 @@ void main()
45 vec2 ofs = fTaps_Poisson[i]; 46 vec2 ofs = fTaps_Poisson[i];
46 ofs = vec2(dot(ofs, basis.xz), dot(ofs, basis.yw)); 47 ofs = vec2(dot(ofs, basis.xz), dot(ofs, basis.yw));
47 48
48 vec2 texcoord = UV + max_siz * ofs / vec2(1024.0,768.0); 49 vec2 texcoord = UV + max_siz * ofs / resolution;
49 sum += texture(screenTex, texcoord, -10.0); 50 sum += texture(screenTex, texcoord, -10.0);
50 } 51 }
51 52
diff --git a/shaders/bloom2.fragment b/shaders/bloom2.fragment index aa69f0f..1d9cac4 100644 --- a/shaders/bloom2.fragment +++ b/shaders/bloom2.fragment
@@ -7,6 +7,7 @@ out vec3 color;
7uniform sampler2D screenTex; 7uniform sampler2D screenTex;
8uniform sampler2D downsampledTex; 8uniform sampler2D downsampledTex;
9uniform float iGlobalTime; 9uniform float iGlobalTime;
10uniform vec2 resolution;
10 11
11float nrand(vec2 n) 12float nrand(vec2 n)
12{ 13{
@@ -46,7 +47,7 @@ void main()
46 vec2 ofs = fTaps_Poisson[i]; 47 vec2 ofs = fTaps_Poisson[i];
47 ofs = vec2(dot(ofs, basis.xz), dot(ofs, basis.yw)); 48 ofs = vec2(dot(ofs, basis.xz), dot(ofs, basis.yw));
48 49
49 vec2 texcoord = UV + max_siz * ofs / vec2(64.0,48.0); 50 vec2 texcoord = UV + max_siz * ofs / (resolution / vec2(16.0));
50 sum += texture(downsampledTex, texcoord, -10.0); 51 sum += texture(downsampledTex, texcoord, -10.0);
51 } 52 }
52 53
diff --git a/shaders/final.fragment b/shaders/final.fragment index 7eeb78e..4a51ad3 100644 --- a/shaders/final.fragment +++ b/shaders/final.fragment
@@ -11,10 +11,6 @@ out vec3 color;
11uniform sampler2D rendertex; 11uniform sampler2D rendertex;
12uniform sampler2D scanlinestex; 12uniform sampler2D scanlinestex;
13 13
14const vec2 UVScalar = vec2(1.0, 1.0);
15const vec2 UVOffset = vec2(0.0, 0.0);
16const vec2 CRTMask_Scale = vec2(85.0, 153.6)*4.0;
17const vec2 CRTMask_Offset = vec2(0.0, 0.0);
18const float Tuning_Overscan = 1.08; 14const float Tuning_Overscan = 1.08;
19const float Tuning_Dimming = 0.0; 15const float Tuning_Dimming = 0.0;
20const float Tuning_Satur = 1.0; 16const float Tuning_Satur = 1.0;
@@ -27,18 +23,18 @@ const float Tuning_Spec_Brightness = 0.35;
27const float Tuning_Spec_Power = 50.0; 23const float Tuning_Spec_Power = 50.0;
28const float Tuning_Fres_Brightness = 1.0; 24const float Tuning_Fres_Brightness = 1.0;
29 25
26uniform vec2 resolution;
27
30vec4 sampleCRT(vec2 uv) 28vec4 sampleCRT(vec2 uv)
31{ 29{
32 vec2 ScaledUV = uv; 30 vec2 CRTMask_Scale = resolution / vec2(6.0, 5.0);
33 ScaledUV *= UVScalar;
34 ScaledUV += UVOffset;
35 31
36 vec2 scanuv = ScaledUV * CRTMask_Scale; 32 vec2 scanuv = uv * CRTMask_Scale;
37 vec3 scantex = texture(scanlinestex, scanuv).rgb; 33 vec3 scantex = texture(scanlinestex, scanuv).rgb;
38 scantex += Tuning_Scanline_Brightness; 34 scantex += Tuning_Scanline_Brightness;
39 scantex = mix(vec3(1,1,1), scantex, Tuning_Scanline_Opacity); 35 scantex = mix(vec3(1,1,1), scantex, Tuning_Scanline_Opacity);
40 36
41 vec2 overscanuv = (ScaledUV * Tuning_Overscan) - ((Tuning_Overscan - 1.0f) * 0.5f); 37 vec2 overscanuv = (uv * Tuning_Overscan) - ((Tuning_Overscan - 1.0f) * 0.5f);
42 overscanuv = overscanuv - vec2(0.5, 0.5); 38 overscanuv = overscanuv - vec2(0.5, 0.5);
43 float rsq = (overscanuv.x*overscanuv.x) + (overscanuv.y*overscanuv.y); 39 float rsq = (overscanuv.x*overscanuv.x) + (overscanuv.y*overscanuv.y);
44 overscanuv = overscanuv + (overscanuv * (Tuning_Barrel * rsq)) + vec2(0.5,0.5); 40 overscanuv = overscanuv + (overscanuv * (Tuning_Barrel * rsq)) + vec2(0.5,0.5);