Debian Codegraph @

Shaders/secondary_lights.frag

raw
1 // -*-C++-*-
2 #version 120
3
4 uniform int display_xsize;
5 uniform int display_ysize;
6 uniform float field_of_view;
7 uniform float view_pitch_offset;
8 uniform float view_heading_offset;
9
10 float light_distance_fading(in float dist)
11 {
12 return min(1.0, 10000.0/(dist*dist));
13 }
14
15 float fog_backscatter(in float avisibility)
16 {
17 return 0.5* min(1.0,10000.0/(avisibility*avisibility));
18 }
19
20
21
22 vec3 searchlight()
23 {
24
25 vec2 center = vec2 (float(display_xsize) * 0.5, float(display_ysize) * 0.4);
26
27 float headlightIntensity;
28 float lightRadius = (float(display_xsize) *9.16 /field_of_view);
29 float angularDist = length(gl_FragCoord.xy -center);
30
31 if (angularDist < lightRadius)
32 {
33 headlightIntensity = pow(cos(angularDist/lightRadius * 1.57075),2.0);
34 //headlightIntensity = headlightIntensity *
35 //headlightIntensity*= clamp(1.0 + 0.15 * log(1000.0/(dist*dist)),0.0,1.0);
36 return headlightIntensity * vec3 (0.5,0.5, 0.5);
37 }
38 else return vec3 (0.0,0.0,0.0);
39 }
40
41 vec3 flashlight(in vec3 color, in float radius)
42 {
43
44 vec2 center = vec2 (float(display_xsize) * 0.5, float(display_ysize) * 0.4);
45
46 float headlightIntensity;
47 float lightRadius = (float(display_xsize) *radius /field_of_view);
48 float angularDist = length(gl_FragCoord.xy -center);
49
50 if (angularDist < lightRadius)
51 {
52 headlightIntensity = pow(cos(angularDist/lightRadius * 1.57075),2.0);
53 return headlightIntensity * color;
54 }
55 else return vec3 (0.0,0.0,0.0);
56 }
57
58 vec3 landing_light(in float offset, in float offsetv)
59 {
60
61 float fov_h = field_of_view;
62 float fov_v = float(display_ysize)/float(display_xsize) * field_of_view;
63
64 float yaw_offset;
65
66 if (view_heading_offset > 180.0)
67 {yaw_offset = -360.0+view_heading_offset;}
68 else
69 {yaw_offset = view_heading_offset;}
70
71 float x_offset = (float(display_xsize) / fov_h * (yaw_offset + offset));
72 float y_offset = -(float(display_ysize) / fov_v * (view_pitch_offset + offsetv));
73
74 vec2 center = vec2 (float(display_xsize) * 0.5 + x_offset, float(display_ysize) * 0.4 + y_offset);
75
76
77
78 float landingLightIntensity;
79 float lightRadius = (float(display_xsize) *9.16 /field_of_view);
80 float angularDist = length(gl_FragCoord.xy -center);
81
82 if (angularDist < lightRadius)
83 {
84 landingLightIntensity = pow(cos(angularDist/lightRadius * 1.57075),2.0);
85 //landingLightIntensity *= min(1.0, 10000.0/(dist*dist));
86 return landingLightIntensity * vec3 (0.5,0.5, 0.5);
87 }
88 else return vec3 (0.0,0.0,0.0);
89
90 }
91
92
93 vec3 addLights(in vec3 color1, in vec3 color2)
94 {
95 vec3 outcolor;
96
97 outcolor.r = 0.14 * log(exp(color1.r/0.14) + exp(color2.r/0.14)-1.0);
98 outcolor.g = 0.14 * log(exp(color1.g/0.14) + exp(color2.g/0.14)-1.0);
99 outcolor.b = 0.14 * log(exp(color1.b/0.14) + exp(color2.b/0.14)-1.0);
100
101 return outcolor;
102 }