| 1 |
/* Steep parallax with self-shading bump mapping shader effect. |
| 2 |
This is added right after bump_mapping.vs and bump_mapping_parallax.vs. |
| 3 |
Included by EnableShaderBumpMapping in ../castlerendererinternalshader.pas unit. |
| 4 |
*/ |
| 5 |
|
| 6 |
varying vec3 castle_light_direction_tangent_space; |
| 7 |
|
| 8 |
/* Note that there's no need to protect castle_LightSource0Position |
| 9 |
from redeclaring, which is usually a problem when |
| 10 |
no "separate compilation units" are available (on OpenGLES). |
| 11 |
In this particular case, using bump mapping forces Phong shading, |
| 12 |
and then lights are calculated in the fragment shader. |
| 13 |
The declaration below is in vertex shader, so it never conflicts. */ |
| 14 |
#ifdef GL_ES |
| 15 |
uniform mediump vec3 castle_LightSource0Position; |
| 16 |
#else |
| 17 |
uniform vec3 castle_LightSource0Position; |
| 18 |
#endif |
| 19 |
|
| 20 |
void PLUG_bump_mapping_parallax_tangent_space_calculations( |
| 21 |
const in vec4 vertex_eye, const in mat3 eye_to_tangent_space) |
| 22 |
{ |
| 23 |
vec3 light_dir = castle_LightSource0Position; |
| 24 |
#ifdef CASTLE_LIGHT0_POSITIONAL |
| 25 |
light_dir -= vec3(vertex_eye); |
| 26 |
#endif |
| 27 |
light_dir = normalize(light_dir); |
| 28 |
castle_light_direction_tangent_space = eye_to_tangent_space * light_dir; |
| 29 |
} |