fix: repair every immediately-obviously-safe rt reference
This commit is contained in:
1 parent
8c05732838
commit
2af9c2209f
9 files changed
+27
-29
No files matched your search
@@ -169,7 +169,7 @@ namespace CalamityMod.FluidSimulation
|
||||
diffusionFactor *= DeltaTime * Size;
|
||||
ApplyThingToTarget(field.NextState, () =>
|
||||
{
|
||||
Main.instance.GraphicsDevice.Textures[1] = field.PreviousState;
|
||||
Main.instance.GraphicsDevice.Textures[1] = field.PreviousState.Target;
|
||||
CalamityShaders.FluidShaders.Value.Parameters["size"].SetValue(Size);
|
||||
CalamityShaders.FluidShaders.Value.Parameters["diffusionFactor"].SetValue(diffusionFactor);
|
||||
CalamityShaders.FluidShaders.Value.Parameters["handlingColors"].SetValue(colors);
|
||||
@@ -209,9 +209,9 @@ namespace CalamityMod.FluidSimulation
|
||||
{
|
||||
ApplyThingToTarget(DivergencePoissonField, () =>
|
||||
{
|
||||
Main.instance.GraphicsDevice.Textures[1] = DivergencePoissonField;
|
||||
Main.instance.GraphicsDevice.Textures[1] = DivergencePoissonField.Target;
|
||||
Main.instance.GraphicsDevice.Textures[2] = velocities;
|
||||
Main.instance.GraphicsDevice.Textures[4] = DivergenceField;
|
||||
Main.instance.GraphicsDevice.Textures[4] = DivergenceField.Target;
|
||||
CalamityShaders.FluidShaders.Value.Parameters["size"].SetValue(Size);
|
||||
CalamityShaders.FluidShaders.Value.CurrentTechnique.Passes["PerformPoissonIterationPass"].Apply();
|
||||
});
|
||||
@@ -220,7 +220,7 @@ namespace CalamityMod.FluidSimulation
|
||||
ApplyThingToTarget(velocities, () =>
|
||||
{
|
||||
Main.instance.GraphicsDevice.Textures[1] = velocities;
|
||||
Main.instance.GraphicsDevice.Textures[3] = DivergencePoissonField;
|
||||
Main.instance.GraphicsDevice.Textures[3] = DivergencePoissonField.Target;
|
||||
CalamityShaders.FluidShaders.Value.CurrentTechnique.Passes["ClearDivergencePass"].Apply();
|
||||
});
|
||||
}
|
||||
@@ -279,9 +279,9 @@ namespace CalamityMod.FluidSimulation
|
||||
Main.instance.GraphicsDevice.Clear(Color.Transparent);
|
||||
|
||||
Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.LinearClamp, DepthStencilState.None, Main.Rasterizer, null, Matrix.Identity);
|
||||
Main.instance.GraphicsDevice.Textures[5] = ColorField.NextState;
|
||||
Main.instance.GraphicsDevice.Textures[5] = ColorField.NextState.Target;
|
||||
CalamityShaders.FluidShaders.Value.CurrentTechnique.Passes["DrawFluidPass"].Apply();
|
||||
Main.spriteBatch.Draw(DensityField.NextState, Vector2.Zero, null, Color.White, 0f, Vector2.Zero, 1f, 0, 0f);
|
||||
Main.spriteBatch.Draw(DensityField.NextState.Target, Vector2.Zero, null, Color.White, 0f, Vector2.Zero, 1f, 0, 0f);
|
||||
Main.spriteBatch.End();
|
||||
|
||||
Main.instance.GraphicsDevice.SetRenderTarget(null);
|
||||
@@ -323,7 +323,7 @@ namespace CalamityMod.FluidSimulation
|
||||
|
||||
shaderPreparations?.Invoke(OutputTarget);
|
||||
|
||||
Main.spriteBatch.Draw(OutputTarget, drawPosition, null, Color.White, 0f, OutputTarget.Size * 0.5f, Scale, 0, 0f);
|
||||
Main.spriteBatch.Draw(OutputTarget.Target, drawPosition, null, Color.White, 0f, OutputTarget.Target.Size() * 0.5f, Scale, 0, 0f);
|
||||
Main.spriteBatch.End();
|
||||
|
||||
if (needsToCallEnd)
|
||||
|
||||
@@ -21,9 +21,6 @@ namespace CalamityMod.FluidSimulation
|
||||
|
||||
public void SwapState() => Utils.Swap(ref PreviousState, ref NextState);
|
||||
|
||||
public RenderTarget2D FieldColorCreateCondition(int screen, int height) =>
|
||||
new(Main.instance.GraphicsDevice, Size, Size, true, FieldContents, DepthFormat.Depth24, 0, RenderTargetUsage.PreserveContents);
|
||||
|
||||
public FluidFieldState(int size, SurfaceFormat fieldContents = SurfaceFormat.Color)
|
||||
{
|
||||
if (Main.dedServ)
|
||||
@@ -32,8 +29,9 @@ namespace CalamityMod.FluidSimulation
|
||||
Size = size;
|
||||
FieldContents = fieldContents;
|
||||
|
||||
PreviousState = new(false, FieldColorCreateCondition, false);
|
||||
NextState = new(false, FieldColorCreateCondition, false);
|
||||
var descriptor = new RenderTargetDescriptor(FieldContents, DepthFormat.Depth24, 0, RenderTargetUsage.PreserveContents, true);
|
||||
PreviousState = RenderTargetPool.Shared.Rent(Main.instance.GraphicsDevice, Size, Size, descriptor);
|
||||
NextState = RenderTargetPool.Shared.Rent(Main.instance.GraphicsDevice, Size, Size, descriptor);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -74,7 +74,7 @@ namespace CalamityMod.Graphics.Metaballs
|
||||
metaballShader.Value.Parameters["edgeColor"]?.SetValue(EdgeColor.ToVector4());
|
||||
metaballShader.Value.Parameters["singleFrameScreenOffset"]?.SetValue((Main.screenLastPosition - Main.screenPosition) / screenSize);
|
||||
|
||||
gd.Textures[1] = DoGVisualsManager.DistortionForegroundContentsTarget;
|
||||
gd.Textures[1] = DoGVisualsManager.DistortionForegroundContentsTarget.Target;
|
||||
gd.SamplerStates[1] = SamplerState.LinearWrap;
|
||||
|
||||
metaballShader.Value.CurrentTechnique.Passes[0].Apply();
|
||||
|
||||
@@ -110,7 +110,7 @@ namespace CalamityMod.Graphics.Metaballs
|
||||
metaball.PrepareShaderForTarget(i);
|
||||
|
||||
// Draw the metaball's raw contents with the shader.
|
||||
Main.spriteBatch.Draw(metaball.LayerTargets[i], Vector2.Zero, Color.White);
|
||||
Main.spriteBatch.Draw(metaball.LayerTargets[i].Target, Vector2.Zero, Color.White);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@ namespace CalamityMod.Graphics.Renderers
|
||||
/// Draw the target here. By default, just draws the target.
|
||||
/// </summary>
|
||||
/// <param name="spriteBatch"></param>
|
||||
public virtual void DrawTarget(SpriteBatch spriteBatch) => spriteBatch.Draw(MainTarget, Vector2.Zero, Color.White);
|
||||
public virtual void DrawTarget(SpriteBatch spriteBatch) => spriteBatch.Draw(MainTarget.Target, Vector2.Zero, Color.White);
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -189,10 +189,10 @@ namespace CalamityMod.Graphics.Renderers.CalamityRenderers
|
||||
|
||||
// If it is dyeable, and a dye exists, apply it. This has null safety, as dyeShader can be null here.
|
||||
if (renderer.ShaderIsDyeable && Dyes.TryGetValue(renderer, out var dyeID) && dyeID > 0)
|
||||
GameShaders.Armor.Apply(dyeID, null, new(target, Vector2.Zero, new Rectangle(0, 0, target.Width, target.Height), Color.White));
|
||||
GameShaders.Armor.Apply(dyeID, null, new(target.Target, Vector2.Zero, new Rectangle(0, 0, target.Target.Width, target.Target.Height), Color.White));
|
||||
|
||||
// Draw the assosiated target that has been drawn to.
|
||||
spriteBatch.Draw(target, Vector2.Zero, Color.White with { A = 0 });
|
||||
spriteBatch.Draw(target.Target, Vector2.Zero, Color.White with { A = 0 });
|
||||
}
|
||||
|
||||
spriteBatch.End();
|
||||
|
||||
@@ -95,7 +95,7 @@ namespace CalamityMod.Graphics.Renderers.CalamityRenderers
|
||||
blightShader.UseOpacity(0.7f);
|
||||
blightShader.Apply();
|
||||
|
||||
spriteBatch.Draw(MainTarget, Vector2.Zero, Color.White);
|
||||
spriteBatch.Draw(MainTarget.Target, Vector2.Zero, Color.White);
|
||||
|
||||
spriteBatch.End();
|
||||
spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, RasterizerState.CullCounterClockwise);
|
||||
|
||||
+2
-2
@@ -415,8 +415,8 @@ namespace CalamityMod.Skies
|
||||
{
|
||||
// Impose the distortion rift contents onto the primitives via shader.
|
||||
var metaballShader = CalamityShaders.MetaballEdgeShader;
|
||||
Texture2D distortionRiftContents = DoGVisualsManager.DistortionRiftBackgroundContentsTarget;
|
||||
Texture2D distortionRift = DoGVisualsManager.DistortionRiftPrimitivesTarget;
|
||||
Texture2D distortionRiftContents = DoGVisualsManager.DistortionRiftBackgroundContentsTarget.Target;
|
||||
Texture2D distortionRift = DoGVisualsManager.DistortionRiftPrimitivesTarget.Target;
|
||||
|
||||
Vector2 screenSize = new(Main.screenWidth, Main.screenHeight);
|
||||
|
||||
|
||||
@@ -194,7 +194,7 @@ namespace CalamityMod.Systems.Graphic.PixelationSystem
|
||||
Main.spriteBatch.Begin(default, keyValuePair.Key, SamplerState.PointClamp, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix);
|
||||
|
||||
float targetScale = 1f / PixelationResolution;
|
||||
Main.spriteBatch.Draw(keyValuePair.Value, Vector2.Zero, null, Color.White, 0f, Vector2.Zero, targetScale, SpriteEffects.None, 0f);
|
||||
Main.spriteBatch.Draw(keyValuePair.Value.Target, Vector2.Zero, null, Color.White, 0f, Vector2.Zero, targetScale, SpriteEffects.None, 0f);
|
||||
Main.spriteBatch.End();
|
||||
}
|
||||
}
|
||||
@@ -241,42 +241,42 @@ namespace CalamityMod.Systems.Graphic.PixelationSystem
|
||||
{
|
||||
case GeneralDrawLayer.BeforeAllTiles:
|
||||
if (!PixelTargets_BeforeAllTiles.ContainsKey(blendState))
|
||||
Main.QueueMainThreadAction(() => PixelTargets_BeforeAllTiles[blendState] = ScreenspaceTargetPool.Shared.Rent(Main.instance.GraphicsDevice, (w, h) => ((int)(w * PixelationResolution), (int)(h * PixelationResolution))))
|
||||
Main.QueueMainThreadAction(() => PixelTargets_BeforeAllTiles[blendState] = ScreenspaceTargetPool.Shared.Rent(Main.instance.GraphicsDevice, (w, h) => ((int)(w * PixelationResolution), (int)(h * PixelationResolution))));
|
||||
break;
|
||||
|
||||
case GeneralDrawLayer.BeforeSolidTiles:
|
||||
if (!PixelTargets_BeforeSolidTiles.ContainsKey(blendState))
|
||||
Main.QueueMainThreadAction(() => PixelTargets_BeforeSolidTiles[blendState] = ScreenspaceTargetPool.Shared.Rent(Main.instance.GraphicsDevice, (w, h) => ((int)(w * PixelationResolution), (int)(h * PixelationResolution))))
|
||||
Main.QueueMainThreadAction(() => PixelTargets_BeforeSolidTiles[blendState] = ScreenspaceTargetPool.Shared.Rent(Main.instance.GraphicsDevice, (w, h) => ((int)(w * PixelationResolution), (int)(h * PixelationResolution))));
|
||||
break;
|
||||
|
||||
case GeneralDrawLayer.BeforeNPCs:
|
||||
if (!PixelTargets_BeforeNPCs.ContainsKey(blendState))
|
||||
Main.QueueMainThreadAction(() => PixelTargets_BeforeNPCs[blendState] = ScreenspaceTargetPool.Shared.Rent(Main.instance.GraphicsDevice, (w, h) => ((int)(w * PixelationResolution), (int)(h * PixelationResolution))))
|
||||
Main.QueueMainThreadAction(() => PixelTargets_BeforeNPCs[blendState] = ScreenspaceTargetPool.Shared.Rent(Main.instance.GraphicsDevice, (w, h) => ((int)(w * PixelationResolution), (int)(h * PixelationResolution))));
|
||||
break;
|
||||
|
||||
case GeneralDrawLayer.AfterNPCs:
|
||||
if (!PixelTargets_AfterNPCs.ContainsKey(blendState))
|
||||
Main.QueueMainThreadAction(() => PixelTargets_AfterNPCs[blendState] = ScreenspaceTargetPool.Shared.Rent(Main.instance.GraphicsDevice, (w, h) => ((int)(w * PixelationResolution), (int)(h * PixelationResolution))))
|
||||
Main.QueueMainThreadAction(() => PixelTargets_AfterNPCs[blendState] = ScreenspaceTargetPool.Shared.Rent(Main.instance.GraphicsDevice, (w, h) => ((int)(w * PixelationResolution), (int)(h * PixelationResolution))));
|
||||
break;
|
||||
|
||||
case GeneralDrawLayer.BeforeProjectiles:
|
||||
if (!PixelTargets_BeforeProjectiles.ContainsKey(blendState))
|
||||
Main.QueueMainThreadAction(() => PixelTargets_BeforeProjectiles[blendState] = ScreenspaceTargetPool.Shared.Rent(Main.instance.GraphicsDevice, (w, h) => ((int)(w * PixelationResolution), (int)(h * PixelationResolution))))
|
||||
Main.QueueMainThreadAction(() => PixelTargets_BeforeProjectiles[blendState] = ScreenspaceTargetPool.Shared.Rent(Main.instance.GraphicsDevice, (w, h) => ((int)(w * PixelationResolution), (int)(h * PixelationResolution))));
|
||||
break;
|
||||
|
||||
case GeneralDrawLayer.AfterProjectiles:
|
||||
if (!PixelTargets_AfterProjectiles.ContainsKey(blendState))
|
||||
Main.QueueMainThreadAction(() => PixelTargets_AfterProjectiles[blendState] = ScreenspaceTargetPool.Shared.Rent(Main.instance.GraphicsDevice, (w, h) => ((int)(w * PixelationResolution), (int)(h * PixelationResolution))))
|
||||
Main.QueueMainThreadAction(() => PixelTargets_AfterProjectiles[blendState] = ScreenspaceTargetPool.Shared.Rent(Main.instance.GraphicsDevice, (w, h) => ((int)(w * PixelationResolution), (int)(h * PixelationResolution))));
|
||||
break;
|
||||
|
||||
case GeneralDrawLayer.AfterPlayers:
|
||||
if (!PixelTargets_AfterPlayers.ContainsKey(blendState))
|
||||
Main.QueueMainThreadAction(() => PixelTargets_AfterPlayers[blendState] = ScreenspaceTargetPool.Shared.Rent(Main.instance.GraphicsDevice, (w, h) => ((int)(w * PixelationResolution), (int)(h * PixelationResolution))))
|
||||
Main.QueueMainThreadAction(() => PixelTargets_AfterPlayers[blendState] = ScreenspaceTargetPool.Shared.Rent(Main.instance.GraphicsDevice, (w, h) => ((int)(w * PixelationResolution), (int)(h * PixelationResolution))));
|
||||
break;
|
||||
|
||||
case GeneralDrawLayer.AfterDusts:
|
||||
if (!PixelTargets_AfterDusts.ContainsKey(blendState))
|
||||
Main.QueueMainThreadAction(() => PixelTargets_AfterDusts[blendState] = ScreenspaceTargetPool.Shared.Rent(Main.instance.GraphicsDevice, (w, h) => ((int)(w * PixelationResolution), (int)(h * PixelationResolution))))
|
||||
Main.QueueMainThreadAction(() => PixelTargets_AfterDusts[blendState] = ScreenspaceTargetPool.Shared.Rent(Main.instance.GraphicsDevice, (w, h) => ((int)(w * PixelationResolution), (int)(h * PixelationResolution))));
|
||||
break;
|
||||
|
||||
case GeneralDrawLayer.AfterEverything:
|
||||
|
||||
Reference in new issue
Block a user