mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-08-03 15:27:13 -04:00
97 lines
2.0 KiB
GLSL
97 lines
2.0 KiB
GLSL
#version 120
|
|
|
|
#if @useUBO
|
|
#extension GL_ARB_uniform_buffer_object : require
|
|
#endif
|
|
|
|
#if @useGPUShader4
|
|
#extension GL_EXT_gpu_shader4: require
|
|
#endif
|
|
|
|
#define PER_PIXEL_LIGHTING 1
|
|
|
|
#include "lib/core/vertex.h.glsl"
|
|
#include "lib/nature/leaves.h.glsl"
|
|
|
|
#if @diffuseMap
|
|
varying vec2 diffuseMapUV;
|
|
#endif
|
|
|
|
#if @emissiveMap
|
|
varying vec2 emissiveMapUV;
|
|
#endif
|
|
|
|
#if @normalMap
|
|
varying vec2 normalMapUV;
|
|
varying vec4 passTangent;
|
|
#endif
|
|
|
|
varying float euclideanDepth;
|
|
varying float linearDepth;
|
|
|
|
varying vec3 passViewPos;
|
|
varying vec3 passNormal;
|
|
|
|
#if @treeAnim
|
|
attribute vec3 aLeafParams;
|
|
#endif
|
|
|
|
#include "lib/light/lighting.glsl"
|
|
#include "lib/view/depth.glsl"
|
|
|
|
#include "compatibility/vertexcolors.glsl"
|
|
#include "compatibility/shadows_vertex.glsl"
|
|
#include "compatibility/normals.glsl"
|
|
|
|
void main(void)
|
|
{
|
|
vec4 vertex = gl_Vertex;
|
|
|
|
#if @treeAnim
|
|
vertex = transformLeafVertex(LeafParams(
|
|
aLeafParams.x,
|
|
aLeafParams.y,
|
|
aLeafParams.z
|
|
), gl_Vertex, gl_Color, gl_Normal.xyz);
|
|
#endif
|
|
|
|
#if @diffuseMap
|
|
diffuseMapUV = (gl_TextureMatrix[@diffuseMapUV] * gl_MultiTexCoord@diffuseMapUV).xy;
|
|
#endif
|
|
|
|
#if @shadowCasting
|
|
gl_Position = gl_ModelViewProjectionMatrix * vertex;
|
|
gl_ClipVertex = (gl_ModelViewMatrix * vertex);
|
|
return;
|
|
#endif
|
|
|
|
gl_Position = modelToClip(vertex);
|
|
|
|
vec4 viewPos = modelToView(vertex);
|
|
gl_ClipVertex = viewPos;
|
|
euclideanDepth = length(viewPos.xyz);
|
|
linearDepth = getLinearDepth(gl_Position.z, viewPos.z);
|
|
passColor = gl_Color;
|
|
passViewPos = viewPos.xyz;
|
|
passNormal = gl_Normal.xyz;
|
|
normalToViewMatrix = gl_NormalMatrix;
|
|
|
|
#if @normalMap
|
|
normalToViewMatrix *= generateTangentSpace(gl_MultiTexCoord7.xyzw, passNormal);
|
|
#endif
|
|
|
|
#if @emissiveMap
|
|
emissiveMapUV = (gl_TextureMatrix[@emissiveMapUV] * gl_MultiTexCoord@emissiveMapUV).xy;
|
|
#endif
|
|
|
|
#if @normalMap
|
|
normalMapUV = (gl_TextureMatrix[@normalMapUV] * gl_MultiTexCoord@normalMapUV).xy;
|
|
#endif
|
|
|
|
|
|
#if @shadows_enabled
|
|
vec3 viewNormal = normalize(gl_NormalMatrix * passNormal);
|
|
setupShadowCoords(viewPos, viewNormal);
|
|
#endif
|
|
}
|