mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-04 03:40:14 +00:00
dd5901d351
Multiview shaders. Refactor Frustum management Rewrite shared shadow map cull mask should respect stereo Stereo savegame screencap LocalMap refactoring use the vertex buffer hint instead of the display list patch to enable/disable display lists Character preview fixes
149 lines
3.3 KiB
GLSL
149 lines
3.3 KiB
GLSL
#version @GLSLVersion
|
|
|
|
#include "multiview_vertex.glsl"
|
|
|
|
#if @useUBO
|
|
#extension GL_ARB_uniform_buffer_object : require
|
|
#endif
|
|
|
|
#if @useGPUShader4
|
|
#extension GL_EXT_gpu_shader4: require
|
|
#endif
|
|
|
|
#include "openmw_vertex.h.glsl"
|
|
#if @diffuseMap
|
|
varying vec2 diffuseMapUV;
|
|
#endif
|
|
|
|
#if @darkMap
|
|
varying vec2 darkMapUV;
|
|
#endif
|
|
|
|
#if @detailMap
|
|
varying vec2 detailMapUV;
|
|
#endif
|
|
|
|
#if @decalMap
|
|
varying vec2 decalMapUV;
|
|
#endif
|
|
|
|
#if @emissiveMap
|
|
varying vec2 emissiveMapUV;
|
|
#endif
|
|
|
|
#if @normalMap
|
|
varying vec2 normalMapUV;
|
|
varying vec4 passTangent;
|
|
#endif
|
|
|
|
#if @envMap
|
|
varying vec2 envMapUV;
|
|
#endif
|
|
|
|
#if @bumpMap
|
|
varying vec2 bumpMapUV;
|
|
#endif
|
|
|
|
#if @specularMap
|
|
varying vec2 specularMapUV;
|
|
#endif
|
|
|
|
#if @glossMap
|
|
varying vec2 glossMapUV;
|
|
#endif
|
|
|
|
varying float euclideanDepth;
|
|
varying float linearDepth;
|
|
|
|
#define PER_PIXEL_LIGHTING (@normalMap || @forcePPL)
|
|
|
|
#if !PER_PIXEL_LIGHTING
|
|
centroid varying vec3 passLighting;
|
|
centroid varying vec3 shadowDiffuseLighting;
|
|
uniform float emissiveMult;
|
|
#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 (@envMap || !PER_PIXEL_LIGHTING || @shadows_enabled)
|
|
vec3 viewNormal = normalize((gl_NormalMatrix * gl_Normal).xyz);
|
|
#endif
|
|
|
|
#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
|
|
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[@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
|
|
|
|
#if @normalMap
|
|
normalMapUV = (gl_TextureMatrix[@normalMapUV] * gl_MultiTexCoord@normalMapUV).xy;
|
|
passTangent = gl_MultiTexCoord7.xyzw;
|
|
#endif
|
|
|
|
#if @bumpMap
|
|
bumpMapUV = (gl_TextureMatrix[@bumpMapUV] * gl_MultiTexCoord@bumpMapUV).xy;
|
|
#endif
|
|
|
|
#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;
|
|
passViewPos = viewPos.xyz;
|
|
passNormal = gl_Normal.xyz;
|
|
|
|
#if !PER_PIXEL_LIGHTING
|
|
vec3 diffuseLight, ambientLight;
|
|
doLighting(viewPos.xyz, viewNormal, diffuseLight, ambientLight, shadowDiffuseLighting);
|
|
vec3 emission = getEmissionColor().xyz * emissiveMult;
|
|
passLighting = getDiffuseColor().xyz * diffuseLight + getAmbientColor().xyz * ambientLight + emission;
|
|
clampLightingResult(passLighting);
|
|
shadowDiffuseLighting *= getDiffuseColor().xyz;
|
|
#endif
|
|
|
|
#if (@shadows_enabled)
|
|
setupShadowCoords(viewPos, viewNormal);
|
|
#endif
|
|
}
|