diff options
Diffstat (limited to 'shaders/final.fragment')
-rw-r--r-- | shaders/final.fragment | 50 |
1 files changed, 43 insertions, 7 deletions
diff --git a/shaders/final.fragment b/shaders/final.fragment index c900973..5feccb9 100644 --- a/shaders/final.fragment +++ b/shaders/final.fragment | |||
@@ -1,7 +1,10 @@ | |||
1 | #version 330 core | 1 | #version 330 core |
2 | 2 | ||
3 | in vec2 UV; | 3 | in vec2 UV; |
4 | in vec3 norm; | 4 | in vec3 normIn; |
5 | in vec3 camDirIn; | ||
6 | in vec3 lightDirIn; | ||
7 | //in vec3 vertPos; | ||
5 | 8 | ||
6 | out vec3 color; | 9 | out vec3 color; |
7 | 10 | ||
@@ -10,20 +13,19 @@ uniform sampler2D scanlinestex; | |||
10 | 13 | ||
11 | const vec2 UVScalar = vec2(1.0, 1.0); | 14 | const vec2 UVScalar = vec2(1.0, 1.0); |
12 | const vec2 UVOffset = vec2(0.0, 0.0); | 15 | const vec2 UVOffset = vec2(0.0, 0.0); |
13 | const vec2 CRTMask_Scale = vec2(85.0, 153.6); | 16 | const vec2 CRTMask_Scale = vec2(85.0, 153.6)*4.0; |
14 | const vec2 CRTMask_Offset = vec2(0.0, 0.0); | 17 | const vec2 CRTMask_Offset = vec2(0.0, 0.0); |
15 | const float Tuning_Overscan = 1.0; | 18 | const float Tuning_Overscan = 1.0; |
16 | const float Tuning_Dimming = 0.5; | 19 | const float Tuning_Dimming = 0.0; |
17 | const float Tuning_Satur = 1.35; | 20 | const float Tuning_Satur = 1.35; |
18 | const float Tuning_ReflScalar = 0.3; | 21 | const float Tuning_ReflScalar = 0.3; |
19 | const float Tuning_Barrel = 0.12; | 22 | const float Tuning_Barrel = 0; //0.12; |
20 | const float Tuning_Scanline_Brightness = 0.25; | 23 | const float Tuning_Scanline_Brightness = 0.5; |
21 | const float Tuning_Scanline_Opacity = 0.5; | 24 | const float Tuning_Scanline_Opacity = 0.5; |
22 | const float Tuning_Diff_Brightness = 0.5; | 25 | const float Tuning_Diff_Brightness = 0.5; |
23 | const float Tuning_Spec_Brightness = 0.35; | 26 | const float Tuning_Spec_Brightness = 0.35; |
24 | const float Tuning_Spec_Power = 50.0; | 27 | const float Tuning_Spec_Power = 50.0; |
25 | const float Tuning_Fres_Brightness = 1.0; | 28 | const float Tuning_Fres_Brightness = 1.0; |
26 | const vec3 Tuning_LightPos = vec3(5.0, -10.0, 0.0); | ||
27 | 29 | ||
28 | vec4 sampleCRT(vec2 uv) | 30 | vec4 sampleCRT(vec2 uv) |
29 | { | 31 | { |
@@ -52,5 +54,39 @@ vec4 sampleCRT(vec2 uv) | |||
52 | 54 | ||
53 | void main() | 55 | void main() |
54 | { | 56 | { |
55 | color = sampleCRT(UV).rgb; | 57 | vec3 norm = normalize(normIn); |
58 | vec3 camDir = normalize(camDirIn); | ||
59 | vec3 lightDir = normalize(lightDirIn); | ||
60 | //vec3 refl = reflect(camDir, normIn); | ||
61 | |||
62 | float diffuse = clamp(dot(norm, lightDir), 0.0f, 1.0f); | ||
63 | vec4 colordiff = vec4(0.175, 0.15, 0.2, 1) * diffuse * Tuning_Diff_Brightness; | ||
64 | |||
65 | vec3 halfVec = normalize(lightDir + camDir); | ||
66 | float spec = clamp(dot(norm, halfVec), 0.0f, 1.0f); | ||
67 | spec = pow(spec, Tuning_Spec_Power); | ||
68 | vec4 colorspec = vec4(0.25, 0.25, 0.25, 1) * spec * Tuning_Spec_Brightness; | ||
69 | |||
70 | float fres = 1.0f - dot(camDir, norm); | ||
71 | fres = (fres*fres) * Tuning_Fres_Brightness; | ||
72 | vec4 colorfres = vec4(0.45, 0.4, 0.5, 1) * fres;/* | ||
73 | |||
74 | float lambertian = max(dot(camDirNorm,norm),0.0); | ||
75 | vec4 colorspec = vec4(0.0); | ||
76 | vec4 colorfres = vec4(0.0); | ||
77 | vec4 colordiff = vec4(0.175,0.15,0.2,1) * lambertian * Tuning_Diff_Brightness; | ||
78 | if (lambertian > 0.0) | ||
79 | { | ||
80 | vec3 viewDir = normalize(-vertPos); | ||
81 | vec3 halfDir = normalize(camDirNorm + viewDir); | ||
82 | float specAngle = max(dot(halfDir, normnorm), 0.0); | ||
83 | colorspec = vec4(0.25,0.25,0.25,1) * pow(specAngle, Tuning_Spec_Power) * Tuning_Spec_Brightness; | ||
84 | }*/ | ||
85 | |||
86 | vec4 emissive = sampleCRT(UV); | ||
87 | |||
88 | vec4 nearfinal = colorfres + colordiff + colorspec + emissive; | ||
89 | vec4 final = nearfinal * mix(vec4(1,1,1,1), vec4(0,0,0,0), Tuning_Dimming); | ||
90 | |||
91 | color = final.rgb; | ||
56 | } | 92 | } |