2016-02-19 00:30:15 +00:00
|
|
|
#version 120
|
|
|
|
|
|
|
|
varying vec2 uv;
|
2020-03-14 12:39:32 +00:00
|
|
|
varying float euclideanDepth;
|
|
|
|
varying float linearDepth;
|
2016-02-19 00:30:15 +00:00
|
|
|
|
|
|
|
#define PER_PIXEL_LIGHTING (@normalMap || @forcePPL)
|
|
|
|
|
|
|
|
#if !PER_PIXEL_LIGHTING
|
2020-12-19 17:17:42 +00:00
|
|
|
centroid varying vec3 passLighting;
|
2018-05-11 18:15:04 +00:00
|
|
|
centroid varying vec3 shadowDiffuseLighting;
|
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
|
|
|
|
2020-12-19 17:17:42 +00:00
|
|
|
#include "vertexcolors.glsl"
|
2018-06-24 22:40:52 +00:00
|
|
|
#include "shadows_vertex.glsl"
|
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;
|
|
|
|
|
|
|
|
vec4 viewPos = (gl_ModelViewMatrix * gl_Vertex);
|
|
|
|
gl_ClipVertex = viewPos;
|
2020-03-14 12:39:32 +00:00
|
|
|
euclideanDepth = length(viewPos.xyz);
|
|
|
|
linearDepth = gl_Position.z;
|
2020-06-15 08:43:51 +00:00
|
|
|
|
|
|
|
#if (!PER_PIXEL_LIGHTING || @shadows_enabled)
|
2019-01-30 22:28:00 +00:00
|
|
|
vec3 viewNormal = normalize((gl_NormalMatrix * gl_Normal).xyz);
|
2020-06-15 08:43:51 +00:00
|
|
|
#endif
|
2016-02-19 00:30:15 +00:00
|
|
|
|
2020-05-12 15:21:02 +00:00
|
|
|
passColor = gl_Color;
|
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
|
|
|
|
2020-12-19 17:17:42 +00:00
|
|
|
#if !PER_PIXEL_LIGHTING
|
|
|
|
vec3 diffuseLight, ambientLight;
|
|
|
|
doLighting(viewPos.xyz, viewNormal, diffuseLight, ambientLight, shadowDiffuseLighting);
|
|
|
|
passLighting = getDiffuseColor().xyz * diffuseLight + getAmbientColor().xyz * ambientLight + getEmissionColor().xyz;
|
|
|
|
shadowDiffuseLighting *= getDiffuseColor().xyz;
|
|
|
|
#endif
|
|
|
|
|
2016-02-19 00:30:15 +00:00
|
|
|
uv = gl_MultiTexCoord0.xy;
|
2017-09-20 23:25:48 +00:00
|
|
|
|
2020-06-15 08:43:51 +00:00
|
|
|
#if (@shadows_enabled)
|
2019-01-30 22:28:00 +00:00
|
|
|
setupShadowCoords(viewPos, viewNormal);
|
2020-06-15 08:43:51 +00:00
|
|
|
#endif
|
2016-02-19 00:30:15 +00:00
|
|
|
}
|