(3ffde5103) Disabled alpha premultiplication on a bunch of non-transparent textures (-> minor loading time reduction)

This commit is contained in:
Joonas Rikkonen
2019-04-03 16:24:48 +03:00
parent fd0e394827
commit 4685121eee
6 changed files with 36 additions and 9 deletions
@@ -701,6 +701,25 @@ namespace Barotrauma
} }
}; };
//spacing
new GUIFrame(new RectTransform(new Vector2(1.0f, 0.02f), generalLayoutGroup.RectTransform), style: null);
new GUIButton(new RectTransform(new Vector2(0.4f, 1.0f), buttonArea.RectTransform, Anchor.BottomLeft),
TextManager.Get("Cancel"), style: "GUIButtonLarge")
{
IgnoreLayoutGroups = true,
OnClicked = (x, y) =>
{
if (UnsavedSettings)
{
LoadPlayerConfig();
}
if (Screen.Selected == GameMain.MainMenuScreen) GameMain.MainMenuScreen.ReturnToMainMenu(null, null);
GUI.SettingsMenuOpen = false;
return true;
}
};
applyButton = new GUIButton(new RectTransform(new Vector2(0.4f, 1.0f), buttonArea.RectTransform, Anchor.BottomRight), applyButton = new GUIButton(new RectTransform(new Vector2(0.4f, 1.0f), buttonArea.RectTransform, Anchor.BottomRight),
TextManager.Get("ApplySettingsButton"), style: "GUIButtonLarge") TextManager.Get("ApplySettingsButton"), style: "GUIButtonLarge")
{ {
@@ -78,9 +78,8 @@ namespace Barotrauma.Lights
AmbientLight = new Color(20, 20, 20, 255); AmbientLight = new Color(20, 20, 20, 255);
visionCircle = Sprite.LoadTexture("Content/Lights/visioncircle.png"); visionCircle = Sprite.LoadTexture("Content/Lights/visioncircle.png", preMultiplyAlpha: false);
highlightRaster = Sprite.LoadTexture("Content/UI/HighlightRaster.png", preMultiplyAlpha: false);
highlightRaster = Sprite.LoadTexture("Content/UI/HighlightRaster.png");
CreateRenderTargets(graphics); CreateRenderTargets(graphics);
GameMain.Instance.OnResolutionChanged += () => GameMain.Instance.OnResolutionChanged += () =>
@@ -292,6 +291,11 @@ namespace Barotrauma.Lights
spriteBatch.Draw(HighlightMap, Vector2.Zero, Color.White); spriteBatch.Draw(HighlightMap, Vector2.Zero, Color.White);
spriteBatch.End(); spriteBatch.End();
} }
GameMain.ParticleManager.Draw(spriteBatch, true, null, Particles.ParticleBlendState.Additive);
spriteBatch.End();
//draw a black rectangle on hulls to hide background lights behind subs
//---------------------------------------------------------------------------------------------------
//draw characters to obstruct the highlighted items/characters and light sprites //draw characters to obstruct the highlighted items/characters and light sprites
//--------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------
@@ -91,7 +91,7 @@ namespace Barotrauma.Lights
} }
break; break;
case "lighttexture": case "lighttexture":
OverrideLightTexture = new Sprite(subElement); OverrideLightTexture = new Sprite(subElement, preMultiplyAlpha: false);
break; break;
} }
} }
@@ -211,7 +211,7 @@ namespace Barotrauma.Lights
{ {
if (lightTexture == null) if (lightTexture == null)
{ {
lightTexture = TextureLoader.FromFile("Content/Lights/pointlight_bright.png"); lightTexture = TextureLoader.FromFile("Content/Lights/pointlight_bright.png", preMultiplyAlpha: false);
} }
return lightTexture; return lightTexture;
@@ -47,12 +47,12 @@ namespace Barotrauma
postProcessEffect = content.Load<Effect>("Effects/postprocess"); postProcessEffect = content.Load<Effect>("Effects/postprocess");
#endif #endif
damageStencil = TextureLoader.FromFile("Content/Map/walldamage.png"); damageStencil = TextureLoader.FromFile("Content/Map/walldamage.png", preMultiplyAlpha: false);
damageEffect.Parameters["xStencil"].SetValue(damageStencil); damageEffect.Parameters["xStencil"].SetValue(damageStencil);
damageEffect.Parameters["aMultiplier"].SetValue(50.0f); damageEffect.Parameters["aMultiplier"].SetValue(50.0f);
damageEffect.Parameters["cMultiplier"].SetValue(200.0f); damageEffect.Parameters["cMultiplier"].SetValue(200.0f);
distortTexture = TextureLoader.FromFile("Content/Effects/distortnormals.png"); distortTexture = TextureLoader.FromFile("Content/Effects/distortnormals.png", preMultiplyAlpha: false);
postProcessEffect.Parameters["xDistortTexture"].SetValue(distortTexture); postProcessEffect.Parameters["xDistortTexture"].SetValue(distortTexture);
} }
@@ -26,6 +26,10 @@ namespace Barotrauma.Items.Components
private float blinkTimer; private float blinkTimer;
private bool itemLoaded;
private float blinkTimer;
public PhysicsBody ParentBody; public PhysicsBody ParentBody;
[Editable(MinValueFloat = 0.0f, MaxValueFloat = 2048.0f), Serialize(100.0f, true)] [Editable(MinValueFloat = 0.0f, MaxValueFloat = 2048.0f), Serialize(100.0f, true)]
@@ -99,7 +99,7 @@ namespace Barotrauma
partial void LoadTexture(ref Vector4 sourceVector, ref bool shouldReturn, bool premultiplyAlpha = true); partial void LoadTexture(ref Vector4 sourceVector, ref bool shouldReturn, bool premultiplyAlpha = true);
partial void CalculateSourceRect(); partial void CalculateSourceRect();
public Sprite(XElement element, string path = "", string file = "") public Sprite(XElement element, string path = "", string file = "", bool? preMultiplyAlpha = null)
{ {
SourceElement = element; SourceElement = element;
if (file == "") if (file == "")
@@ -124,7 +124,7 @@ namespace Barotrauma
Name = SourceElement.GetAttributeString("name", null); Name = SourceElement.GetAttributeString("name", null);
Vector4 sourceVector = SourceElement.GetAttributeVector4("sourcerect", Vector4.Zero); Vector4 sourceVector = SourceElement.GetAttributeVector4("sourcerect", Vector4.Zero);
bool shouldReturn = false; bool shouldReturn = false;
LoadTexture(ref sourceVector, ref shouldReturn, SourceElement.GetAttributeBool("premultiplyalpha", true)); LoadTexture(ref sourceVector, ref shouldReturn, preMultiplyAlpha ?? SourceElement.GetAttributeBool("premultiplyalpha", true));
if (shouldReturn) return; if (shouldReturn) return;
sourceRect = new Rectangle((int)sourceVector.X, (int)sourceVector.Y, (int)sourceVector.Z, (int)sourceVector.W); sourceRect = new Rectangle((int)sourceVector.X, (int)sourceVector.Y, (int)sourceVector.Z, (int)sourceVector.W);
size = SourceElement.GetAttributeVector2("size", Vector2.One); size = SourceElement.GetAttributeVector2("size", Vector2.One);