This file is indexed.

/usr/share/oolite/Shaders/oolite-default-shader.fragment is in oolite-data 1.77.1-3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
/*
	oolite-default-shader.fragment
	Default fragment shader for Oolite ships.
	
	
	© 2007–2013 Jens Ayton
	
	This is similar to normal ship shaders, but has special controlling
	macros (like OOSTD_DIFFUSE_MAP, OOSTD_SPECULAR etc.) which are specific
	to the default shader.
	
	
	Permission is hereby granted, free of charge, to any person obtaining a copy
	of this software and associated documentation files (the "Software"), to deal
	in the Software without restriction, including without limitation the rights
	to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
	copies of the Software, and to permit persons to whom the Software is
	furnished to do so, subject to the following conditions:
	
	The above copyright notice and this permission notice shall be included in all
	copies or substantial portions of the Software.
	
	THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
	IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
	FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
	AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
	LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
	OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
	SOFTWARE.
*/


#ifndef OOSTD_DIFFUSE_MAP
#define OOSTD_DIFFUSE_MAP 0
#endif


#ifndef OOSTD_DIFFUSE_MAP_IS_CUBE_MAP
#define OOSTD_DIFFUSE_MAP_IS_CUBE_MAP 0
#endif

#ifndef OOSTD_SPECULAR
#define OOSTD_SPECULAR 0
#undef OOSTD_SPECULAR_MAP
#endif

#ifndef OOSTD_SPECULAR_MAP
#define OOSTD_SPECULAR_MAP 0
#endif

#ifndef OOSTD_NORMAL_MAP
#define OOSTD_NORMAL_MAP 0
#endif

#ifndef OOSTD_NORMAL_AND_PARALLAX_MAP
#define OOSTD_NORMAL_AND_PARALLAX_MAP 0
#endif

#ifndef OOSTD_EMISSION
#define OOSTD_EMISSION 0
#endif

#ifndef OOSTD_EMISSION_MAP
#define OOSTD_EMISSION_MAP 0
#endif

#ifndef OOSTD_ILLUMINATION_MAP
#define OOSTD_ILLUMINATION_MAP 0
#endif

#ifndef OOSTD_EMISSION_AND_ILLUMINATION_MAP
#define OOSTD_EMISSION_AND_ILLUMINATION_MAP 0
#endif


#if OOSTD_EMISSION_AND_ILLUMINATION_MAP && !OOSTD_EMISSION_MAP
#undef OOSTD_EMISSION_MAP
#define OOSTD_EMISSION_MAP 1
#endif
#if OOSTD_EMISSION_AND_ILLUMINATION_MAP && OOSTD_ILLUMINATION_MAP
#undef OOSTD_EMISSION_AND_ILLUMINATION_MAP
#define OOSTD_EMISSION_AND_ILLUMINATION_MAP 0
#endif
#if OOSTD_NORMAL_AND_PARALLAX_MAP && !OOSTD_NORMAL_MAP
#undef OOSTD_NORMAL_AND_PARALLAX_MAP
#define OOSTD_NORMAL_AND_PARALLAX_MAP 0
#endif


#define NEED_EYE_VECTOR (OOSTD_SPECULAR || OOSTD_NORMAL_AND_PARALLAX_MAP)

#define HAVE_ILLUMINATION (OOSTD_EMISSION_AND_ILLUMINATION_MAP || OOSTD_ILLUMINATION_MAP)


#if NEED_EYE_VECTOR
varying vec3			vEyeVector;
#endif

varying vec2			vTexCoord;

varying vec3			vLight1Vector;

#if OOSTD_DIFFUSE_MAP
#if !OOSTD_DIFFUSE_MAP_IS_CUBE_MAP
// Standard 2D diffuse map
uniform sampler2D		uDiffuseMap;
#else
// Cube diffuse map
uniform samplerCube		uDiffuseMap;
varying vec3			vCubeTexCoords;
#endif
#endif


#if OOSTD_SPECULAR_MAP
uniform sampler2D		uSpecularMap;
#endif

#if OOSTD_EMISSION_MAP
uniform sampler2D		uEmissionMap;
#endif

#if OOSTD_ILLUMINATION_MAP
uniform sampler2D		uIlluminationMap;
#endif

#if OOSTD_NORMAL_MAP
uniform sampler2D		uNormalMap;
#endif

#if OOSTD_NORMAL_AND_PARALLAX_MAP
uniform float			uParallaxScale;
uniform float			uParallaxBias;
#endif


vec4 CalcDiffuseLight(in vec3 lightVector, in vec3 normal, in vec4 lightColor)
{
#if OOSTD_NORMAL_MAP
	float intensity = dot(normal, lightVector);
#else
	// dot(v, (0,0,1)) is v.x*0 + v.y*0 + v.z*1 = v.z
	float intensity = lightVector.z;
#endif
	intensity = max(intensity, 0.0);
	return lightColor * intensity;
}


vec4 CalcSpecularLight(in vec3 lightVector, in vec3 eyeVector, in float exponent, in vec3 normal, in vec4 lightColor)
{
#if OOSTD_NORMAL_MAP
	vec3 reflection = -reflect(lightVector, normal);
#else
	/*	reflect(I, N) is defined as I - 2 * dot(N, I) * N
		If N is (0,0,1), this becomes (I.x,I.y,-I.z).
		Note that we want it negated as per above.
	*/
	vec3 reflection = vec3(-lightVector.x, -lightVector.y, lightVector.z);
#endif
	float intensity = dot(reflection, eyeVector);
	intensity = pow(max(intensity, 0.0), exponent);
	return lightColor * intensity;
}


#ifndef OO_REDUCED_COMPLEXITY
uniform float			uHullHeatLevel;
uniform float			uTime;


