#version 430 core in vec2 vTex; in vec3 vTint; in float vFogFactor; // 1 = no fog, 0 = full fog color out vec4 fragColor; uniform sampler2D uDiffuse; uniform float uTransparency; // keyframe transparency: 0 visible, 1 transparent uniform float uApplyFog; // 1 for foggable sky layers; raw-additive surfaces keep retail fog disabled uniform float uSurfOpacity; // final surface opacity multiplier from the CPU struct Light { vec4 posAndKind; vec4 dirAndRange; vec4 colorAndIntensity; vec4 coneAngleEtc; }; layout(std140, binding = 1) uniform SceneLighting { Light uLights[8]; vec4 uCellAmbient; vec4 uFogParams; vec4 uFogColor; vec4 uCameraAndTime; }; void main() { vec4 sampled = texture(uDiffuse, vTex); vec3 rgb = sampled.rgb * vTint; if (uApplyFog > 0.5) { const float SKY_FOG_FLOOR = 0.2; float skyFogFactor = max(vFogFactor, SKY_FOG_FLOOR); rgb = mix(uFogColor.rgb, rgb, skyFogFactor); } float flash = uFogParams.z; rgb += flash * vec3(1.5, 1.5, 1.8); float cap = mix(1.0, 3.0, clamp(flash, 0.0, 1.0)); rgb = min(rgb, vec3(cap)); float a = sampled.a * (1.0 - uTransparency) * uSurfOpacity; if (a < 0.01) discard; fragColor = vec4(rgb, a); }