2016-02-19 00:30:15 +00:00
#version 120
2017-11-07 20:22:45 +00:00
#define SHADOWS @shadows_enabled
2016-02-19 00:30:15 +00:00
varying vec2 uv;
varying float depth;
#define PER_PIXEL_LIGHTING (@normalMap || @forcePPL)
#if !PER_PIXEL_LIGHTING
2018-04-11 21:39:11 +00:00
centroid varying vec4 lighting;
2018-05-11 18:15:04 +00:00
centroid varying vec3 shadowDiffuseLighting;
2016-02-19 00:30:15 +00:00
#else
2018-04-11 21:39:11 +00:00
centroid varying vec4 passColor;
2016-02-19 00:30:15 +00:00
#endif
2016-02-20 18:54:47 +00:00
varying vec3 passViewPos;
2016-03-22 20:00:31 +00:00
varying vec3 passNormal;
2016-02-19 00:30:15 +00:00
2017-11-07 20:22:45 +00:00
#if SHADOWS
2018-06-22 00:02:01 +00:00
@foreach shadow_texture_unit_index @shadow_texture_unit_list
uniform int shadowTextureUnit@shadow_texture_unit_index;
varying vec4 shadowSpaceCoords@shadow_texture_unit_index;
@endforeach
2017-11-07 20:22:45 +00:00
#endif // SHADOWS
2017-09-20 23:25:48 +00:00
2016-02-19 00:30:15 +00:00
#include "lighting.glsl"
void main(void)
{
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
depth = gl_Position.z;
vec4 viewPos = (gl_ModelViewMatrix * gl_Vertex);
gl_ClipVertex = viewPos;
#if !PER_PIXEL_LIGHTING
2016-03-22 20:00:31 +00:00
vec3 viewNormal = normalize((gl_NormalMatrix * gl_Normal).xyz);
2017-09-21 00:59:02 +00:00
lighting = doLighting(viewPos.xyz, viewNormal, gl_Color, shadowDiffuseLighting);
2016-02-19 00:30:15 +00:00
#else
passColor = gl_Color;
#endif
2016-03-22 20:00:31 +00:00
passNormal = gl_Normal.xyz;
2016-02-20 18:54:47 +00:00
passViewPos = viewPos.xyz;
2016-02-19 00:30:15 +00:00
uv = gl_MultiTexCoord0.xy;
2017-09-20 23:25:48 +00:00
2017-11-10 02:02:27 +00:00
#if SHADOWS
2018-06-22 00:02:01 +00:00
// This matrix has the opposite handedness to the others used here, so multiplication must have the vector to the left. Alternatively it could be transposed after construction, but that's extra work for the GPU just to make the code look a tiny bit cleaner.
mat4 eyePlaneMat;
@foreach shadow_texture_unit_index @shadow_texture_unit_list
eyePlaneMat = mat4(gl_EyePlaneS[shadowTextureUnit@shadow_texture_unit_index], gl_EyePlaneT[shadowTextureUnit@shadow_texture_unit_index], gl_EyePlaneR[shadowTextureUnit@shadow_texture_unit_index], gl_EyePlaneQ[shadowTextureUnit@shadow_texture_unit_index]);
shadowSpaceCoords@shadow_texture_unit_index = viewPos * eyePlaneMat;
@endforeach
2017-11-10 02:02:27 +00:00
#endif // SHADOWS
2016-02-19 00:30:15 +00:00
}