diff options
Diffstat (limited to 'shaders/final.fragment')
-rw-r--r-- | shaders/final.fragment | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/shaders/final.fragment b/shaders/final.fragment new file mode 100644 index 0000000..c900973 --- /dev/null +++ b/shaders/final.fragment | |||
@@ -0,0 +1,56 @@ | |||
1 | #version 330 core | ||
2 | |||
3 | in vec2 UV; | ||
4 | in vec3 norm; | ||
5 | |||
6 | out vec3 color; | ||
7 | |||
8 | uniform sampler2D rendertex; | ||
9 | uniform sampler2D scanlinestex; | ||
10 | |||
11 | const vec2 UVScalar = vec2(1.0, 1.0); | ||
12 | const vec2 UVOffset = vec2(0.0, 0.0); | ||
13 | const vec2 CRTMask_Scale = vec2(85.0, 153.6); | ||
14 | const vec2 CRTMask_Offset = vec2(0.0, 0.0); | ||
15 | const float Tuning_Overscan = 1.0; | ||
16 | const float Tuning_Dimming = 0.5; | ||
17 | const float Tuning_Satur = 1.35; | ||
18 | const float Tuning_ReflScalar = 0.3; | ||
19 | const float Tuning_Barrel = 0.12; | ||
20 | const float Tuning_Scanline_Brightness = 0.25; | ||
21 | const float Tuning_Scanline_Opacity = 0.5; | ||
22 | const float Tuning_Diff_Brightness = 0.5; | ||
23 | const float Tuning_Spec_Brightness = 0.35; | ||
24 | const float Tuning_Spec_Power = 50.0; | ||
25 | const float Tuning_Fres_Brightness = 1.0; | ||
26 | const vec3 Tuning_LightPos = vec3(5.0, -10.0, 0.0); | ||
27 | |||
28 | vec4 sampleCRT(vec2 uv) | ||
29 | { | ||
30 | vec2 ScaledUV = uv; | ||
31 | ScaledUV *= UVScalar; | ||
32 | ScaledUV += UVOffset; | ||
33 | |||
34 | vec2 scanuv = ScaledUV * CRTMask_Scale; | ||
35 | vec3 scantex = texture(scanlinestex, scanuv).rgb; | ||
36 | scantex += Tuning_Scanline_Brightness; | ||
37 | scantex = mix(vec3(1,1,1), scantex, Tuning_Scanline_Opacity); | ||
38 | |||
39 | vec2 overscanuv = (ScaledUV * Tuning_Overscan) - ((Tuning_Overscan - 1.0f) * 0.5f); | ||
40 | overscanuv = overscanuv - vec2(0.5, 0.5); | ||
41 | float rsq = (overscanuv.x*overscanuv.x) + (overscanuv.y*overscanuv.y); | ||
42 | overscanuv = overscanuv + (overscanuv * (Tuning_Barrel * rsq)) + vec2(0.5,0.5); | ||
43 | |||
44 | vec3 comptex = texture(rendertex, overscanuv).rgb; | ||
45 | |||
46 | vec4 emissive = vec4(comptex * scantex, 1); | ||
47 | float desat = dot(vec4(0.299, 0.587, 0.114, 0.0), emissive); | ||
48 | emissive = mix(vec4(desat, desat, desat, 1), emissive, Tuning_Satur); | ||
49 | |||
50 | return emissive; | ||
51 | } | ||
52 | |||
53 | void main() | ||
54 | { | ||
55 | color = sampleCRT(UV).rgb; | ||
56 | } | ||