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

@ -1,31 +1,12 @@
// swap out jitter pattern to be a 4 frame pattern instead of an 8 frame halton sequence
#ifdef RESPONSIVE_TAA
#if defined RESPONSIVE_TAA || defined DH_TAA_OVERRIDE
const vec2[4] offsets = vec2[4](
// vec2( 0.0, -1.0),
// vec2( 1.0, 0.0),
// vec2( 0.0, 1.0),
// vec2(-1.0, 0.0)
// vec2(-1.0, -7.0)/8.0,
// vec2( 7.0, -1.0)/8.0,
// vec2( 1.0, 7.0)/8.0,
// vec2(-7.0, 1.0)/8.0
vec2(-0.125, -0.875),
vec2( 0.875, -0.125),
vec2( 0.125, 0.875),
vec2(-0.875, 0.125)
// vec2(-7.0, 1.0)/8.0,
// vec2( 7.0, -1.0)/8.0,
// vec2( 1.0, 7.0)/8.0,
// vec2(-1.0, -7.0)/8.0
);
#else
const vec2[8] offsets = vec2[8](
vec2( 1.0, -3.0)/8.0,
vec2(-1.0, 3.0)/8.0,
@ -36,5 +17,4 @@
vec2( 3.0, 7.0)/8.0,
vec2( 7.0, 7.0)/8.0
);
#endif

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);
}

View File

