2022-04-24 15:29:16 +00:00
|
|
|
#version 120
|
2022-04-04 22:51:23 +02:00
|
|
|
|
2021-03-31 22:05:47 -07:00
|
|
|
#if @useUBO
|
|
|
|
#extension GL_ARB_uniform_buffer_object : require
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if @useGPUShader4
|
|
|
|
#extension GL_EXT_gpu_shader4: require
|
|
|
|
#endif
|
|
|
|
|
2023-02-26 14:31:41 -08:00
|
|
|
#define PER_PIXEL_LIGHTING 1
|
|
|
|
|
2023-02-25 11:03:39 -08:00
|
|
|
#include "lib/core/vertex.h.glsl"
|
2023-02-26 14:31:41 -08:00
|
|
|
|
2020-12-17 00:46:09 +03:00
|
|
|
#if @diffuseMap
|
|
|
|
varying vec2 diffuseMapUV;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if @emissiveMap
|
|
|
|
varying vec2 emissiveMapUV;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if @normalMap
|
|
|
|
varying vec2 normalMapUV;
|
|
|
|
varying vec4 passTangent;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
varying float euclideanDepth;
|
|
|
|
varying float linearDepth;
|
|
|
|
|
|
|
|
varying vec3 passViewPos;
|
|
|
|
varying vec3 passNormal;
|
|
|
|
|
2023-02-25 11:03:39 -08:00
|
|
|
#include "lib/light/lighting.glsl"
|
|
|
|
#include "lib/view/depth.glsl"
|
2020-12-17 00:46:09 +03:00
|
|
|
|
2023-02-26 14:31:41 -08:00
|
|
|
#include "compatibility/vertexcolors.glsl"
|
|
|
|
#include "compatibility/shadows_vertex.glsl"
|
2023-12-10 21:45:15 +03:00
|
|
|
#include "compatibility/normals.glsl"
|
2023-02-26 14:31:41 -08:00
|
|
|
|
2020-12-17 00:46:09 +03:00
|
|
|
void main(void)
|
|
|
|
{
|
2023-02-25 11:03:39 -08:00
|
|
|
gl_Position = modelToClip(gl_Vertex);
|
2020-12-17 00:46:09 +03:00
|
|
|
|
2023-02-25 11:03:39 -08:00
|
|
|
vec4 viewPos = modelToView(gl_Vertex);
|
2020-12-17 00:46:09 +03:00
|
|
|
gl_ClipVertex = viewPos;
|
|
|
|
euclideanDepth = length(viewPos.xyz);
|
2021-07-09 10:05:27 -07:00
|
|
|
linearDepth = getLinearDepth(gl_Position.z, viewPos.z);
|
2023-12-10 21:45:15 +03:00
|
|
|
passColor = gl_Color;
|
|
|
|
passViewPos = viewPos.xyz;
|
|
|
|
passNormal = gl_Normal.xyz;
|
|
|
|
normalToViewMatrix = gl_NormalMatrix;
|
|
|
|
|
|
|
|
#if @normalMap
|
|
|
|
normalToViewMatrix *= generateTangentSpace(gl_MultiTexCoord7.xyzw, passNormal);
|
|
|
|
#endif
|
2020-12-17 00:46:09 +03:00
|
|
|
|
|
|
|
#if @diffuseMap
|
|
|
|
diffuseMapUV = (gl_TextureMatrix[@diffuseMapUV] * gl_MultiTexCoord@diffuseMapUV).xy;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if @emissiveMap
|
|
|
|
emissiveMapUV = (gl_TextureMatrix[@emissiveMapUV] * gl_MultiTexCoord@emissiveMapUV).xy;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if @normalMap
|
|
|
|
normalMapUV = (gl_TextureMatrix[@normalMapUV] * gl_MultiTexCoord@normalMapUV).xy;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#if @shadows_enabled
|
2023-12-30 02:43:38 +03:00
|
|
|
vec3 viewNormal = normalize(gl_NormalMatrix * passNormal);
|
2020-12-17 00:46:09 +03:00
|
|
|
setupShadowCoords(viewPos, viewNormal);
|
|
|
|
#endif
|
|
|
|
}
|