2020-12-17 00:46:09 +03:00
|
|
|
#version 120
|
2021-10-05 12:37:08 +00:00
|
|
|
#pragma import_defines(FORCE_OPAQUE)
|
2020-12-17 00:46:09 +03:00
|
|
|
|
2023-02-26 14:31:41 -08:00
|
|
|
#if @useUBO
|
|
|
|
#extension GL_ARB_uniform_buffer_object : require
|
|
|
|
#endif
|
|
|
|
|
2020-12-17 00:46:09 +03:00
|
|
|
#if @useGPUShader4
|
|
|
|
#extension GL_EXT_gpu_shader4: require
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if @diffuseMap
|
|
|
|
uniform sampler2D diffuseMap;
|
|
|
|
varying vec2 diffuseMapUV;
|
|
|
|
#endif
|
|
|
|
|
2023-09-24 12:20:09 +02:00
|
|
|
varying vec3 passViewPos;
|
2023-02-26 14:31:41 -08:00
|
|
|
varying vec3 passNormal;
|
2020-12-17 00:46:09 +03:00
|
|
|
varying float euclideanDepth;
|
|
|
|
varying float linearDepth;
|
2023-02-26 14:31:41 -08:00
|
|
|
varying float passFalloff;
|
2020-12-17 00:46:09 +03:00
|
|
|
|
2022-06-06 22:40:38 +02:00
|
|
|
uniform vec2 screenRes;
|
2023-02-26 14:31:41 -08:00
|
|
|
uniform bool useFalloff;
|
2023-02-25 11:03:39 -08:00
|
|
|
uniform float far;
|
2023-09-24 12:20:09 +02:00
|
|
|
uniform float near;
|
2023-02-25 11:03:39 -08:00
|
|
|
uniform float alphaRef;
|
2020-12-17 00:46:09 +03:00
|
|
|
|
2023-02-25 11:03:39 -08:00
|
|
|
#include "lib/material/alpha.glsl"
|
2023-02-26 14:31:41 -08:00
|
|
|
|
|
|
|
#include "compatibility/vertexcolors.glsl"
|
|
|
|
#include "compatibility/fog.glsl"
|
|
|
|
#include "compatibility/shadows_fragment.glsl"
|
2020-12-17 00:46:09 +03:00
|
|
|
|
2023-09-24 12:20:09 +02:00
|
|
|
#if @softParticles
|
|
|
|
#include "lib/particle/soft.glsl"
|
|
|
|
|
|
|
|
uniform sampler2D opaqueDepthTex;
|
|
|
|
uniform float particleSize;
|
|
|
|
uniform bool particleFade;
|
2023-10-28 10:23:48 -07:00
|
|
|
uniform float softFalloffDepth;
|
2023-09-24 12:20:09 +02:00
|
|
|
#endif
|
|
|
|
|
2020-12-17 00:46:09 +03:00
|
|
|
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;
|
|
|
|
|
2023-02-26 14:31:41 -08:00
|
|
|
gl_FragData[0].a = alphaTest(gl_FragData[0].a, alphaRef);
|
|
|
|
|
|
|
|
gl_FragData[0] = applyFogAtDist(gl_FragData[0], euclideanDepth, linearDepth, far);
|
2020-12-17 00:46:09 +03:00
|
|
|
|
2023-09-24 12:20:09 +02:00
|
|
|
#if !defined(FORCE_OPAQUE) && @softParticles
|
|
|
|
vec2 screenCoords = gl_FragCoord.xy / screenRes;
|
|
|
|
vec3 viewVec = normalize(passViewPos.xyz);
|
|
|
|
vec3 viewNormal = normalize(gl_NormalMatrix * passNormal);
|
|
|
|
|
|
|
|
gl_FragData[0].a *= calcSoftParticleFade(
|
|
|
|
viewVec,
|
|
|
|
passViewPos,
|
|
|
|
viewNormal,
|
|
|
|
near,
|
|
|
|
far,
|
|
|
|
texture2D(opaqueDepthTex, screenCoords).x,
|
|
|
|
particleSize,
|
2023-10-28 10:23:48 -07:00
|
|
|
particleFade,
|
|
|
|
softFalloffDepth
|
2023-09-24 12:20:09 +02:00
|
|
|
);
|
|
|
|
#endif
|
|
|
|
|
2021-10-06 08:05:10 +02:00
|
|
|
#if defined(FORCE_OPAQUE) && FORCE_OPAQUE
|
2021-10-05 12:37:08 +00:00
|
|
|
gl_FragData[0].a = 1.0;
|
2020-12-17 00:46:09 +03:00
|
|
|
#endif
|
|
|
|
|
2023-02-26 14:31:41 -08:00
|
|
|
#if !defined(FORCE_OPAQUE) && !@disableNormals
|
|
|
|
vec3 viewNormal = normalize(gl_NormalMatrix * passNormal);
|
|
|
|
gl_FragData[1].xyz = viewNormal * 0.5 + 0.5;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
applyShadowDebugOverlay();
|
2020-12-17 00:46:09 +03:00
|
|
|
}
|