mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-15 03:30:53 +01:00
Implements blend modes (#3740)
Closes https://github.com/space-wizards/RobustToolbox/issues/3739
This commit is contained in:
@@ -243,6 +243,8 @@ namespace Robust.Client.Graphics.Clyde
|
||||
|
||||
program.SetUniformMaybe(UniITexturePixelSize, Vector2.One / loadedTexture.Size);
|
||||
|
||||
SetBlendFunc(loaded.BlendMode);
|
||||
|
||||
var primitiveType = MapPrimitiveType(command.PrimitiveType);
|
||||
if (command.Indexed)
|
||||
{
|
||||
@@ -256,6 +258,9 @@ namespace Robust.Client.Graphics.Clyde
|
||||
CheckGlError();
|
||||
}
|
||||
|
||||
ResetBlendFunc();
|
||||
GL.BlendEquation(BlendEquationMode.FuncAdd);
|
||||
|
||||
_debugStats.LastGLDrawCalls += 1;
|
||||
}
|
||||
|
||||
@@ -869,6 +874,23 @@ namespace Robust.Client.Graphics.Clyde
|
||||
GL.Viewport(0, 0, _mainWindow!.FramebufferSize.X, _mainWindow!.FramebufferSize.Y);
|
||||
}
|
||||
|
||||
private void SetBlendFunc(ShaderBlendMode blend)
|
||||
{
|
||||
switch (blend)
|
||||
{
|
||||
case ShaderBlendMode.Add:
|
||||
GL.BlendFunc(BlendingFactor.SrcAlpha, BlendingFactor.DstAlpha);
|
||||
break;
|
||||
case ShaderBlendMode.Subtract:
|
||||
GL.BlendFuncSeparate(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.DstAlpha, BlendingFactorSrc.Zero, BlendingFactorDest.DstAlpha);
|
||||
GL.BlendEquation(BlendEquationMode.FuncReverseSubtract);
|
||||
break;
|
||||
case ShaderBlendMode.Multiply:
|
||||
GL.BlendFunc(BlendingFactor.DstColor, BlendingFactor.OneMinusSrcAlpha);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void ResetBlendFunc()
|
||||
{
|
||||
GL.BlendFuncSeparate(
|
||||
|
||||
@@ -90,7 +90,7 @@ namespace Robust.Client.Graphics
|
||||
}
|
||||
else if (word.Word == "blend_mode")
|
||||
{
|
||||
if (lightMode != null)
|
||||
if (blendMode != null)
|
||||
{
|
||||
throw new ShaderParseException("Already specified 'blend_mode' before!");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user