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

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

141 lines
3.1 KiB
Plaintext
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 10:38:15 -08:00
2022-04-27 17:37:07 +02:00
#include "openmw_vertex.h.glsl"
#if @diffuseMap
varying vec2 diffuseMapUV;
#endif
2016-02-16 22:32:59 +01:00
#if @darkMap
varying vec2 darkMapUV;
#endif
#if @detailMap
varying vec2 detailMapUV;
#endif
#if @decalMap
varying vec2 decalMapUV;
#endif
#if @emissiveMap
varying vec2 emissiveMapUV;
#endif
2016-02-18 00:00:12 +01:00
#if @normalMap
varying vec2 normalMapUV;
varying vec4 passTangent;
2016-02-18 00:00:12 +01:00
#endif
2016-02-18 23:05:44 +01:00
#if @envMap
varying vec2 envMapUV;
#endif
2020-03-02 04:03:36 +03:00
#if @bumpMap
varying vec2 bumpMapUV;
#endif
2016-02-20 19:02:11 +01:00
#if @specularMap
varying vec2 specularMapUV;
#endif
#if @glossMap
varying vec2 glossMapUV;
#endif
2016-02-18 17:08:18 +01:00
#define PER_PIXEL_LIGHTING (@normalMap || @forcePPL)
2016-02-17 23:39:06 +01:00
#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;
2020-12-17 00:46:09 +03:00
uniform float emissiveMult;
2016-02-17 23:39:06 +01:00
#endif
2016-02-20 19:02:11 +01:00
varying vec3 passViewPos;
2016-03-22 21:12:16 +01:00
varying vec3 passNormal;
2016-02-16 23:30:23 +01:00
2020-12-19 20:17:42 +03:00
#include "vertexcolors.glsl"
#include "shadows_vertex.glsl"
2021-03-28 11:06:00 -07:00
2016-02-17 23:29:26 +01:00
#include "lighting.glsl"
2021-06-01 12:15:25 -07:00
#include "depth.glsl"
2016-02-16 23:30:23 +01:00
void main(void)
{
gl_Position = mw_modelToClip(gl_Vertex);
vec4 viewPos = mw_modelToView(gl_Vertex);
gl_ClipVertex = viewPos;
2020-03-14 16:39:32 +04:00
2020-06-15 12:43:51 +04:00
#if (@envMap || !PER_PIXEL_LIGHTING || @shadows_enabled)
vec3 viewNormal = normalize((gl_NormalMatrix * gl_Normal).xyz);
2020-06-15 12:43:51 +04:00
#endif
2016-02-18 23:05:44 +01:00
#if @envMap
vec3 viewVec = normalize(viewPos.xyz);
vec3 r = reflect( viewVec, viewNormal );
float m = 2.0 * sqrt( r.x*r.x + r.y*r.y + (r.z+1.0)*(r.z+1.0) );
envMapUV = vec2(r.x/m + 0.5, r.y/m + 0.5);
#endif
#if @diffuseMap
2016-02-17 02:46:47 +01:00
diffuseMapUV = (gl_TextureMatrix[@diffuseMapUV] * gl_MultiTexCoord@diffuseMapUV).xy;
#endif
2016-02-16 23:30:23 +01:00
#if @darkMap
darkMapUV = (gl_TextureMatrix[@darkMapUV] * gl_MultiTexCoord@darkMapUV).xy;
#endif
#if @detailMap
2016-03-01 18:40:18 +01:00
detailMapUV = (gl_TextureMatrix[@detailMapUV] * gl_MultiTexCoord@detailMapUV).xy;
#endif
#if @decalMap
decalMapUV = (gl_TextureMatrix[@decalMapUV] * gl_MultiTexCoord@decalMapUV).xy;
#endif
#if @emissiveMap
emissiveMapUV = (gl_TextureMatrix[@emissiveMapUV] * gl_MultiTexCoord@emissiveMapUV).xy;
#endif
2016-02-18 00:00:12 +01:00
#if @normalMap
normalMapUV = (gl_TextureMatrix[@normalMapUV] * gl_MultiTexCoord@normalMapUV).xy;
passTangent = gl_MultiTexCoord7.xyzw;
2016-02-18 00:00:12 +01:00
#endif
2020-03-02 04:03:36 +03:00
#if @bumpMap
bumpMapUV = (gl_TextureMatrix[@bumpMapUV] * gl_MultiTexCoord@bumpMapUV).xy;
#endif
2016-02-20 19:02:11 +01:00
#if @specularMap
specularMapUV = (gl_TextureMatrix[@specularMapUV] * gl_MultiTexCoord@specularMapUV).xy;
#endif
#if @glossMap
glossMapUV = (gl_TextureMatrix[@glossMapUV] * gl_MultiTexCoord@glossMapUV).xy;
#endif
passColor = gl_Color;
2016-02-20 19:02:11 +01:00
passViewPos = viewPos.xyz;
2016-03-22 21:12:16 +01:00
passNormal = gl_Normal.xyz;
2017-09-21 00:25:48 +01:00
2020-12-19 20:17:42 +03:00
#if !PER_PIXEL_LIGHTING
vec3 diffuseLight, ambientLight;
doLighting(viewPos.xyz, viewNormal, diffuseLight, ambientLight, shadowDiffuseLighting);
2020-12-17 00:46:09 +03:00
vec3 emission = getEmissionColor().xyz * emissiveMult;
passLighting = getDiffuseColor().xyz * diffuseLight + getAmbientColor().xyz * ambientLight + emission;
clampLightingResult(passLighting);
2020-12-19 20:17:42 +03:00
shadowDiffuseLighting *= getDiffuseColor().xyz;
#endif
2020-06-15 12:43:51 +04:00
#if (@shadows_enabled)
setupShadowCoords(viewPos, viewNormal);
2020-06-15 12:43:51 +04:00
#endif
}