Debian Codegraph @

src/scene/glsl/source/bump_mapping.vs

raw
1 /* Bump mapping shader effect.
2 Included by EnableShaderBumpMapping in ../castlerendererinternalshader.pas unit.
3 */
4
5 attribute vec3 castle_Tangent;
6 // attribute vec3 castle_bitangent; // GLSL doesn't receive this vector anymore, instead GPU can compute it
7 varying mat3 castle_tangent_to_eye_space;
8
9 // avoid redeclaring variables when no "separate compilation units" available (OpenGLES)
10 #ifndef GL_ES
11 #if defined(CASTLE_HAS_NORMALS)
12 uniform mat3 castle_NormalMatrix;
13 attribute vec3 castle_Normal;
14 #endif
15 #endif
16
17 void PLUG_vertex_eye_space(const in vec4 vertex_eye, const in vec3 normal_eye)
18 {
19 #if defined(CASTLE_HAS_NORMALS)
20 vec3 bitangent = cross(castle_Normal, castle_Tangent);
21 mat3 castle_tangent_to_object_space = mat3(
22 castle_Tangent,
23 bitangent,
24 castle_Normal
25 );
26 castle_tangent_to_eye_space = castle_NormalMatrix * castle_tangent_to_object_space;
27 #else
28 /* Fallback in case you use bump mapping with unlit material that ignores normals. */
29 castle_tangent_to_eye_space = mat3(1.0);
30 #endif
31
32 /* PLUG: bump_mapping_tangent_space_calculations (vertex_eye, castle_tangent_to_object_space) */
33 }