// Irregular flickering function.
float Pulse(in float value, in float timeScale)
{
	float t = uTime * timeScale;   
	
	float s0 = t;
	s0 -= floor(s0);
	float sum = abs( s0 - 0.5);
	
	float s1 = t * 0.7 - 0.05;
	s1 -= floor(s1);
	sum += abs(s1 - 0.5) - 0.25;
	
	float s2 = t * 1.3 - 0.3;
	s2 -= floor(s2);
	sum += abs(s2 - 0.5) - 0.25;
	
	float s3 = t * 5.09 - 0.6;
	s3 -= floor(s3);
	sum += abs(s3 - 0.5) - 0.25;
	
	return (sum * 0.1 + 0.9) * value;
}


// Colour ramp from black through reddish brown/dark orange to yellow-white.
vec4 TemperatureGlow(in float level)
{
	vec4 result = vec4(0);
	
	result.r = level;
	result.g = level * level * level;
	result.b = max(level - 0.7, 0.0) * 2.0;
	result.a = 1.0;
	
	return result;	
}
#endif


void main(void)
{
	vec4 totalColor = vec4(0);
	
	// Get eye vector
#if NEED_EYE_VECTOR
	vec3 eyeVector = normalize(vEyeVector);
#endif
	
	// Get texture coords, using parallax mapping if appropriate
#if OOSTD_NORMAL_AND_PARALLAX_MAP
	float parallax = texture2D(uNormalMap, vTexCoord).a;
	parallax = parallax * uParallaxScale + uParallaxBias;
	vec2 texCoord = vTexCoord - parallax * eyeVector.xy * vec2(-1.0, 1.0);
#else
	#define texCoord vTexCoord
#endif
	
	// Get normal
#if OOSTD_NORMAL_MAP
	vec3 normal = normalize(texture2D(uNormalMap, texCoord).rgb - 0.5);
#else
	const vec3 normal = vec3(0.0, 0.0, 1.0);
#endif
	
	// Get light vectors
	vec3 lightVector = normalize(vLight1Vector);
	
	// Get ambient colour
	vec4 ambientLight = gl_LightModel.ambient;
	
	// Get emission colour
#if OOSTD_EMISSION || OOSTD_EMISSION_MAP
	vec4 emissionColor = vec4(1.0);
#if OOSTD_EMISSION
	emissionColor *= gl_FrontMaterial.emission;
#endif
#if OOSTD_EMISSION_MAP
	vec4 emissionMapColor = texture2D(uEmissionMap, texCoord);
	emissionColor *= emissionMapColor;
#endif
	emissionColor.a = 1.0;
	totalColor += emissionColor;
#endif
	
	// Get illumination colour
#if OOSTD_EMISSION_AND_ILLUMINATION_MAP
	// Use alpha channel of emission map as white illumination
	vec4 illuminationMapLight = vec4(emissionMapColor.aaa, 1.0);
#elif OOSTD_ILLUMINATION_MAP
	vec4 illuminationMapLight = texture2D(uIlluminationMap, texCoord);
#endif
#ifdef OOSTD_ILLUMINATION_COLOR
	// OOSTD_ILLUMINATION_COLOR, if defined, is a vec4() declaration.
	illuminationMapLight *= OOSTD_ILLUMINATION_COLOR;
#endif
	
	vec4 diffuseLight = vec4(0);
	diffuseLight += CalcDiffuseLight(lightVector, normal, gl_LightSource[1].diffuse);
	
#if HAVE_ILLUMINATION
	diffuseLight += illuminationMapLight;
#endif
	
	// Get specular parameters
#if OOSTD_SPECULAR_MAP
	vec4 specularMapColor = texture2D(uSpecularMap, texCoord);
	float specularExponentLevel = pow(specularMapColor.a, 2.0) + 0.001;
	specularMapColor.a = 1.0;
	#define APPLY_MAPPED_EXPONENT exponent = (exponent - 1.0) * specularExponentLevel + 1.0
#else
	#define APPLY_MAPPED_EXPONENT exponent += 0.001
#endif
	
	// Calculate specular light
#if OOSTD_SPECULAR
	vec4 specularLight = vec4(0);
	float exponent = gl_FrontMaterial.shininess;
	APPLY_MAPPED_EXPONENT;
	specularLight += CalcSpecularLight(lightVector, eyeVector, exponent, normal, gl_LightSource[1].specular);
	specularLight.a = 1.0;
#endif
	
	vec4 ambientColor = gl_FrontMaterial.ambient;
	vec4 diffuseColor = gl_FrontMaterial.diffuse;
#if OOSTD_SPECULAR
	vec4 specularColor = gl_FrontMaterial.specular;
#endif
#if OOSTD_SPECULAR_MAP
	specularColor *= specularMapColor;
#endif

#if OOSTD_DIFFUSE_MAP
#if !OOSTD_DIFFUSE_MAP_IS_CUBE_MAP
	vec4 diffuseMapColor = texture2D(uDiffuseMap, texCoord);
#else
	vec4 diffuseMapColor = textureCube(uDiffuseMap, vCubeTexCoords);
#endif
	diffuseMapColor.a = 1.0;
	diffuseColor *= diffuseMapColor;
	ambientColor *= diffuseMapColor;
#endif
	
	totalColor += ambientColor * ambientLight + diffuseColor * diffuseLight;
#if OOSTD_SPECULAR
	totalColor += specularColor * specularLight;
#endif
	
#ifndef OO_REDUCED_COMPLEXITY
	// Heat glow
	float hullHeat = max(uHullHeatLevel - 0.5, 0.0) * 2.0;
	hullHeat = Pulse(hullHeat * hullHeat, 0.1);
	totalColor += TemperatureGlow(hullHeat);
#endif
	
	gl_FragColor = totalColor;
}