From 044d690a5289347ba967d403c3159b4a0ab14473 Mon Sep 17 00:00:00 2001 From: Xonk Date: Sat, 18 May 2024 22:58:30 -0400 Subject: [PATCH] ADD water exit effect, add damage amount based hurt effects. fix water fog lightmap --- shaders/dimensions/DH_translucent.fsh | 3 +- shaders/dimensions/all_particles.fsh | 2 +- shaders/dimensions/all_translucent.fsh | 35 ++---- shaders/dimensions/all_vanilla_emissives.fsh | 1 - shaders/dimensions/composite1.fsh | 13 +-- shaders/dimensions/composite5.fsh | 13 ++- shaders/dimensions/final.fsh | 12 ++- .../dimensions/fogBehindTranslucent_pass.fsh | 8 +- shaders/lib/gameplay_effects.glsl | 100 ++++++++++++------ shaders/lib/projections.glsl | 4 +- shaders/lib/settings.glsl | 21 +++- shaders/shaders.properties | 21 +++- 12 files changed, 149 insertions(+), 84 deletions(-) diff --git a/shaders/dimensions/DH_translucent.fsh b/shaders/dimensions/DH_translucent.fsh index 12271ad..8ed6ebc 100644 --- a/shaders/dimensions/DH_translucent.fsh +++ b/shaders/dimensions/DH_translucent.fsh @@ -1,4 +1,5 @@ #include "/lib/settings.glsl" +#include "/lib/util.glsl" #include "/lib/res_params.glsl" #include "/lib/color_transforms.glsl" #include "/lib/projections.glsl" @@ -63,8 +64,6 @@ flat varying vec3 WsunVec; flat varying vec3 WsunVec2; -#define diagonal3(m) vec3((m)[0].x, (m)[1].y, m[2].z) -#define projMAD(m, v) (diagonal3(m) * (v) + (m)[3].xyz) // uniform mat4 dhPreviousProjection; // uniform mat4 dhProjectionInverse; diff --git a/shaders/dimensions/all_particles.fsh b/shaders/dimensions/all_particles.fsh index 82424a9..7b8d0ad 100644 --- a/shaders/dimensions/all_particles.fsh +++ b/shaders/dimensions/all_particles.fsh @@ -92,7 +92,7 @@ vec3 toLinear(vec3 sRGB){ return sRGB * (sRGB * (sRGB * 0.305306011 + 0.682171111) + 0.012522878); } -#define diagonal3(m) vec3((m)[0].x, (m)[1].y, m[2].z) +// #define diagonal3(m) vec3((m)[0].x, (m)[1].y, m[2].z) vec3 toScreenSpace(vec3 p) { vec4 iProjDiag = vec4(gbufferProjectionInverse[0].x, gbufferProjectionInverse[1].y, gbufferProjectionInverse[2].zw); diff --git a/shaders/dimensions/all_translucent.fsh b/shaders/dimensions/all_translucent.fsh index e8ae91e..4c7c68e 100644 --- a/shaders/dimensions/all_translucent.fsh +++ b/shaders/dimensions/all_translucent.fsh @@ -40,8 +40,9 @@ const bool colortex4MipmapEnabled = true; uniform sampler2D noisetex; uniform sampler2D depthtex1; uniform sampler2D depthtex0; + #ifdef DISTANT_HORIZONS -uniform sampler2D dhDepthTex1; + uniform sampler2D dhDepthTex1; #endif uniform sampler2D colortex7; uniform sampler2D colortex12; @@ -94,12 +95,13 @@ uniform float sunIntensity; uniform vec3 sunColor; uniform vec3 nsunColor; +#include "/lib/util.glsl" #include "/lib/Shadow_Params.glsl" #include "/lib/color_transforms.glsl" #include "/lib/projections.glsl" #include "/lib/sky_gradient.glsl" #include "/lib/waterBump.glsl" -#include "/lib/util.glsl" + #ifdef OVERWORLD_SHADER flat varying float Flashing; @@ -124,6 +126,7 @@ uniform vec3 nsunColor; #endif #include "/lib/diffuse_lighting.glsl" + float blueNoise(){ return fract(texelFetch2D(noisetex, ivec2(gl_FragCoord.xy)%512, 0).a + 1.0/1.6180339887 * frameCounter); } @@ -182,31 +185,6 @@ vec3 applyBump(mat3 tbnMatrix, vec3 bump, float puddle_values){ return normalize(bump*tbnMatrix); } -// vec2 tapLocation(int sampleNumber,int nb, float nbRot,float jitter,float distort) -// { -// float alpha = (sampleNumber+jitter)/nb; -// float angle = jitter*6.28 + alpha * nbRot * 6.28; - -// float sin_v, cos_v; - -// sin_v = sin(angle); -// cos_v = cos(angle); - -// return vec2(cos_v, sin_v)*sqrt(alpha); -// } -vec2 tapLocation_simple( - int samples, int totalSamples, float rotation, float rng -){ - const float PI = 3.141592653589793238462643383279502884197169; - float alpha = float(samples + rng) * (1.0 / float(totalSamples)); - float angle = alpha * (rotation * PI); - - float sin_v = sin(angle); - float cos_v = cos(angle); - - return vec2(cos_v, sin_v) * sqrt(alpha); -} - vec2 CleanSample( int samples, float totalSamples, float noise ){ @@ -392,7 +370,6 @@ float ComputeShadowMap(inout vec3 directLightColor, vec3 playerPos, float maxDis float rdMul = 14.0*distortFactor*d0*k/shadowMapResolution; for(int i = 0; i < samples; i++){ - // vec2 offsetS = tapLocation_simple(i, 7, 9, noise) * 0.5; vec2 offsetS = CleanSample(i, samples - 1, noise) * 0.3; projectedShadowPosition.xy += rdMul*offsetS; #else @@ -898,7 +875,7 @@ if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 ) gl_FragData[0].rgb = Direct_lighting * 0.1; #endif - gl_FragData[3].a = encodeVec2(lightmap); + gl_FragData[3].a = clamp(lightmap.y,0.0,1.0); } } \ No newline at end of file diff --git a/shaders/dimensions/all_vanilla_emissives.fsh b/shaders/dimensions/all_vanilla_emissives.fsh index 3cb314f..e3f4828 100644 --- a/shaders/dimensions/all_vanilla_emissives.fsh +++ b/shaders/dimensions/all_vanilla_emissives.fsh @@ -11,7 +11,6 @@ flat varying float exposure; varying vec4 tangent; varying vec4 normalMat; -attribute vec4 at_tangent; uniform float frameTimeCounter; //faster and actually more precise than pow 2.2 diff --git a/shaders/dimensions/composite1.fsh b/shaders/dimensions/composite1.fsh index 69b7200..f210516 100644 --- a/shaders/dimensions/composite1.fsh +++ b/shaders/dimensions/composite1.fsh @@ -9,9 +9,13 @@ #extension GL_ARB_shading_language_packing: enable #endif +#include "/lib/util.glsl" #include "/lib/res_params.glsl" +#define diagonal3_old(m) vec3((m)[0].x, (m)[1].y, m[2].z) +#define projMAD_old(m, v) (diagonal3_old(m) * (v) + (m)[3].xyz) + const bool colortex5MipmapEnabled = true; #ifdef OVERWORLD_SHADER @@ -134,8 +138,6 @@ flat varying float exposure; uniform int heldItemId2; #endif -#define diagonal3(m) vec3((m)[0].x, (m)[1].y, m[2].z) -#define projMAD(m, v) (diagonal3(m) * (v) + (m)[3].xyz) void convertHandDepth(inout float depth) { float ndcDepth = depth * 2.0 - 1.0; @@ -173,7 +175,6 @@ vec3 toScreenSpace(vec3 p) { // #define CLOUDS_INTERSECT_TERRAIN #endif -#include "/lib/util.glsl" #ifdef IS_LPV_ENABLED #include "/lib/hsv.glsl" @@ -295,7 +296,7 @@ vec3 toShadowSpaceProjected(vec3 feetPlayerPos){ feetPlayerPos = mat3(gbufferModelViewInverse) * feetPlayerPos + gbufferModelViewInverse[3].xyz; feetPlayerPos = mat3(shadowModelView) * feetPlayerPos + shadowModelView[3].xyz; - feetPlayerPos = diagonal3(DH_shadowProjection) * feetPlayerPos + DH_shadowProjection[3].xyz; + feetPlayerPos = diagonal3_old(DH_shadowProjection) * feetPlayerPos + DH_shadowProjection[3].xyz; return feetPlayerPos; } @@ -944,9 +945,9 @@ void main() { if(!hand) GriAndEminShadowFix(shadowPlayerPos, viewToWorld(FlatNormals), vanilla_AO, lightmap.y); vec3 projectedShadowPosition = mat3(shadowModelView) * shadowPlayerPos + shadowModelView[3].xyz; - projectedShadowPosition = diagonal3(shadowProjection) * projectedShadowPosition + shadowProjection[3].xyz; + projectedShadowPosition = diagonal3_old(shadowProjection) * projectedShadowPosition + shadowProjection[3].xyz; - #if OPTIMIZED_SHADOW_DISTANCE > 0.0 + #if OPTIMIZED_SHADOW_DISTANCE > 0 float shadowMapFalloff = smoothstep(0.0, 1.0, min(max(1.0 - length(feetPlayerPos) / (shadowDistance+16),0.0)*5.0,1.0)); float shadowMapFalloff2 = smoothstep(0.0, 1.0, min(max(1.0 - length(feetPlayerPos) / shadowDistance,0.0)*5.0,1.0)); #else diff --git a/shaders/dimensions/composite5.fsh b/shaders/dimensions/composite5.fsh index 03a044b..d07779b 100644 --- a/shaders/dimensions/composite5.fsh +++ b/shaders/dimensions/composite5.fsh @@ -76,8 +76,7 @@ uniform int hideGUI; -#define fsign(a) (clamp((a)*1e35,0.,1.)*2.-1.) - +#include "/lib/util.glsl" #include "/lib/projections.glsl" @@ -327,6 +326,10 @@ const vec2[8] offsets = vec2[8](vec2(1./8.,-3./8.), +#ifdef DAMAGE_TAKEN_EFFECT + uniform float CriticalDamageTaken; +#endif + vec4 TAA_hq(bool hand){ #ifdef TAA_UPSCALING @@ -401,7 +404,7 @@ vec4 TAA_hq(bool hand){ float movementRejection = (0.12+isclamped)*clamp(length(velocity/texelSize),0.0,1.0); - float depthDiff = texture2D(colortex14, previousPosition.xy).a; + // float depthDiff = texture2D(colortex14, previousPosition.xy).a; // movementRejection = mix( 0.0, 1.0, depthDiff); if(hand) movementRejection *= 5.0; @@ -409,6 +412,10 @@ vec4 TAA_hq(bool hand){ //Blend current pixel with clamped history, apply fast tonemap beforehand to reduce flickering vec4 supersampled = vec4(invTonemap(mix(tonemap(finalcAcc), tonemap(albedoCurrent0), clamp(BLEND_FACTOR + movementRejection, 0.0,1.0))), 1.0); + #ifdef DAMAGE_TAKEN_EFFECT + if(CriticalDamageTaken > 0.01) supersampled.rgb = mix(supersampled.rgb, texture2D(colortex5, adjTC).rgb, sqrt(CriticalDamageTaken)*0.8); + #endif + //De-tonemap return supersampled; #endif diff --git a/shaders/dimensions/final.fsh b/shaders/dimensions/final.fsh index 6a2eed7..b6e099d 100644 --- a/shaders/dimensions/final.fsh +++ b/shaders/dimensions/final.fsh @@ -7,12 +7,19 @@ uniform sampler2D colortex14; uniform sampler2D depthtex0; uniform vec2 texelSize; uniform float frameTimeCounter; +uniform float viewHeight; +uniform float viewWidth; +uniform float aspectRatio; uniform sampler2D shadow; uniform sampler2D shadowcolor0; uniform sampler2D shadowcolor1; uniform sampler2D shadowtex0; uniform sampler2D shadowtex1; +uniform sampler2D noisetex; + +uniform vec3 previousCameraPosition; +uniform vec3 cameraPosition; #include "/lib/color_transforms.glsl" #include "/lib/color_dither.glsl" @@ -153,7 +160,10 @@ void main() { applyContrast(FINAL_COLOR, CONTRAST); // for fun - applyGameplayEffects_FRAGMENT(FINAL_COLOR, texcoord, interleaved_gradientNoise()); // for making the fun, more fun + #if defined LOW_HEALTH_EFFECT || defined DAMAGE_TAKEN_EFFECT || defined WATER_ON_CAMERA_EFFECT + // for making the fun, more fun + applyGameplayEffects(FINAL_COLOR, texcoord, interleaved_gradientNoise()); + #endif gl_FragColor.rgb = FINAL_COLOR; diff --git a/shaders/dimensions/fogBehindTranslucent_pass.fsh b/shaders/dimensions/fogBehindTranslucent_pass.fsh index a197a76..16d537a 100644 --- a/shaders/dimensions/fogBehindTranslucent_pass.fsh +++ b/shaders/dimensions/fogBehindTranslucent_pass.fsh @@ -341,7 +341,9 @@ void main() { if(texture2D(colortex2, tc).a > 0.0 || iswater){ #ifdef OVERWORLD_SHADER - vec2 lightmap = decodeVec2(texture2D(colortex14, tc).a); + // vec2 lightmap = decodeVec2(texture2D(colortex14, tc).a); + + vec2 lightmap = vec2(0.0,texture2D(colortex14, tc).a); #ifdef DISTANT_HORIZONS if(z >= 1.0) lightmap.y = 0.99; @@ -360,8 +362,8 @@ void main() { - // indirectLightColor_dynamic *= ambient_brightness * pow(1.0-pow(1.0-lightmap.y,0.5),3.0) ; - // float TorchBrightness_autoAdjust = mix(1.0, 30.0, clamp(exp(-10.0*exposure),0.0,1.0)) ; + indirectLightColor_dynamic *= ambient_brightness * pow(1.0-pow(1.0-lightmap.y,0.5),3.0) ; + float TorchBrightness_autoAdjust = mix(1.0, 30.0, clamp(exp(-10.0*exposure),0.0,1.0)) ; // indirectLightColor_dynamic += vec3(TORCH_R,TORCH_G,TORCH_B) * TorchBrightness_autoAdjust * pow(1.0-sqrt(1.0-clamp(lightmap.x,0.0,1.0)),2.0) * 2.0; vec4 VolumetricFog2 = vec4(0,0,0,1); diff --git a/shaders/lib/gameplay_effects.glsl b/shaders/lib/gameplay_effects.glsl index f40eab2..9347a53 100644 --- a/shaders/lib/gameplay_effects.glsl +++ b/shaders/lib/gameplay_effects.glsl @@ -3,11 +3,15 @@ uniform float maxPlayerHealth; uniform float oneHeart; uniform float threeHeart; + + uniform float CriticalDamageTaken; + uniform float MinorDamageTaken; #else uniform bool isDead; #endif -uniform float hurt; +uniform float exitWater; +uniform int isEyeInWater; // uniform float currentPlayerHunger; // uniform float maxPlayerHunger; @@ -28,43 +32,77 @@ uniform float hurt; // uniform bool isSpectator; -void applyGameplayEffects_FRAGMENT(inout vec3 color, in vec2 texcoord, float noise){ +void applyGameplayEffects(inout vec3 color, in vec2 texcoord, float noise){ + + // detect when health is zero + #ifdef IS_IRIS + bool isDead = currentPlayerHealth * maxPlayerHealth <= 0.0 && currentPlayerHealth > -1; + #else + float oneHeart = 0.0; + float threeHeart = 0.0; + #endif + + float distortmask = 0.0; + float vignette = sqrt(clamp(dot(texcoord*2.0 - 1.0, texcoord*2.0 - 1.0) * 0.5, 0.0, 1.0)); + + //////////////////////// DAMAGE DISTORTION ///////////////////// + #if defined LOW_HEALTH_EFFECT || defined DAMAGE_TAKEN_EFFECT + float heartBeat = (pow(sin(frameTimeCounter * 15)*0.5+0.5,2.0)*0.2 + 0.1) ; + + // apply low health distortion effects + float damageDistortion = vignette * noise * heartBeat * threeHeart; + + // apply critical hit distortion effect + damageDistortion = mix(damageDistortion, vignette * (0.5 + noise), CriticalDamageTaken) * MOTION_AMOUNT; + + // apply death distortion effect + distortmask = isDead ? noise*0.7 : damageDistortion; + #endif + //////////////////////// WATER DISTORTION ///////////////////// + #if defined WATER_ON_CAMERA_EFFECT + if(exitWater > 0.0){ + vec3 scale = vec3(1.0,1.0,0.0); + scale.xy = (isEyeInWater == 1 ? vec2(0.3) : vec2(0.5, 0.25 + (exitWater*exitWater)*0.25 ) ) * vec2(aspectRatio,1.0); + scale.z = isEyeInWater == 1 ? 0.0 : exitWater; + + float waterDrops = texture2D(noisetex, (texcoord - vec2(0.0, scale.z)) * scale.xy).r; + + if(isEyeInWater == 1) waterDrops = waterDrops*waterDrops * 0.3; + if(isEyeInWater == 0) waterDrops = sqrt(min(max(waterDrops - (1.0-sqrt(exitWater))*0.7,0.0) * (1.0 + exitWater),1.0)) * 0.3; + + // apply distortion effects for exiting water and under water + distortmask = max(distortmask, waterDrops); + } + #endif + + //////////////////////// APPLY DISTORTION ///////////////////// + // all of the distortion will be based around zooming the UV in the center + vec2 zoomUV = 0.5 + (texcoord - 0.5) * (1.0 - distortmask); + vec3 distortedColor = texture2D(colortex7, zoomUV).rgb; + + #ifdef WATER_ON_CAMERA_EFFECT + // apply the distorted water color to the scene, but revert back to before when it ends + if(exitWater > 0.01) color = distortedColor; + #endif + + //////////////////////// APPLY COLOR EFFECTS ///////////////////// + #if defined LOW_HEALTH_EFFECT || defined DAMAGE_TAKEN_EFFECT + vec3 distortedColorLuma = vec3(1.0, 0.0, 0.0) * dot(distortedColor, vec3(0.21, 0.72, 0.07)); - #if defined LOW_HEALTH_EFFECT || defined DAMAGE_TAKEN_EFFECT - // detect when health is zero - #ifdef IS_IRIS - bool isDead = currentPlayerHealth * maxPlayerHealth <= 0.0 && currentPlayerHealth > -1; - #else - float oneHeart = 0.0; - float threeHeart = 0.0; - #endif - - float vignette = sqrt(clamp(dot(texcoord*2.0 - 1.0, texcoord*2.0 - 1.0) * 0.5, 0.0, 1.0)); - - // heart beat effect to scale stuff with, make it more intense. theres a multiplier "MOTION_AMOUNT" for accessiblity - float beatingRate = isDead ? 0.0 : (oneHeart > 0.0 ? 15.0 : 7.5); - float heartBeat = (pow(sin(frameTimeCounter * beatingRate)*0.5+0.5,2.0)*0.2 + 0.1); - - // scale UV to be more and more lower frequency towards the edges of the screen, to create a tunnel vision effect, - vec2 zoomUV = 0.5 + (texcoord - 0.5) * (1.0 - vignette * (isDead ? noise*0.7 : noise * heartBeat * MOTION_AMOUNT)); - vec3 distortedScreen = vec3(1.0, 0.0, 0.0) * dot(texture2D(colortex7, zoomUV).rgb, vec3(0.21, 0.72, 0.07)); - #ifdef LOW_HEALTH_EFFECT - // at 1 heart or 3 hearts, create 2 levels of a strain / tunnel vision effect. + float colorLuma = dot(color, vec3(0.21, 0.72, 0.07)); - // black and white version of the scene color. - vec3 colorLuma = vec3(1.0, 1.0, 1.0) * dot(color,vec3(0.21, 0.72, 0.07)); + vec3 LumaRedEdges = mix(vec3(colorLuma), vec3(1.0, 0.3, 0.3) * distortedColorLuma.r, vignette); - // I LOVE LINEAR INTERPOLATION - color = mix(color, mix(colorLuma, distortedScreen, vignette), mix(vignette * threeHeart, oneHeart, oneHeart)); - - if(isDead) color = distortedScreen*0.3; + // apply color effects for when you are at low health + color = mix(color, LumaRedEdges, mix(vignette * threeHeart, oneHeart, oneHeart)); #endif - #ifdef DAMAGE_TAKEN_EFFECT - // when damage is taken, flash the above effect. because it uses the stuff above, it seamlessly blends to them. - color = mix(color, distortedScreen, (vignette*vignette) * sqrt(hurt)); + color = mix(color, distortedColorLuma, vignette * sqrt(MinorDamageTaken)); + color = mix(color, distortedColorLuma, sqrt(CriticalDamageTaken)); #endif + + if(isDead) color = distortedColorLuma * 0.3; #endif } \ No newline at end of file diff --git a/shaders/lib/projections.glsl b/shaders/lib/projections.glsl index 2cead9f..31e2352 100644 --- a/shaders/lib/projections.glsl +++ b/shaders/lib/projections.glsl @@ -8,8 +8,8 @@ uniform mat4 shadowProjection; uniform vec3 cameraPosition; -#define diagonal3(m) vec3((m)[0].x, (m)[1].y, m[2].z) -#define projMAD(m, v) (diagonal3(m) * (v) + (m)[3].xyz) +// #define diagonal3(m) vec3((m)[0].x, (m)[1].y, m[2].z) +// #define projMAD(m, v) (diagonal3(m) * (v) + (m)[3].xyz) vec3 toClipSpace3(vec3 viewSpacePosition) { return projMAD(gbufferProjection, viewSpacePosition) / -viewSpacePosition.z * 0.5 + 0.5; diff --git a/shaders/lib/settings.glsl b/shaders/lib/settings.glsl index d4863f2..21af6ad 100644 --- a/shaders/lib/settings.glsl +++ b/shaders/lib/settings.glsl @@ -125,9 +125,14 @@ const float sunPathRotation = -35; //[-90 -89 -88 -87 -86 -85 -84 -83 -82 -81 -8 const int shadowMapResolution = 2048; // [512 768 1024 1536 2048 3172 4096 8192] const float shadowDistance = 128.0; // [32.0 48.0 64.0 80.0 96.0 112.0 128.0 144.0 160.0 176.0 192.0 208.0 224.0 240.0 256.0 272.0 288.0 304.0 320.0 336.0 352.0 368.0 384.0 512.0 768.0 1024.0 1536.0 2048.0 4096.0 8192.0] -#define OPTIMIZED_SHADOW_DISTANCE 1.0 // [-1.0 1.0] -const float shadowDistanceRenderMul = OPTIMIZED_SHADOW_DISTANCE; +#ifdef IS_IRIS + #define OPTIMIZED_SHADOW_DISTANCE 1 // [-1 1] + const float shadowDistanceRenderMul = OPTIMIZED_SHADOW_DISTANCE; +#else + #define OPTIMIZED_SHADOW_DISTANCE 1 // [-1 1] + const float shadowDistanceRenderMul = float(OPTIMIZED_SHADOW_DISTANCE); +#endif const float entityShadowDistanceMul = 0.25; // [0.01 0.02 0.03 0.04 0.05 0.10 0.15 0.20 0.25 0.30 0.35 0.40 0.45 0.50 0.75 1.00] @@ -591,8 +596,20 @@ const vec3 aerochrome_color = mix(vec3(1.0, 0.0, 0.0), vec3(0.715, 0.303, 0.631) /////////////////////////////////////////////////////// #define MOTION_AMOUNT 0.25 // [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] + +#ifdef IS_IRIS #define DAMAGE_TAKEN_EFFECT #define LOW_HEALTH_EFFECT +#endif + +#define WATER_ON_CAMERA_EFFECT + +#ifdef LOW_HEALTH_EFFECT +#endif +#ifdef DAMAGE_TAKEN_EFFECT +#endif +#ifdef WATER_ON_CAMERA_EFFECT +#endif diff --git a/shaders/shaders.properties b/shaders/shaders.properties index ed8d82a..20e72b7 100644 --- a/shaders/shaders.properties +++ b/shaders/shaders.properties @@ -318,7 +318,7 @@ BLISS_SHADERS \ SHADOWS_GRADE_B MIDS_GRADE_B HIGHLIGHTS_GRADE_B \ SHADOWS_GRADE_MUL MIDS_GRADE_MUL HIGHLIGHTS_GRADE_MUL ### COOL GAMEPLAY EFFECTS - screen.GAMEPLAY_EFFECTS = MOTION_AMOUNT DAMAGE_TAKEN_EFFECT LOW_HEALTH_EFFECT + screen.GAMEPLAY_EFFECTS = MOTION_AMOUNT DAMAGE_TAKEN_EFFECT LOW_HEALTH_EFFECT WATER_ON_CAMERA_EFFECT @@ -480,16 +480,31 @@ uniform.float.noPuddleAreas = smooth(if(in(biome, 3, 4, 16, 37, 39, 48, 49, 31, ####### RANDOM STUFF ####### ############################ +#if defined WATER_ON_CAMERA_EFFECT + uniform.float.exitWater = smooth(if(isEyeInWater == 1,1,0),0.0,5.0) +#endif + #if defined LOW_HEALTH_EFFECT || defined DAMAGE_TAKEN_EFFECT #ifdef IS_IRIS variable.float.Currenthealth = currentPlayerHealth * maxPlayerHealth uniform.float.oneHeart = smooth(if(Currenthealth <= 2.0 && currentPlayerHealth > -1.0, 1,0), 0.0,1.0) uniform.float.threeHeart = smooth(if(Currenthealth <= 6.0 && currentPlayerHealth > -1.0, 1,0), 0.0,1.0) + + # let the binary value last slightly longer after it becomes false, to remove any failures to detect damage, + variable.bool.isHurtSmooth = smooth(if(is_hurt, 0.0, 1.0), 0.0, 1.0) < 1.0 + + # detect over 2 hearts of damage taken + variable.float.detectSmallDamage = smooth(if(isHurtSmooth, 0.0, Currenthealth), 0.0, 0.5) + uniform.float.MinorDamageTaken = smooth(if(Currenthealth < detectSmallDamage && currentPlayerHealth > -1.0, 1.0, 0.0), 0.0, 1.0) + + # detect over 5 hearts of damage taken + variable.float.detectLargeDamage = smooth(if(isHurtSmooth, 0.0, Currenthealth), 0.0, 0.13) + variable.float.critHit = smooth(if(Currenthealth < detectLargeDamage && currentPlayerHealth > -1.0, 1.0, 0.0), 0.0, 1.0) + uniform.float.CriticalDamageTaken = smooth(if(critHit > 0.01, 1.0, 0.0), 0.5, 3.0) + #else uniform.bool.isDead = !is_alive #endif - - uniform.float.hurt = smooth(if(is_hurt,1,0),0.0,0.5) #endif # photon stuff