Debian Codegraph @

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

raw
1 { -*- buffer-read-only: t -*- }
2 { DON'T EDIT -- this file was automatically generated from "source/bump_mapping_parallax.vs" }
3 '/* Parallax bump mapping shader effect.' + LineEnding +
4 ' This is added right after bump_mapping.fs.' + LineEnding +
5 ' Included by EnableShaderBumpMapping in ../castlerendererinternalshader.pas unit.' + LineEnding +
6 '*/' + LineEnding +
7 '' + LineEnding +
8 '/* Make castleTranspose() available.' + LineEnding +
9 '' + LineEnding +
10 ' For desktop OpenGL, we could use "#version 120" and get transpose().' + LineEnding +
11 '' + LineEnding +
12 ' But on OpenGLES, it seems easiest to just implement your own transpose().' + LineEnding +
13 ' Or we could require version 3.00,' + LineEnding +
14 ' https://www.khronos.org/registry/OpenGL-Refpages/es3.1/html/transpose.xhtml ,' + LineEnding +
15 ' but this also requires other GLSL changes,' + LineEnding +
16 ' and it seems that iOS would be troublesome anyway:' + LineEnding +
17 ' https://stackoverflow.com/questions/18034677/transpose-a-mat4-in-opengl-es-2-0-glsl' + LineEnding +
18 '*/' + LineEnding +
19 'mat3 castleTranspose(const in mat3 m)' + LineEnding +
20 '{' + LineEnding +
21 ' return mat3(' + LineEnding +
22 ' vec3(m[0].x, m[1].x, m[2].x),' + LineEnding +
23 ' vec3(m[0].y, m[1].y, m[2].y),' + LineEnding +
24 ' vec3(m[0].z, m[1].z, m[2].z)' + LineEnding +
25 ' );' + LineEnding +
26 '}' + LineEnding +
27 '' + LineEnding +
28 '// avoid redeclaring variables when no "separate compilation units" available (OpenGLES)' + LineEnding +
29 '#ifndef GL_ES' + LineEnding +
30 'uniform mat4 castle_ModelViewMatrix;' + LineEnding +
31 '#endif' + LineEnding +
32 '' + LineEnding +
33 'varying vec3 castle_vertex_to_eye_in_tangent_space;' + LineEnding +
34 '' + LineEnding +
35 'void PLUG_bump_mapping_tangent_space_calculations(' + LineEnding +
36 ' const in vec4 vertex_eye, const in mat3 tangent_to_object_space)' + LineEnding +
37 '{' + LineEnding +
38 ' mat3 object_to_tangent_space = castleTranspose(tangent_to_object_space);' + LineEnding +
39 ' mat3 eye_to_object_space = mat3(' + LineEnding +
40 ' castle_ModelViewMatrix[0][0], castle_ModelViewMatrix[1][0], castle_ModelViewMatrix[2][0],' + LineEnding +
41 ' castle_ModelViewMatrix[0][1], castle_ModelViewMatrix[1][1], castle_ModelViewMatrix[2][1],' + LineEnding +
42 ' castle_ModelViewMatrix[0][2], castle_ModelViewMatrix[1][2], castle_ModelViewMatrix[2][2]);' + LineEnding +
43 ' mat3 eye_to_tangent_space = object_to_tangent_space * eye_to_object_space;' + LineEnding +
44 ' /* Theoretically faster implementation below, not fully correct ---' + LineEnding +
45 ' assume that transpose is enough to invert this matrix. Tests proved:' + LineEnding +
46 ' - results seem the same' + LineEnding +
47 ' - but it''s not really faster. */' + LineEnding +
48 ' // mat3 eye_to_tangent_space = castleTranspose(castle_tangent_to_eye_space);' + LineEnding +
49 ' castle_vertex_to_eye_in_tangent_space = normalize(eye_to_tangent_space * (-vec3(vertex_eye)) );' + LineEnding +
50 '' + LineEnding +
51 ' /* PLUG: bump_mapping_parallax_tangent_space_calculations (vertex_eye, eye_to_tangent_space) */' + LineEnding +
52 '}' + LineEnding +
53 ''