add flashlight effects. add TAA jitter toggle for DH LOD, force responsive TAA jitter on DH. add adjustable health thresholds for damage effects..

This commit is contained in:
Xonk
2025-02-25 17:42:55 -05:00
parent 8a62fff7a2
commit 0ea061c891
18 changed files with 359 additions and 234 deletions

View File

@ -86,4 +86,48 @@ vec3 doIndirectLighting(
indirectLight += minimumLightColor * (MIN_LIGHT_AMOUNT * 0.02 * 0.2 + nightVision*0.02);
return indirectLight;
}
}
uniform float centerDepthSmooth;
vec3 calculateFlashlight(in vec2 texcoord, in vec3 viewPos, in vec3 albedo, in vec3 normal, out vec4 flashLightSpecularData, bool hand){
vec3 shiftedViewPos = viewPos + vec3(-0.25, 0.2, 0.0);
vec3 shiftedPlayerPos = mat3(gbufferModelViewInverse) * shiftedViewPos; + gbufferModelViewInverse[3].xyz + (cameraPosition - previousCameraPosition) * 3.0;
shiftedViewPos = mat3(gbufferPreviousModelView) * shiftedPlayerPos + gbufferPreviousModelView[3].xyz;
vec2 scaledViewPos = shiftedViewPos.xy / max(-shiftedViewPos.z - 0.5, 1e-7);
float linearDistance = length(shiftedPlayerPos);
float shiftedLinearDistance = length(scaledViewPos);
float lightFalloff = 1.0 - clamp(1.0-linearDistance/FLASHLIGHT_RANGE, -0.999,1.0);
lightFalloff = max(exp(-10.0 * lightFalloff),0.0);
#if defined FLASHLIGHT_SPECULAR && (defined DEFERRED_SPECULAR || defined FORWARD_SPECULAR)
float flashLightSpecular = lightFalloff * exp2(-7.0*shiftedLinearDistance*shiftedLinearDistance);
flashLightSpecularData = vec4(normalize(shiftedPlayerPos), flashLightSpecular);
#endif
float projectedCircle = clamp(1.0 - shiftedLinearDistance*FLASHLIGHT_SIZE,0.0,1.0);
float lenseDirt = texture2D(noisetex, scaledViewPos * 0.2 + 0.1).b;
float lenseShape = (pow(abs(pow(abs(projectedCircle-1.0),2.0)*2.0 - 0.5),2.0) + lenseDirt*0.2) * 10.0;
float offsetNdotL = clamp(dot(-normal, normalize(shiftedPlayerPos)),0,1);
vec3 flashlightDiffuse = vec3(1.0) * lightFalloff * offsetNdotL * pow(1.0-pow(1.0-projectedCircle,2),2) * lenseShape;
if(hand){
flashlightDiffuse = vec3(0.0);
flashLightSpecularData = vec4(0.0);
}
#ifdef FLASHLIGHT_BOUNCED_INDIRECT
float lightWidth = 1.0+linearDistance*3.0;
vec3 pointPos = mat3(gbufferModelViewInverse) * (toScreenSpace(vec3(texcoord, centerDepthSmooth)) + vec3(-0.25, 0.2, 0.0));
float flashLightHitPoint = distance(pointPos, shiftedPlayerPos);
float indirectFlashLight = exp(-10.0 * (1.0 - clamp(1.0-length(shiftedViewPos.xy)/lightWidth,0.0,1.0)) );
indirectFlashLight *= pow(clamp(1.0-flashLightHitPoint/lightWidth,0,1),2.0);
flashlightDiffuse += albedo/150.0 * indirectFlashLight * lightFalloff;
#endif
return flashlightDiffuse * vec3(FLASHLIGHT_R,FLASHLIGHT_G,FLASHLIGHT_B);
}