From c2637b956f5ade7bc130b41bfe232f81ca4c0212 Mon Sep 17 00:00:00 2001 From: Memes <114233643+Mr-Memes@users.noreply.github.com> Date: Thu, 22 May 2025 22:43:24 +0200 Subject: [PATCH] I got placebo'd really hard (Found another way). --- Backgrounds/SunkenSeaBurrowsBG.cs | 15 +++++++----- Effects/BasicTextureDistortionShader.fx | 28 ++++++++--------------- Effects/BasicTextureDistortionShader.xnb | Bin 1720 -> 1076 bytes 3 files changed, 18 insertions(+), 25 deletions(-) diff --git a/Backgrounds/SunkenSeaBurrowsBG.cs b/Backgrounds/SunkenSeaBurrowsBG.cs index 15286d2293..838eda9488 100644 --- a/Backgrounds/SunkenSeaBurrowsBG.cs +++ b/Backgrounds/SunkenSeaBurrowsBG.cs @@ -108,12 +108,15 @@ namespace CalamityMod.Backgrounds Main.spriteBatch.End(); Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearClamp, DepthStencilState.None, Main.Rasterizer, distortionShader.Shader, CalamityUtils.BackgroundMatrix); - distortionShader.Shader.Parameters["time"].SetValue(Main.GlobalTimeWrappedHourly); - distortionShader.Shader.Parameters["distortionXSpeed"].SetValue(-0.012f); - distortionShader.Shader.Parameters["distortionYSpeed"].SetValue(0.02f); - distortionShader.Shader.Parameters["distortionStrength"].SetValue(0.035f); - distortionShader.Shader.Parameters["noiseScale"].SetValue(0.075f); - distortionShader.SetShaderTexture(distortionTexture, index: 0); + const float distortionXSpeed = -0.012f; + const float distortionYSpeed = 0.02f; + const float noiseScale = 0.075f; + const float noiseStrength = 0.035f; + Vector2 timeOffset = new Vector2(distortionXSpeed, distortionYSpeed) * Main.GlobalTimeWrappedHourly * noiseScale; + Vector2 noiseScaleStrength = new Vector2(noiseScale, noiseStrength); + distortionShader.Shader.Parameters["timeOffset"].SetValue(timeOffset); + distortionShader.Shader.Parameters["noiseScaleStrength"].SetValue(noiseScaleStrength); + distortionShader.SetShaderTexture(distortionTexture); Main.spriteBatch.Draw(WaterDistortionTarget.Target, new Rectangle(16, 16, Main.screenWidth, Main.screenHeight), Color.White); } diff --git a/Effects/BasicTextureDistortionShader.fx b/Effects/BasicTextureDistortionShader.fx index ec5cc7c77a..a9e45abb3a 100644 --- a/Effects/BasicTextureDistortionShader.fx +++ b/Effects/BasicTextureDistortionShader.fx @@ -1,30 +1,20 @@ -cbuffer DistortionParams : register(b0) -{ - float time; - float distortionXSpeed; - float distortionYSpeed; - float distortionStrength; - float noiseScale; -}; +sampler baseTexture : register(s0); +sampler distortionTexture : register(s1); -Texture2D baseTexture : register(t0); -Texture2D distortionTexture : register(t1); -SamplerState linearSampler : register(s0); +float2 timeOffset; +float2 noiseScaleStrength; -float4 PixelShaderFunction(float4 sampleColor : COLOR0, float2 coords : TEXCOORD0) : SV_Target +float4 PixelShaderFunction(float4 sampleColor : COLOR0, float2 coords : TEXCOORD0) : COLOR { - float2 distortedCoords = coords + float2(time * distortionXSpeed, time * distortionYSpeed); - distortedCoords *= noiseScale; - float distortion = distortionTexture.Sample(linearSampler, distortedCoords).r; - - float4 returnColor = baseTexture.Sample(linearSampler, coords + distortion * distortionStrength); - return returnColor * sampleColor.a; + float2 distortedCoords = coords * noiseScaleStrength.x + timeOffset; + float distortion = tex2D(distortionTexture, distortedCoords).r * noiseScaleStrength.y; + return tex2D(baseTexture, coords + distortion) * sampleColor.a; } technique Technique1 { pass DistortionPass { - PixelShader = compile ps_4_0 PixelShaderFunction(); + PixelShader = compile ps_2_0 PixelShaderFunction(); } } diff --git a/Effects/BasicTextureDistortionShader.xnb b/Effects/BasicTextureDistortionShader.xnb index 7d0177e6500e0595c6dcc0c65c61b9a5500e13b8..b556cca62c8dd13c89a729520435e43fd3f64dc4 100644 GIT binary patch delta 435 zcmdnNyM==z!q2IkmC=M{BF7xb9%crH^V}cy2rwW3Bj^8r9255@=P&}r8W7?POh7hB z3t(PX5NM zA`Ex%YDS=U89_QHKV%V}{DFmq3lS8PrC6*ci?A8k16>F-hob>VFJJ+B2N*^TKsRq- eVE7NB7dU|fjUU8rVB~m$q=o^gCvZpq?x=D+ zMx?w`o)|^ja;&ne6--@Qv-KUZYuVdc+A>{Xy4q^FEQ;=i&`ZLOtHan2Y`s=7icVa8 zCTz#B%*CWO%YSh-U9Y-zTP&KQ?%H}au4e07RipS=yvbYJ!d#qBCW__xEiqRTso7NO zF0m+=vAge6XD63?rvFhUz3!pn<4YJupf`Q9|D6Wf(jAc(4bDoEx6)_$;3|fa;kcIV zVz-h_6b*QLAwH)J($XlfYwQS~mfTNl1QO<6fp3tbkgEw%Vw#LQWh0Q`anJvYn~|GA zY&h;3>_NVqYYX$0TN&ib4vCvWoM{=3$QAXfpmC!wJ#foXX zu8TRMao8Nsv5{b$!6+pTup|wPFQAQ({TBFR$o>NSGi3h(z80TgrwV1df@)xRz0=4>W5 zXQ}_p)!Q3))Q6c|M$J|D7eGy0J2j&Uu%IRGX$z@@mY7c_sonJ~%5JRYlt^K%>n-*B z_6?h1ANQ!&H-*%%zy+wRoqMOVon0?+7Y;c^vo#H3e^~-M&B{g7&THgjO82UaRRE) za4yfYFn1Dq28luV=HK#{YvSb}3~=-)zy~xDYe}pCBR7sT3V!D(LY)?V7p2`qZLQ^= n9pm|?GSO)vC;pjFtSycUa|j%N4L^p+JHR>-