@ -299,38 +299,21 @@ vec4 GetVolumetricFog(
color += (hazeLighting - hazeLighting*exp(-hazeDensity*dd*dL)) * absorbance;
// // determine where the vortex area ends and chaotic lightning area begins.
// float vortexBounds = clamp(vortexBoundRange - length(progressW), 0.0,1.0);
#if defined FLASHLIGHT && defined FLASHLIGHT_FOG_ILLUMINATION
vec3 shiftedViewPos = mat3(gbufferModelView)*(progressW-cameraPosition) + vec3(-0.25, 0.2, 0.0);
vec3 shiftedPlayerPos = mat3(gbufferModelViewInverse) * shiftedViewPos;
vec2 scaledViewPos = shiftedViewPos.xy / max(-shiftedViewPos.z - 0.5, 1e-7);
float linearDistance = length(shiftedPlayerPos);
float shiftedLinearDistance = length(scaledViewPos);
// vec3 lightPosition = LightSourcePosition(progressW, cameraPosition, vortexBounds);
// vec3 lightColors = LightSourceColors(vortexBounds, lightningflash);
float lightFalloff = 1.0 - clamp(1.0-linearDistance/FLASHLIGHT_RANGE, -0.999,1.0);
lightFalloff = max(exp(-30.0 * lightFalloff),0.0);
float projectedCircle = clamp(1.0 - shiftedLinearDistance*FLASHLIGHT_SIZE,0.0,1.0);
// volumeDensity += max(1.0 - length(vec3(lightPosition.x,lightPosition.y*2,lightPosition.z))/50,0.0) * vortexBounds;
// float clearArea = 1.0-min(max(1.0 - length(progressW - cameraPosition) / 100,0.0),1.0);
// float density = min(volumeDensity * clearArea, END_STORM_DENSTIY);
vec3 flashlightGlow = vec3(FLASHLIGHT_R,FLASHLIGHT_G,FLASHLIGHT_B) * lightFalloff * projectedCircle * 0.5;
// ///// ----- air lighting, the haze
// float distanceFog = max(1.0 - length(progressW - cameraPosition) / max(far, 32.0 * 13.0),0.0);
// float hazeDensity = min(exp2(distanceFog * -25)+0.0005,1.0);
// vec3 hazeColor = vec3(0.3,0.75,1.0) * 0.3;
// color += (hazeColor - hazeColor*exp(-hazeDensity*dd*dL)) * absorbance;
// ///// ----- main lighting
// vec3 voidLighting = vec3(1.0,0.0,0.8) * 0.1 * (1-exp(volumeDensity * -25)) * max(exp2(-1 * sqrt(max(progressW.y - -60,0.0))),0.0) ;
// vec3 ambient = vec3(0.5,0.75,1.0) * 0.2 * (exp((volumeDensity*volumeDensity) * -50) * 0.9 + 0.1);
// float shadows = 0;
// vec3 lightsources = LightSourceLighting(progressW, lightPosition, dither2, volumeDensity, lightColors, vortexBounds);
// vec3 lighting = lightsources + ambient + voidLighting;
// #ifdef THE_ORB
// density += min(50.0*max(1.0 - length(lightPosition)/10,0.0),1.0);
// #endif
// ///// ----- blend
// color += (lighting - lighting*exp(-(density)*dd*dL)) * absorbance;
// absorbance *= exp(-max(density,hazeDensity)*dd*dL);
color += (flashlightGlow - flashlightGlow * exp(-max(stormDensity,0.005)*dd*dL)) * absorbance;
#endif
//------ LPV FOG EFFECT
#if defined LPV_VL_FOG_ILLUMINATION && defined EXCLUDE_WRITE_TO_LUT

View File

@ -103,6 +103,22 @@ vec4 GetVolumetricFog(
color += (ceilingSmoke - ceilingSmoke*ceilingSmokeVolumeCoeff) * (absorbance*0.5+0.5);
absorbance *= ceilingSmokeVolumeCoeff;
#if defined FLASHLIGHT && defined FLASHLIGHT_FOG_ILLUMINATION
vec3 shiftedViewPos = mat3(gbufferModelView)*(progressW-cameraPosition) + vec3(-0.25, 0.2, 0.0);
vec3 shiftedPlayerPos = mat3(gbufferModelViewInverse) * shiftedViewPos;
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(-30.0 * lightFalloff),0.0);
float projectedCircle = clamp(1.0 - shiftedLinearDistance*FLASHLIGHT_SIZE,0.0,1.0);
vec3 flashlightGlow = vec3(FLASHLIGHT_R,FLASHLIGHT_G,FLASHLIGHT_B) * lightFalloff * projectedCircle * 0.5;
color += (flashlightGlow - flashlightGlow * exp(-max(plumeDensity,0.005)*dd*dL)) * absorbance;
#endif
//------ LPV FOG EFFECT
#if defined LPV_VL_FOG_ILLUMINATION && defined EXCLUDE_WRITE_TO_LUT
color += LPV_FOG_ILLUMINATION(progressW-cameraPosition, dd, dL) * TorchBrightness_autoAdjust * absorbance;

View File

@ -231,6 +231,22 @@ vec4 GetVolumetricFog(
color += (lighting - lighting * fogVolumeCoeff) * totalAbsorbance;
#if defined FLASHLIGHT && defined FLASHLIGHT_FOG_ILLUMINATION
vec3 shiftedViewPos = mat3(gbufferModelView)*(progressW-cameraPosition) + vec3(-0.25, 0.2, 0.0);
vec3 shiftedPlayerPos = mat3(gbufferModelViewInverse) * shiftedViewPos;
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(-30.0 * lightFalloff),0.0);
float projectedCircle = clamp(1.0 - shiftedLinearDistance*FLASHLIGHT_SIZE,0.0,1.0);
vec3 flashlightGlow = vec3(FLASHLIGHT_R,FLASHLIGHT_G,FLASHLIGHT_B) * lightFalloff * projectedCircle * 0.5;
color += (flashlightGlow - flashlightGlow * exp(-max(fogDensity,0.005)*dd*dL)) * totalAbsorbance;
#endif
// kill fog absorbance when in caves.
totalAbsorbance *= mix(1.0, fogVolumeCoeff, lightLevelZero);
//------------------------------------
@ -261,7 +277,6 @@ vec4 GetVolumetricFog(
atmosphereAbsorbance *= atmosphereVolumeCoeff*fogVolumeCoeff;
//------------------------------------
//------ LPV FOG EFFECT
//------------------------------------

View File

@ -618,6 +618,8 @@ const vec3 aerochrome_color = mix(vec3(1.0, 0.0, 0.0), vec3(0.715, 0.303, 0.631)
#ifdef IS_IRIS
#define DAMAGE_TAKEN_EFFECT
#define LOW_HEALTH_EFFECT
#define LOW_HEALTH_EFFECT_START 6.0 // [1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0 11.0 12.0 13.0 14.0 15.0 16.0 17.0 18.0 19.0 20.0 21.0 22.0 23.0 24.0]
#define CRITICALLY_LOW_HEALTH_EFFECT_START 2.0 // [1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0 11.0 12.0 13.0 14.0 15.0 16.0 17.0 18.0 19.0 20.0 21.0 22.0 23.0 24.0]
#endif
#define WATER_ON_CAMERA_EFFECT
@ -630,6 +632,33 @@ const vec3 aerochrome_color = mix(vec3(1.0, 0.0, 0.0), vec3(0.715, 0.303, 0.631)
#ifdef WATER_ON_CAMERA_EFFECT
#endif
// #define FLASHLIGHT
#define FLASHLIGHT_SPECULAR
#define FLASHLIGHT_BOUNCED_INDIRECT
// #define FLASHLIGHT_FOG_ILLUMINATION
#define FLASHLIGHT_RANGE 32 // [ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 60 70 80 90 100 ]
#define FLASHLIGHT_SIZE 2.0 // [0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0 11.0 12.0 13.0 14.0 15.0 16.0 17.0 18.0 19.0 20.0]
#define FLASHLIGHT_R 1.0 // [0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.0]
#define FLASHLIGHT_G 0.9 // [0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.0]
#define FLASHLIGHT_B 0.8 // [0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.0]
#ifdef FLASHLIGHT
#endif
#ifdef FLASHLIGHT_SPECULAR
#endif
#ifdef FLASHLIGHT_BOUNCED_INDIRECT
#endif
#ifdef FLASHLIGHT_FOG_ILLUMINATION
#endif
#if !defined FLASHLIGHT
#undef FLASHLIGHT_SPECULAR
#endif
#if defined FLASHLIGHT
#undef Hand_Held_lights
#endif
/////////////////////////////////////////
@ -740,6 +769,7 @@ const vec3 aerochrome_color = mix(vec3(1.0, 0.0, 0.0), vec3(0.715, 0.303, 0.631)
#define DH_SUBSURFACE_SCATTERING
#define DH_SCREENSPACE_REFLECTIONS
#define DH_NOISE_TEXTURE
#define DH_TAA_JITTER
///////////////////////////////////////////
// ----- FLOODFILL [LPV] SETTINGS ----- //
@ -792,6 +822,8 @@ const vec3 aerochrome_color = mix(vec3(1.0, 0.0, 0.0), vec3(0.715, 0.303, 0.631)
#undef TAA
#endif
// fix settings
#ifdef DH_TAA_JITTER
#endif
#ifdef DH_SCREENSPACE_REFLECTIONS
#endif
#ifdef DH_SUBSURFACE_SCATTERING

View File

@ -288,6 +288,9 @@ vec3 specularReflections(
#else
, bool isWater
#endif
,in vec4 flashLight_stuff
){
#ifdef FORWARD_RENDERED_SPECULAR
lightmap = pow(min(max(lightmap-0.6,0.0)*2.5,1.0),2.0);
@ -316,7 +319,7 @@ vec3 specularReflections(
// get reflectance and f0/HCM values
// float shlickFresnel = pow(clamp(1.0 + dot(-reflectedVector, samplePoints),0.0,1.0),5.0);
if(isHand) reflectedVector_L = reflect(playerPos, normal);
reflectedVector_L = isHand ? reflect(playerPos, normal) : reflectedVector_L;
#else
vec3 reflectedVector_L = reflect(playerPos, normal);
#endif
@ -389,5 +392,10 @@ vec3 specularReflections(
specularReflections += lightSourceReflection;
#endif
#if defined FLASHLIGHT_SPECULAR
vec3 flashLightReflection = vec3(FLASHLIGHT_R,FLASHLIGHT_G,FLASHLIGHT_B) * flashLight_stuff.a * GGX(normal, -flashLight_stuff.xyz, -flashLight_stuff.xyz, roughness, reflectance, metalAlbedoTint);
specularReflections += flashLightReflection;
#endif
return specularReflections;
}