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

61 lines
1.5 KiB
Plaintext
Raw Normal View History

#version 120
#if @useUBO
#extension GL_ARB_uniform_buffer_object : require
#endif
#if @useGPUShader4
#extension GL_EXT_gpu_shader4: require
#endif
2021-02-21 10:38:15 -08:00
varying vec2 uv;
2020-03-14 16:39:32 +04:00
varying float euclideanDepth;
varying float linearDepth;
#define PER_PIXEL_LIGHTING (@normalMap || @forcePPL)
#if !PER_PIXEL_LIGHTING
2020-12-19 20:17:42 +03:00
centroid varying vec3 passLighting;
2018-05-11 19:15:04 +01:00
centroid varying vec3 shadowDiffuseLighting;
#endif
2016-02-20 19:54:47 +01:00
varying vec3 passViewPos;
2016-03-22 21:00:31 +01:00
varying vec3 passNormal;
2020-12-19 20:17:42 +03:00
#include "vertexcolors.glsl"
#include "shadows_vertex.glsl"
2021-03-28 11:06:00 -07:00
#include "lighting.glsl"
2021-06-01 12:15:25 -07:00
#include "depth.glsl"
void main(void)
{
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
vec4 viewPos = (gl_ModelViewMatrix * gl_Vertex);
gl_ClipVertex = viewPos;
2020-03-14 16:39:32 +04:00
euclideanDepth = length(viewPos.xyz);
2021-06-01 12:15:25 -07:00
linearDepth = getLinearDepth(viewPos);
2020-06-15 12:43:51 +04:00
#if (!PER_PIXEL_LIGHTING || @shadows_enabled)
vec3 viewNormal = normalize((gl_NormalMatrix * gl_Normal).xyz);
2020-06-15 12:43:51 +04:00
#endif
passColor = gl_Color;
2016-03-22 21:00:31 +01:00
passNormal = gl_Normal.xyz;
2016-02-20 19:54:47 +01:00
passViewPos = viewPos.xyz;
2020-12-19 20:17:42 +03:00
#if !PER_PIXEL_LIGHTING
vec3 diffuseLight, ambientLight;
doLighting(viewPos.xyz, viewNormal, diffuseLight, ambientLight, shadowDiffuseLighting);
passLighting = getDiffuseColor().xyz * diffuseLight + getAmbientColor().xyz * ambientLight + getEmissionColor().xyz;
clampLightingResult(passLighting);
2020-12-19 20:17:42 +03:00
shadowDiffuseLighting *= getDiffuseColor().xyz;
#endif
uv = gl_MultiTexCoord0.xy;
2017-09-21 00:25:48 +01:00
2020-06-15 12:43:51 +04:00
#if (@shadows_enabled)
setupShadowCoords(viewPos, viewNormal);
2020-06-15 12:43:51 +04:00
#endif
}