1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-21 08:53:52 +00:00
openmw/files/shaders/compatibility/objects.vert

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

164 lines
3.9 KiB
GLSL
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 18:38:15 +00:00
2023-02-25 19:03:39 +00:00
#include "lib/core/vertex.h.glsl"
#if @diffuseMap
varying vec2 diffuseMapUV;
#endif
2016-02-16 21:32:59 +00: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-17 23:00:12 +00:00
#if @normalMap
varying vec2 normalMapUV;
#endif
2016-02-18 22:05:44 +00:00
#if @envMap
varying vec2 envMapUV;
#endif
2020-03-02 01:03:36 +00:00
#if @bumpMap
varying vec2 bumpMapUV;
#endif
2016-02-20 18:02:11 +00:00
#if @specularMap
varying vec2 specularMapUV;
#endif
#if @glossMap
varying vec2 glossMapUV;
#endif
#define PER_PIXEL_LIGHTING (@normalMap || @specularMap || @forcePPL)
2016-02-17 22:39:06 +00:00
#if !PER_PIXEL_LIGHTING
2020-12-19 17:17:42 +00:00
centroid varying vec3 passLighting;
centroid varying vec3 passSpecular;
2018-05-11 18:15:04 +00:00
centroid varying vec3 shadowDiffuseLighting;
centroid varying vec3 shadowSpecularLighting;
2020-12-16 21:46:09 +00:00
uniform float emissiveMult;
uniform float specStrength;
2016-02-17 22:39:06 +00:00
#endif
2016-02-20 18:02:11 +00:00
varying vec3 passViewPos;
2016-03-22 20:12:16 +00:00
varying vec3 passNormal;
#if @normalMap || @diffuseParallax
varying vec4 passTangent;
#endif
2016-02-16 22:30:23 +00:00
2020-12-19 17:17:42 +00:00
#include "vertexcolors.glsl"
#include "shadows_vertex.glsl"
#include "compatibility/normals.glsl"
2021-03-28 18:06:00 +00:00
2023-02-25 19:03:39 +00:00
#include "lib/light/lighting.glsl"
#include "lib/view/depth.glsl"
2016-02-16 22:30:23 +00:00
2023-01-07 06:23:03 +00:00
#if @particleOcclusion
varying vec3 orthoDepthMapCoord;
uniform mat4 depthSpaceMatrix;
uniform mat4 osg_ViewMatrixInverse;
#endif
void main(void)
{
2023-01-07 06:23:03 +00:00
#if @particleOcclusion
mat4 model = osg_ViewMatrixInverse * gl_ModelViewMatrix;
orthoDepthMapCoord = ((depthSpaceMatrix * model) * vec4(gl_Vertex.xyz, 1.0)).xyz;
#endif
2023-02-25 19:03:39 +00:00
gl_Position = modelToClip(gl_Vertex);
2023-02-25 19:03:39 +00:00
vec4 viewPos = modelToView(gl_Vertex);
gl_ClipVertex = viewPos;
passColor = gl_Color;
passViewPos = viewPos.xyz;
passNormal = gl_Normal.xyz;
normalToViewMatrix = gl_NormalMatrix;
#if @normalMap || @diffuseParallax
passTangent = gl_MultiTexCoord7.xyzw;
normalToViewMatrix *= generateTangentSpace(passTangent, passNormal);
#endif
2020-03-14 12:39:32 +00:00
#if @envMap || !PER_PIXEL_LIGHTING || @shadows_enabled
vec3 viewNormal = normalize(gl_NormalMatrix * passNormal);
2020-06-15 08:43:51 +00:00
#endif
2016-02-18 22:05:44 +00: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 01:46:47 +00:00
diffuseMapUV = (gl_TextureMatrix[@diffuseMapUV] * gl_MultiTexCoord@diffuseMapUV).xy;
#endif
2016-02-16 22:30:23 +00:00
#if @darkMap
darkMapUV = (gl_TextureMatrix[@darkMapUV] * gl_MultiTexCoord@darkMapUV).xy;
#endif
#if @detailMap
2016-03-01 17:40:18 +00: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-17 23:00:12 +00:00
#if @normalMap
normalMapUV = (gl_TextureMatrix[@normalMapUV] * gl_MultiTexCoord@normalMapUV).xy;
#endif
2020-03-02 01:03:36 +00:00
#if @bumpMap
bumpMapUV = (gl_TextureMatrix[@bumpMapUV] * gl_MultiTexCoord@bumpMapUV).xy;
#endif
2016-02-20 18:02:11 +00:00
#if @specularMap
specularMapUV = (gl_TextureMatrix[@specularMapUV] * gl_MultiTexCoord@specularMapUV).xy;
#endif
#if @glossMap
glossMapUV = (gl_TextureMatrix[@glossMapUV] * gl_MultiTexCoord@glossMapUV).xy;
#endif
2020-12-19 17:17:42 +00:00
#if !PER_PIXEL_LIGHTING
vec3 diffuseLight, ambientLight, specularLight;
doLighting(viewPos.xyz, viewNormal, gl_FrontMaterial.shininess, diffuseLight, ambientLight, specularLight, shadowDiffuseLighting, shadowSpecularLighting);
passLighting = getDiffuseColor().xyz * diffuseLight + getAmbientColor().xyz * ambientLight + getEmissionColor().xyz * emissiveMult;
passSpecular = getSpecularColor().xyz * specularLight * specStrength;
clampLightingResult(passLighting);
2020-12-19 17:17:42 +00:00
shadowDiffuseLighting *= getDiffuseColor().xyz;
shadowSpecularLighting *= getSpecularColor().xyz * specStrength;
2020-12-19 17:17:42 +00:00
#endif
2020-06-15 08:43:51 +00:00
#if (@shadows_enabled)
setupShadowCoords(viewPos, viewNormal);
2020-06-15 08:43:51 +00:00
#endif
}