Debian Codegraph @

src/scene/glsl/generated-pascal/lighting_model_phong_shading_phong.fs.inc

raw
1 { -*- buffer-read-only: t -*- }
2 { DON'T EDIT -- this file was automatically generated from "source/lighting_model_phong/shading_phong.fs" }
3 '/*' + LineEnding +
4 ' Copyright 2010-2020 Michalis Kamburelis.' + LineEnding +
5 '' + LineEnding +
6 ' This file is part of "Castle Game Engine".' + LineEnding +
7 '' + LineEnding +
8 ' "Castle Game Engine" is free software; see the file COPYING.txt,' + LineEnding +
9 ' included in this distribution, for details about the copyright.' + LineEnding +
10 '' + LineEnding +
11 ' "Castle Game Engine" is distributed in the hope that it will be useful,' + LineEnding +
12 ' but WITHOUT ANY WARRANTY; without even the implied warranty of' + LineEnding +
13 ' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.' + LineEnding +
14 '' + LineEnding +
15 ' ----------------------------------------------------------------------------' + LineEnding +
16 '' + LineEnding +
17 ' Calculate Phong lighting model, in Phong shading. */' + LineEnding +
18 '' + LineEnding +
19 'uniform vec4 castle_MaterialDiffuseAlpha;' + LineEnding +
20 'uniform vec3 castle_MaterialAmbient;' + LineEnding +
21 'uniform vec3 castle_MaterialSpecular;' + LineEnding +
22 'uniform float castle_MaterialShininess;' + LineEnding +
23 'uniform vec3 castle_MaterialEmissive;' + LineEnding +
24 'uniform vec3 castle_GlobalAmbient;' + LineEnding +
25 '' + LineEnding +
26 'uniform vec4 castle_UnlitColor;' + LineEnding +
27 '' + LineEnding +
28 '/* Material ambient color * global (light model) ambient. */' + LineEnding +
29 'vec3 get_ambient_color()' + LineEnding +
30 '{' + LineEnding +
31 ' vec3 ambient = castle_MaterialAmbient;' + LineEnding +
32 ' /* PLUG: material_light_ambient (ambient) */' + LineEnding +
33 ' return ambient * castle_GlobalAmbient;' + LineEnding +
34 '}' + LineEnding +
35 '' + LineEnding +
36 'void calculate_lighting(out vec4 result, const in vec4 vertex_eye, const in vec3 normal_eye)' + LineEnding +
37 '{' + LineEnding +
38 '#ifdef LIT' + LineEnding +
39 ' MaterialInfo material_info;' + LineEnding +
40 '' + LineEnding +
41 ' material_info.ambient = castle_MaterialAmbient;' + LineEnding +
42 ' /* PLUG: material_ambient (material_info.ambient) */' + LineEnding +
43 ' material_info.specular = castle_MaterialSpecular;' + LineEnding +
44 ' /* PLUG: material_specular (material_info.specular) */' + LineEnding +
45 ' material_info.shininess = castle_MaterialShininess;' + LineEnding +
46 ' /* PLUG: material_shininess (material_info.shininess) */' + LineEnding +
47 '' + LineEnding +
48 ' material_info.diffuse_alpha = castle_apply_color_per_vertex(castle_MaterialDiffuseAlpha);' + LineEnding +
49 '' + LineEnding +
50 ' main_texture_apply(material_info.diffuse_alpha, normal_eye);' + LineEnding +
51 '' + LineEnding +
52 ' result = vec4(get_ambient_color(), material_info.diffuse_alpha.a);' + LineEnding +
53 '' + LineEnding +
54 ' /* PLUG: add_light (result, vertex_eye, normal_eye, material_info) */' + LineEnding +
55 '' + LineEnding +
56 ' /* PLUG: material_occlusion (result) */' + LineEnding +
57 '' + LineEnding +
58 ' vec3 emissive = castle_MaterialEmissive;' + LineEnding +
59 ' /* PLUG: material_emissive (emissive) */' + LineEnding +
60 ' result.rgb += emissive;' + LineEnding +
61 '' + LineEnding +
62 ' /* Clamp sum of lights colors to be <= 1. Fixed-function OpenGL does it too.' + LineEnding +
63 ' This isn''t really mandatory, but scenes with many lights could easily' + LineEnding +
64 ' have colors > 1 and then the textures will look "burned out".' + LineEnding +
65 ' Of course, for future HDR rendering we will turn this off. */' + LineEnding +
66 ' result.rgb = min(result.rgb, 1.0);' + LineEnding +
67 '#else' + LineEnding +
68 ' /* Unlit case.' + LineEnding +
69 ' This is only an optimization of the "lit" case' + LineEnding +
70 ' (e.g. no need to do per-light-source processing).' + LineEnding +
71 '' + LineEnding +
72 ' Diffuse color is zero in this case, and we know that it''s not set to non-zero' + LineEnding +
73 ' by castle_ColorPerVertexFragment (since that would make the shape "lit").' + LineEnding +
74 ' So we don''t use castle_apply_color_per_vertex,' + LineEnding +
75 ' and we don''t apply RGB of main_texture_apply (as it would be multiplied by zero).' + LineEnding +
76 ' */' + LineEnding +
77 ' result = castle_UnlitColor;' + LineEnding +
78 '' + LineEnding +
79 ' // Apply emissiveTexture, if exists' + LineEnding +
80 ' /* PLUG: material_emissive (result.rgb) */' + LineEnding +
81 '' + LineEnding +
82 ' // Apply alpha from the diffuseTexture (or Appearance.texture).' + LineEnding +
83 ' // We need to call main_texture_apply for this.' + LineEnding +
84 ' vec4 color_alpha = result;' + LineEnding +
85 ' main_texture_apply(color_alpha, normal_eye);' + LineEnding +
86 ' result.a = color_alpha.a;' + LineEnding +
87 '#endif' + LineEnding +
88 '}' + LineEnding +
89 ''