Added gfx quality integration to the fluid sim

This commit is contained in:
Dominic committed 2022-05-27 17:23:48 -05:00
1 parent 542ff04ad2
commit 9936ff7852
5 files changed
+28 -13

No files matched your search

+6 -4
View File
@@ -5861,16 +5861,18 @@ namespace CalamityMod.CalPlayer
if (totalMoonlightDyes > 0)
{
// Initialize the aurora drawer.
int size = 520;
int sourceArea = 3;
int size = 455;
FluidFieldManager.AdjustSizeRelativeToGraphicsQuality(ref size);
float scale = MathHelper.Max(Main.screenWidth, Main.screenHeight) / size;
if (ProfanedMoonlightAuroraDrawer is null || ProfanedMoonlightAuroraDrawer.Size != size)
ProfanedMoonlightAuroraDrawer = FluidFieldManager.CreateField(size, scale, 0.1f, 50f, 0.992f);
int sourceArea = (int)Math.Ceiling(6f / ProfanedMoonlightAuroraDrawer.Scale) + 1;
ProfanedMoonlightAuroraDrawer.ShouldUpdate = true;
ProfanedMoonlightAuroraDrawer.UpdateAction = () =>
{
int auroraCount = totalMoonlightDyes / 2 + 3;
int auroraCount = totalMoonlightDyes / 2 + 4;
for (int i = 0; i < auroraCount; i++)
{
float auroraPower = MathHelper.Clamp(totalMoonlightDyes / 3f, 0f, 1f);
@@ -5880,7 +5882,7 @@ namespace CalamityMod.CalPlayer
Vector2 auroraVelocity = (offsetAngle / 3f + Main.GlobalTimeWrappedHourly * 0.32f).ToRotationVector2();
auroraVelocity.Y = -Math.Abs(auroraVelocity.Y);
auroraVelocity = (auroraVelocity * new Vector2(0.15f, 1f) - Vector2.UnitX * Player.velocity.X / 9f).SafeNormalize(Vector2.UnitY) * 0.04f;
auroraVelocity = (auroraVelocity * new Vector2(0.15f, 1f) - Vector2.UnitX * Player.velocity.X / 9f).SafeNormalize(Vector2.UnitY) * 0.03f;
Vector2 drawPosition = Main.LocalPlayer.Center - Main.screenPosition;
Vector2 auroraSpawnPosition = drawPosition - Vector2.UnitY * 15f;
+3 -5
View File
@@ -144,11 +144,9 @@ float4 InitializeDivergence(float4 sampleColor : TEXCOORD, float2 coords : TEXCO
float4 DrawField(float4 sampleColor : TEXCOORD, float2 coords : TEXCOORD0) : COLOR0
{
float density = tex2D(nextStates, coords).r;
if (density < 0.05)
return 0;
return float4(tex2D(colorField, coords).rgb, 1) * density;
float density = pow(tex2D(nextStates, coords).r, 1.84);
float3 color = tex2D(colorField, coords).rgb;
return float4(color, 1) * density;
}
technique Technique1
Binary file not shown.
+14
View File
@@ -15,6 +15,20 @@ namespace CalamityMod.FluidSimulation
return field;
}
public static void AdjustSizeRelativeToGraphicsQuality(ref int size, int min = 325, int max = 725)
{
float graphicsQuality = MathHelper.Clamp(Main.gfxQuality, 0f, 1f);
// Use a quality of 0.5 for quality if it automatically updates. This is done to prevent having small changes reset the size and
// require the creation of a new field altogether.
if (Main.qaStyle == 0)
graphicsQuality = 0.5f;
int lowerBound = (int)MathHelper.Lerp(size, min, 1f - graphicsQuality);
int upperBound = (int)MathHelper.Lerp(size, max, graphicsQuality);
size = (upperBound + lowerBound) / 2;
}
// Update logic SHOULD NOT be called manually in external parts.
// A should update and update action field exist to allow for modularity with that.
// The reason you should not update manually in arbitrary parts of code is because the update loop
+5 -4
View File
@@ -462,7 +462,9 @@ namespace CalamityMod.ILEditing
// If the blazing mouse is actually going to do damage, draw an indicator aura.
if (Main.LocalPlayer.Calamity().blazingCursorDamage && !Main.mapFullscreen)
{
int size = 375;
int size = 450;
FluidFieldManager.AdjustSizeRelativeToGraphicsQuality(ref size);
float scale = MathHelper.Max(Main.screenWidth, Main.screenHeight) / size;
ref FluidField calamityFireDrawer = ref Main.LocalPlayer.Calamity().CalamityFireDrawer;
ref Vector2 firePosition = ref Main.LocalPlayer.Calamity().FireDrawerPosition;
@@ -474,6 +476,8 @@ namespace CalamityMod.ILEditing
int x = (int)((drawPosition.X - firePosition.X) / calamityFireDrawer.Scale);
int y = (int)((drawPosition.Y - firePosition.Y) / calamityFireDrawer.Scale);
int horizontalArea = (int)Math.Ceiling(5f / calamityFireDrawer.Scale);
int verticalArea = (int)Math.Ceiling(5f / calamityFireDrawer.Scale);
calamityFireDrawer.ShouldUpdate = true;
calamityFireDrawer.UpdateAction = () =>
@@ -484,9 +488,6 @@ namespace CalamityMod.ILEditing
if (Main.LocalPlayer.hasRainbowCursor)
color = Color.Lerp(color, Main.hslToRgb(Main.GlobalTimeWrappedHourly * 0.97f % 1f, 1f, 0.6f), 0.75f);
int horizontalArea = 2;
int verticalArea = 2;
for (int i = -horizontalArea; i <= horizontalArea; i++)
{
float offsetAngle = (float)Math.Sin(Main.GlobalTimeWrappedHourly * 6.7f) * 0.99f;