2020-12-17 00:46:09 +03:00
|
|
|
#version 120
|
|
|
|
|
2023-02-26 14:31:41 -08:00
|
|
|
#if @useUBO
|
|
|
|
#extension GL_ARB_uniform_buffer_object : require
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if @useGPUShader4
|
|
|
|
#extension GL_EXT_gpu_shader4: require
|
|
|
|
#endif
|
|
|
|
|
2023-02-25 11:03:39 -08:00
|
|
|
#include "lib/core/vertex.h.glsl"
|
2021-07-09 10:05:27 -07:00
|
|
|
|
2020-12-17 00:46:09 +03:00
|
|
|
#if @diffuseMap
|
|
|
|
varying vec2 diffuseMapUV;
|
|
|
|
#endif
|
|
|
|
|
2023-02-26 14:31:41 -08:00
|
|
|
varying vec3 passNormal;
|
2023-09-24 12:20:09 +02:00
|
|
|
varying vec3 passViewPos;
|
2020-12-17 00:46:09 +03:00
|
|
|
varying float euclideanDepth;
|
|
|
|
varying float linearDepth;
|
2023-02-26 14:31:41 -08:00
|
|
|
varying float passFalloff;
|
2020-12-17 00:46:09 +03:00
|
|
|
|
|
|
|
uniform bool useFalloff;
|
|
|
|
uniform vec4 falloffParams;
|
|
|
|
|
2023-02-25 11:03:39 -08:00
|
|
|
#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"
|
|
|
|
|
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);
|
2020-12-17 00:46:09 +03:00
|
|
|
|
|
|
|
#if @diffuseMap
|
|
|
|
diffuseMapUV = (gl_TextureMatrix[@diffuseMapUV] * gl_MultiTexCoord@diffuseMapUV).xy;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
passColor = gl_Color;
|
2023-09-24 12:20:09 +02:00
|
|
|
passViewPos = viewPos.xyz;
|
2023-02-26 14:31:41 -08:00
|
|
|
passNormal = gl_Normal.xyz;
|
|
|
|
|
2020-12-17 00:46:09 +03:00
|
|
|
if (useFalloff)
|
|
|
|
{
|
|
|
|
vec3 viewNormal = gl_NormalMatrix * normalize(gl_Normal.xyz);
|
|
|
|
vec3 viewDir = normalize(viewPos.xyz);
|
|
|
|
float viewAngle = abs(dot(viewNormal, viewDir));
|
2023-02-11 23:19:26 +03:00
|
|
|
passFalloff = smoothstep(falloffParams.x, falloffParams.y, viewAngle);
|
|
|
|
|
|
|
|
float startOpacity = min(falloffParams.z, 1.0);
|
|
|
|
float stopOpacity = max(falloffParams.w, 0.0);
|
|
|
|
|
|
|
|
passFalloff = mix(startOpacity, stopOpacity, passFalloff);
|
2020-12-17 00:46:09 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
passFalloff = 1.0;
|
|
|
|
}
|
2023-02-26 14:31:41 -08:00
|
|
|
|
|
|
|
#if @shadows_enabled
|
2023-12-30 02:43:38 +03:00
|
|
|
vec3 viewNormal = normalize(gl_NormalMatrix * passNormal);
|
2023-02-26 14:31:41 -08:00
|
|
|
setupShadowCoords(viewPos, viewNormal);
|
|
|
|
#endif
|
2020-12-17 00:46:09 +03:00
|
|
|
}
|