1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-03-26 22:10:28 +00:00
openmw-tes3mp/files/shaders/objects_vertex.glsl
2016-02-18 19:37:59 +01:00

55 lines
1.2 KiB
GLSL

#version 120
#if @diffuseMap
varying vec2 diffuseMapUV;
#endif
#if @darkMap
varying vec2 darkMapUV;
#endif
#if @detailMap
varying vec2 detailMapUV;
#endif
#if @emissiveMap
varying vec2 emissiveMapUV;
#endif
varying float depth;
varying vec4 lighting;
#include "lighting.glsl"
void main(void)
{
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
depth = gl_Position.z;
vec4 viewPos = (gl_ModelViewMatrix * gl_Vertex);
gl_ClipVertex = viewPos;
vec3 viewNormal = normalize((gl_NormalMatrix * gl_Normal).xyz);
#if @diffuseMap
diffuseMapUV = (gl_TextureMatrix[@diffuseMapUV] * gl_MultiTexCoord@diffuseMapUV).xy;
#endif
#if @darkMap
darkMapUV = (gl_TextureMatrix[@darkMapUV] * gl_MultiTexCoord@darkMapUV).xy;
#endif
#if @detailMap
detailMapUV = (gl_TextureMatrix[@detailMap] * gl_MultiTexCoord@detailMap).xy;
#endif
#if @emissiveMap
emissiveMapUV = (gl_TextureMatrix[@emissiveMapUV] * gl_MultiTexCoord@emissiveMapUV).xy;
#endif
lighting = doLighting(viewPos.xyz, viewNormal, gl_Color);
// TODO: make clamp configurable
// the following produces fixed-function compatible lighting, w/o clamp arguably looks better
//lighting = clamp(lighting, vec4(0.0, 0.0, 0.0, 0.0), vec4(1.0, 1.0, 1.0, 1.0));
}