Debian Codegraph @

src/scene/glsl/generated-pascal/main_shading_phong.vs.inc

raw
1 { -*- buffer-read-only: t -*- }
2 { DON'T EDIT -- this file was automatically generated from "source/main_shading_phong.vs" }
3 '/* Phong shading GLSL vertex shader.' + LineEnding +
4 ' Used by ../castlerendererinternalshader.pas to construct the final shader.' + LineEnding +
5 ' When you change this file, rerun `make'' and then recompile Pascal sources.' + LineEnding +
6 '*/' + LineEnding +
7 '' + LineEnding +
8 '/* Plug into PLUG-DECLARATIONS-EARLY things that need to be defined' + LineEnding +
9 ' before uniforms below, like definition of CASTLE_HAS_NORMALS.' + LineEnding +
10 ' TODO: Can we unify this with PLUG-DECLARATIONS? */' + LineEnding +
11 '/* PLUG-DECLARATIONS-EARLY */' + LineEnding +
12 '' + LineEnding +
13 'uniform mat4 castle_ModelViewMatrix;' + LineEnding +
14 'uniform mat4 castle_ProjectionMatrix;' + LineEnding +
15 'attribute vec4 castle_Vertex;' + LineEnding +
16 '' + LineEnding +
17 '#if defined(CASTLE_HAS_NORMALS)' + LineEnding +
18 'uniform mat3 castle_NormalMatrix;' + LineEnding +
19 'attribute vec3 castle_Normal;' + LineEnding +
20 '#endif' + LineEnding +
21 '' + LineEnding +
22 '/* PLUG-DECLARATIONS */' + LineEnding +
23 '' + LineEnding +
24 'varying vec4 castle_vertex_eye;' + LineEnding +
25 'varying vec3 castle_normal_eye;' + LineEnding +
26 '' + LineEnding +
27 '#if defined(COLOR_PER_VERTEX_RGB)' + LineEnding +
28 'attribute vec3 castle_ColorPerVertex;' + LineEnding +
29 'varying vec3 castle_ColorPerVertexFragment;' + LineEnding +
30 '#elif defined(COLOR_PER_VERTEX_RGB_ALPHA)' + LineEnding +
31 'attribute vec4 castle_ColorPerVertex;' + LineEnding +
32 'varying vec4 castle_ColorPerVertexFragment;' + LineEnding +
33 '#endif' + LineEnding +
34 '' + LineEnding +
35 '/* Include fragment shader utilities used by both Gouraud and Phong shading. */' + LineEnding +
36 '/* CASTLE-COMMON-CODE */' + LineEnding +
37 '' + LineEnding +
38 'void main(void)' + LineEnding +
39 '{' + LineEnding +
40 ' #ifdef COLOR_PER_VERTEX' + LineEnding +
41 ' castle_ColorPerVertexFragment = castle_ColorPerVertex;' + LineEnding +
42 ' #endif' + LineEnding +
43 '' + LineEnding +
44 ' vec4 vertex_object = castle_Vertex;' + LineEnding +
45 ' vec3 normal_object =' + LineEnding +
46 ' #if defined(CASTLE_HAS_NORMALS)' + LineEnding +
47 ' castle_Normal;' + LineEnding +
48 ' #else' + LineEnding +
49 ' /* When CASTLE_HAS_NORMALS not defined, then TShader.NeedsNormals = false.' + LineEnding +
50 ' Renderer may then not define castle_Normal attribute at all,' + LineEnding +
51 ' so we cannot use it (using it causes invisible objects on ATI GPUs,' + LineEnding +
52 ' even though undefined normal_object value is not used by anything;' + LineEnding +
53 ' see' + LineEnding +
54 ' https://github.com/castle-engine/castle-engine/issues/462' + LineEnding +
55 ' https://trello.com/c/QH9d9A8o/92-bug-unable-to-see-and-use-gizmos )' + LineEnding +
56 ' */' + LineEnding +
57 ' vec3(0.0, 0.0, 1.0);' + LineEnding +
58 ' #endif' + LineEnding +
59 '' + LineEnding +
60 ' /* PLUG: vertex_object_space_change (vertex_object, normal_object) */' + LineEnding +
61 ' /* PLUG: vertex_object_space (vertex_object, normal_object) */' + LineEnding +
62 '' + LineEnding +
63 ' castle_vertex_eye = castle_ModelViewMatrix * vertex_object;' + LineEnding +
64 '' + LineEnding +
65 ' castle_normal_eye =' + LineEnding +
66 ' #if defined(CASTLE_HAS_NORMALS)' + LineEnding +
67 ' /* Although we will normalize it again in the fragment shader' + LineEnding +
68 ' (otherwise interpolated result could be shorter < 1, imagine a case' + LineEnding +
69 ' when normals point the almost opposite directions on the opposite' + LineEnding +
70 ' vertexes), we also have to normalize it in vertex shader (otherwise' + LineEnding +
71 ' a much longer normal on one vertex would pull all the interpolated' + LineEnding +
72 ' normals, thus making their direction invalid in fragment shaders). */' + LineEnding +
73 ' normalize(castle_NormalMatrix * normal_object);' + LineEnding +
74 ' #else' + LineEnding +
75 ' vec3(0.0, 0.0, 1.0);' + LineEnding +
76 ' #endif' + LineEnding +
77 '' + LineEnding +
78 ' /* PLUG: vertex_eye_space (castle_vertex_eye, castle_normal_eye) */' + LineEnding +
79 '' + LineEnding +
80 ' gl_Position = castle_ProjectionMatrix * castle_vertex_eye;' + LineEnding +
81 '}' + LineEnding +
82 ''