1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-25 06:35:30 +00:00
OpenMW/files/shaders/compatibility/bs/nolighting.vert

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

70 lines
1.6 KiB
GLSL
Raw Normal View History

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"
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;
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);
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;
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));
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
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
}