I got placebo'd really hard (Found another way).

This commit is contained in:
Memes committed 2025-05-22 22:43:24 +02:00
1 parent 55fe8d764c
commit c2637b956f
3 files changed
+18 -25

No files matched your search

+9 -6
View File
@@ -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);
}
+9 -19
View File
@@ -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();
}
}
Binary file not shown.