diff options
Diffstat (limited to 'shaders')
-rw-r--r-- | shaders/bloom1.fragment | 3 | ||||
-rw-r--r-- | shaders/bloom2.fragment | 3 | ||||
-rw-r--r-- | shaders/final.fragment | 14 |
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 | ||
7 | uniform sampler2D screenTex; | 7 | uniform sampler2D screenTex; |
8 | uniform float iGlobalTime; | 8 | uniform float iGlobalTime; |
9 | uniform vec2 resolution; | ||
9 | 10 | ||
10 | float nrand(vec2 n) | 11 | float 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; | |||
7 | uniform sampler2D screenTex; | 7 | uniform sampler2D screenTex; |
8 | uniform sampler2D downsampledTex; | 8 | uniform sampler2D downsampledTex; |
9 | uniform float iGlobalTime; | 9 | uniform float iGlobalTime; |
10 | uniform vec2 resolution; | ||
10 | 11 | ||
11 | float nrand(vec2 n) | 12 | float 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; | |||
11 | uniform sampler2D rendertex; | 11 | uniform sampler2D rendertex; |
12 | uniform sampler2D scanlinestex; | 12 | uniform sampler2D scanlinestex; |
13 | 13 | ||
14 | const vec2 UVScalar = vec2(1.0, 1.0); | ||
15 | const vec2 UVOffset = vec2(0.0, 0.0); | ||
16 | const vec2 CRTMask_Scale = vec2(85.0, 153.6)*4.0; | ||
17 | const vec2 CRTMask_Offset = vec2(0.0, 0.0); | ||
18 | const float Tuning_Overscan = 1.08; | 14 | const float Tuning_Overscan = 1.08; |
19 | const float Tuning_Dimming = 0.0; | 15 | const float Tuning_Dimming = 0.0; |
20 | const float Tuning_Satur = 1.0; | 16 | const float Tuning_Satur = 1.0; |
@@ -27,18 +23,18 @@ const float Tuning_Spec_Brightness = 0.35; | |||
27 | const float Tuning_Spec_Power = 50.0; | 23 | const float Tuning_Spec_Power = 50.0; |
28 | const float Tuning_Fres_Brightness = 1.0; | 24 | const float Tuning_Fres_Brightness = 1.0; |
29 | 25 | ||
26 | uniform vec2 resolution; | ||
27 | |||
30 | vec4 sampleCRT(vec2 uv) | 28 | vec4 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); |