mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-26 09:35:28 +00:00
4b1c009ffd
With this PR we test out osg's shader define system for a somewhat harmless feature. As we can see, our code becomes more concise and efficient in this case. Most importantly, we no longer create unneeded vertex shader objects.
54 lines
1.0 KiB
GLSL
54 lines
1.0 KiB
GLSL
#version 120
|
|
#pragma import_defines(FORCE_OPAQUE)
|
|
|
|
#if @useGPUShader4
|
|
#extension GL_EXT_gpu_shader4: require
|
|
#endif
|
|
|
|
#if @diffuseMap
|
|
uniform sampler2D diffuseMap;
|
|
varying vec2 diffuseMapUV;
|
|
#endif
|
|
|
|
#if @radialFog
|
|
varying float euclideanDepth;
|
|
#else
|
|
varying float linearDepth;
|
|
#endif
|
|
|
|
uniform bool useFalloff;
|
|
|
|
varying float passFalloff;
|
|
|
|
#include "vertexcolors.glsl"
|
|
#include "alpha.glsl"
|
|
|
|
void main()
|
|
{
|
|
#if @diffuseMap
|
|
gl_FragData[0] = texture2D(diffuseMap, diffuseMapUV);
|
|
gl_FragData[0].a *= coveragePreservingAlphaScale(diffuseMap, diffuseMapUV);
|
|
#else
|
|
gl_FragData[0] = vec4(1.0);
|
|
#endif
|
|
|
|
gl_FragData[0] *= getDiffuseColor();
|
|
|
|
if (useFalloff)
|
|
gl_FragData[0].a *= passFalloff;
|
|
|
|
alphaTest();
|
|
|
|
#if @radialFog
|
|
float fogValue = clamp((euclideanDepth - gl_Fog.start) * gl_Fog.scale, 0.0, 1.0);
|
|
#else
|
|
float fogValue = clamp((linearDepth - gl_Fog.start) * gl_Fog.scale, 0.0, 1.0);
|
|
#endif
|
|
|
|
#if FORCE_OPAQUE
|
|
gl_FragData[0].a = 1.0;
|
|
#endif
|
|
|
|
gl_FragData[0].xyz = mix(gl_FragData[0].xyz, gl_Fog.color.xyz, fogValue);
|
|
}
|