Debian Codegraph @

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

raw
1 { -*- buffer-read-only: t -*- }
2 { DON'T EDIT -- this file was automatically generated from "source/bump_mapping.fs" }
3 '/* Bump mapping shader effect.' + LineEnding +
4 ' Included by EnableShaderBumpMapping in ../castlerendererinternalshader.pas unit.' + LineEnding +
5 '*/' + LineEnding +
6 '' + LineEnding +
7 'varying mat3 castle_tangent_to_eye_space;' + LineEnding +
8 '' + LineEnding +
9 '// declare castle_normal_map, avoiding redeclaring it for GL_ES' + LineEnding +
10 '#ifdef GL_ES' + LineEnding +
11 ' #ifndef castle_normal_map_defined' + LineEnding +
12 ' #define castle_normal_map_defined' + LineEnding +
13 ' uniform sampler2D castle_normal_map;' + LineEnding +
14 ' uniform float castle_normalScale;' + LineEnding +
15 ' #endif' + LineEnding +
16 '#else' + LineEnding +
17 ' uniform sampler2D castle_normal_map;' + LineEnding +
18 ' uniform float castle_normalScale;' + LineEnding +
19 '#endif' + LineEnding +
20 '' + LineEnding +
21 '// avoid redeclaring for GL_ES' + LineEnding +
22 '#ifndef GL_ES' + LineEnding +
23 'varying vec4 castle_TexCoord<NormalMapTextureCoordinatesId>;' + LineEnding +
24 '#endif' + LineEnding +
25 '' + LineEnding +
26 'void PLUG_fragment_eye_space(const vec4 vertex, inout vec3 normal_eye_fragment)' + LineEnding +
27 '{' + LineEnding +
28 ' // Read normal from the texture (the core idea of bump mapping).' + LineEnding +
29 ' // Unpack normals, they are in texture in [0..1] range and we want in [-1..1].' + LineEnding +
30 ' vec3 normal_tangent = texture2D(castle_normal_map,' + LineEnding +
31 ' castle_TexCoord<NormalMapTextureCoordinatesId>.st).xyz * 2.0 - vec3(1.0);' + LineEnding +
32 '' + LineEnding +
33 ' normal_tangent *= vec3(castle_normalScale, castle_normalScale, 1.0);' + LineEnding +
34 '' + LineEnding +
35 ' /* We have to take two-sided lighting into account here, in tangent space.' + LineEnding +
36 ' Simply negating whole normal in eye space (like we do without bump mapping)' + LineEnding +
37 ' would not work good,' + LineEnding +
38 ' check e.g. insides of demo_models/bump_mapping/room_for_parallax_final.wrl. */' + LineEnding +
39 ' if (gl_FrontFacing)' + LineEnding +
40 ' /* Avoid AMD bug http://forums.amd.com/devforum/messageview.cfm?catid=392&threadid=148827&enterthread=y' + LineEnding +
41 ' It causes both (gl_FrontFacing) and (!gl_FrontFacing) to be true...' + LineEnding +
42 ' To minimize the number of problems, never use "if (!gl_FrontFacing)",' + LineEnding +
43 ' only "if (gl_FrontFacing)".' + LineEnding +
44 ' See template_phong.fs for more comments.' + LineEnding +
45 ' */ ; else' + LineEnding +
46 ' normal_tangent.z = -normal_tangent.z;' + LineEnding +
47 '' + LineEnding +
48 ' normal_eye_fragment = normalize(castle_tangent_to_eye_space * normal_tangent);' + LineEnding +
49 '}' + LineEnding +
50 ''