summary refs log tree commit diff stats
path: root/shaders/final.fragment
diff options
context:
space:
mode:
Diffstat (limited to 'shaders/final.fragment')
-rw-r--r--shaders/final.fragment50
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
3in vec2 UV; 3in vec2 UV;
4in vec3 norm; 4in vec3 normIn;
5in vec3 camDirIn;
6in vec3 lightDirIn;
7//in vec3 vertPos;
5 8
6out vec3 color; 9out vec3 color;
7 10
@@ -10,20 +13,19 @@ uniform sampler2D scanlinestex;
10 13
11const vec2 UVScalar = vec2(1.0, 1.0); 14const vec2 UVScalar = vec2(1.0, 1.0);
12const vec2 UVOffset = vec2(0.0, 0.0); 15const vec2 UVOffset = vec2(0.0, 0.0);
13const vec2 CRTMask_Scale = vec2(85.0, 153.6); 16const vec2 CRTMask_Scale = vec2(85.0, 153.6)*4.0;
14const vec2 CRTMask_Offset = vec2(0.0, 0.0); 17const vec2 CRTMask_Offset = vec2(0.0, 0.0);
15const float Tuning_Overscan = 1.0; 18const float Tuning_Overscan = 1.0;
16const float Tuning_Dimming = 0.5; 19const float Tuning_Dimming = 0.0;
17const float Tuning_Satur = 1.35; 20const float Tuning_Satur = 1.35;
18const float Tuning_ReflScalar = 0.3; 21const float Tuning_ReflScalar = 0.3;
19const float Tuning_Barrel = 0.12; 22const float Tuning_Barrel = 0; //0.12;
20const float Tuning_Scanline_Brightness = 0.25; 23const float Tuning_Scanline_Brightness = 0.5;
21const float Tuning_Scanline_Opacity = 0.5; 24const float Tuning_Scanline_Opacity = 0.5;
22const float Tuning_Diff_Brightness = 0.5; 25const float Tuning_Diff_Brightness = 0.5;
23const float Tuning_Spec_Brightness = 0.35; 26const float Tuning_Spec_Brightness = 0.35;
24const float Tuning_Spec_Power = 50.0; 27const float Tuning_Spec_Power = 50.0;
25const float Tuning_Fres_Brightness = 1.0; 28const float Tuning_Fres_Brightness = 1.0;
26const vec3 Tuning_LightPos = vec3(5.0, -10.0, 0.0);
27 29
28vec4 sampleCRT(vec2 uv) 30vec4 sampleCRT(vec2 uv)
29{ 31{
@@ -52,5 +54,39 @@ vec4 sampleCRT(vec2 uv)
52 54
53void main() 55void 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}