mirror of https://github.com/OpenMW/openmw.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
62 lines
1.5 KiB
GLSL
62 lines
1.5 KiB
GLSL
#version 120
|
|
|
|
#if @useUBO
|
|
#extension GL_ARB_uniform_buffer_object : require
|
|
#endif
|
|
|
|
#if @useGPUShader4
|
|
#extension GL_EXT_gpu_shader4: require
|
|
#endif
|
|
|
|
#include "openmw_vertex.h.glsl"
|
|
varying vec2 uv;
|
|
varying float euclideanDepth;
|
|
varying float linearDepth;
|
|
|
|
#define PER_PIXEL_LIGHTING (@normalMap || @forcePPL)
|
|
|
|
#if !PER_PIXEL_LIGHTING
|
|
centroid varying vec3 passLighting;
|
|
centroid varying vec3 shadowDiffuseLighting;
|
|
#endif
|
|
varying vec3 passViewPos;
|
|
varying vec3 passNormal;
|
|
|
|
#include "vertexcolors.glsl"
|
|
#include "shadows_vertex.glsl"
|
|
|
|
#include "lighting.glsl"
|
|
#include "depth.glsl"
|
|
|
|
void main(void)
|
|
{
|
|
gl_Position = mw_modelToClip(gl_Vertex);
|
|
|
|
vec4 viewPos = mw_modelToView(gl_Vertex);
|
|
gl_ClipVertex = viewPos;
|
|
euclideanDepth = length(viewPos.xyz);
|
|
linearDepth = getLinearDepth(gl_Position.z, viewPos.z);
|
|
|
|
#if (!PER_PIXEL_LIGHTING || @shadows_enabled)
|
|
vec3 viewNormal = normalize((gl_NormalMatrix * gl_Normal).xyz);
|
|
#endif
|
|
|
|
passColor = gl_Color;
|
|
passNormal = gl_Normal.xyz;
|
|
passViewPos = viewPos.xyz;
|
|
|
|
#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);
|
|
shadowDiffuseLighting *= getDiffuseColor().xyz;
|
|
#endif
|
|
|
|
uv = gl_MultiTexCoord0.xy;
|
|
|
|
#if (@shadows_enabled)
|
|
setupShadowCoords(viewPos, viewNormal);
|
|
#endif
|
|
}
|