1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2024-12-29 03:19:44 +00:00
OpenMW/files/shaders/compatibility/terrain.vert

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

74 lines
2.1 KiB
GLSL
Raw Normal View History

2022-04-24 15:29:16 +00:00
#version 120
#if @useUBO
#extension GL_ARB_uniform_buffer_object : require
#endif
#if @useGPUShader4
#extension GL_EXT_gpu_shader4: require
#endif
2021-02-21 18:38:15 +00:00
2023-02-25 19:03:39 +00:00
#include "lib/core/vertex.h.glsl"
varying vec2 uv;
2020-03-14 12:39:32 +00:00
varying float euclideanDepth;
varying float linearDepth;
#define PER_PIXEL_LIGHTING (@normalMap || @specularMap || @forcePPL)
#if !PER_PIXEL_LIGHTING
2020-12-19 17:17:42 +00:00
centroid varying vec3 passLighting;
centroid varying vec3 passSpecular;
2018-05-11 18:15:04 +00:00
centroid varying vec3 shadowDiffuseLighting;
centroid varying vec3 shadowSpecularLighting;
#endif
2016-02-20 18:54:47 +00:00
varying vec3 passViewPos;
2016-03-22 20:00:31 +00:00
varying vec3 passNormal;
2020-12-19 17:17:42 +00:00
#include "vertexcolors.glsl"
#include "shadows_vertex.glsl"
#include "compatibility/normals.glsl"
2021-03-28 18:06:00 +00:00
2023-02-25 19:03:39 +00:00
#include "lib/light/lighting.glsl"
#include "lib/view/depth.glsl"
void main(void)
{
2023-02-25 19:03:39 +00:00
gl_Position = modelToClip(gl_Vertex);
2023-02-25 19:03:39 +00:00
vec4 viewPos = modelToView(gl_Vertex);
gl_ClipVertex = viewPos;
2020-03-14 12:39:32 +00:00
euclideanDepth = length(viewPos.xyz);
linearDepth = getLinearDepth(gl_Position.z, viewPos.z);
2020-06-15 08:43:51 +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;
normalToViewMatrix = gl_NormalMatrix;
#if @normalMap
mat3 tbnMatrix = generateTangentSpace(vec4(1.0, 0.0, 0.0, 1.0), passNormal);
tbnMatrix[0] = normalize(cross(tbnMatrix[2], tbnMatrix[1])); // note, now we need to re-cross to derive tangent again because it wasn't orthonormal
normalToViewMatrix *= tbnMatrix;
#endif
#if !PER_PIXEL_LIGHTING || @shadows_enabled
vec3 viewNormal = normalize(gl_NormalMatrix * passNormal);
#endif
2020-12-19 17:17:42 +00:00
#if !PER_PIXEL_LIGHTING
vec3 diffuseLight, ambientLight, specularLight;
doLighting(viewPos.xyz, viewNormal, gl_FrontMaterial.shininess, diffuseLight, ambientLight, specularLight, shadowDiffuseLighting, shadowSpecularLighting);
2020-12-19 17:17:42 +00:00
passLighting = getDiffuseColor().xyz * diffuseLight + getAmbientColor().xyz * ambientLight + getEmissionColor().xyz;
passSpecular = getSpecularColor().xyz * specularLight;
clampLightingResult(passLighting);
2020-12-19 17:17:42 +00:00
shadowDiffuseLighting *= getDiffuseColor().xyz;
shadowSpecularLighting *= getSpecularColor().xyz;
2020-12-19 17:17:42 +00:00
#endif
uv = gl_MultiTexCoord0.xy;
2017-09-20 23:25:48 +00:00
2020-06-15 08:43:51 +00:00
#if (@shadows_enabled)
setupShadowCoords(viewPos, viewNormal);
2020-06-15 08:43:51 +00:00
#endif
}