mirror of
https://github.com/Facepunch/sbox-public.git
synced 2025-12-23 22:48:07 -05:00
Fixed opaque & non-opaque sprite sorting (#3660)
This commit is contained in:
@@ -231,6 +231,11 @@ public sealed class SceneSpriteSystem : GameObjectSystem<SceneSpriteSystem>
|
||||
flags |= InstanceGroupFlags.Additive;
|
||||
}
|
||||
|
||||
if ( component.Opaque )
|
||||
{
|
||||
flags |= InstanceGroupFlags.Opaque;
|
||||
}
|
||||
|
||||
RenderGroupKey renderGroupKey = new()
|
||||
{
|
||||
GroupFlags = flags,
|
||||
@@ -281,6 +286,7 @@ public sealed class SceneSpriteSystem : GameObjectSystem<SceneSpriteSystem>
|
||||
renderGroupObject.Flags.ExcludeGameLayer = (renderGroupKey.GroupFlags & InstanceGroupFlags.CastOnlyShadow) != 0;
|
||||
renderGroupObject.Sorted = (renderGroupKey.GroupFlags & InstanceGroupFlags.Transparent) != 0;
|
||||
renderGroupObject.Additive = (renderGroupKey.GroupFlags & InstanceGroupFlags.Additive) != 0;
|
||||
renderGroupObject.Opaque = (renderGroupKey.GroupFlags & InstanceGroupFlags.Opaque) != 0;
|
||||
renderGroupObject.Tags.SetFrom( new TagSet( renderGroupKey.Tags ) );
|
||||
renderGroupKey.RenderLayer.Apply( renderGroupObject );
|
||||
|
||||
@@ -362,6 +368,7 @@ public sealed class SceneSpriteSystem : GameObjectSystem<SceneSpriteSystem>
|
||||
CastShadow = 1 << 0,
|
||||
CastOnlyShadow = 1 << 1,
|
||||
Transparent = 1 << 2,
|
||||
Additive = 1 << 3
|
||||
Additive = 1 << 3,
|
||||
Opaque = 1 << 4
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ internal sealed class SpriteBatchSceneObject : SceneCustomObject
|
||||
public bool Sorted { get; set; } = false;
|
||||
public bool Filtered { get; set; } = false;
|
||||
public bool Additive { get; set; } = false;
|
||||
public bool Opaque { get; set; } = false;
|
||||
|
||||
internal Dictionary<Guid, SpriteRenderer> Components = new();
|
||||
|
||||
@@ -512,6 +513,7 @@ internal sealed class SpriteBatchSceneObject : SceneCustomObject
|
||||
Graphics.ResourceBarrierTransition( SpriteBufferOut, ResourceState.Common );
|
||||
|
||||
Graphics.Attributes.SetCombo( "D_BLEND", Additive ? 1 : 0 );
|
||||
Graphics.Attributes.SetCombo( "D_OPAQUE", Opaque ? 1 : 0 );
|
||||
|
||||
// Sort
|
||||
if ( Sorted )
|
||||
|
||||
@@ -232,14 +232,13 @@ PS
|
||||
RenderState( DepthWriteEnable, false );
|
||||
#else
|
||||
RenderState( BlendEnable, true );
|
||||
RenderState( DepthWriteEnable, S_MODE_DEPTH == 1 );
|
||||
RenderState( SrcBlend, SRC_ALPHA );
|
||||
RenderState( DstBlend, INV_SRC_ALPHA );
|
||||
RenderState( BlendOp, ADD );
|
||||
RenderState( SrcBlendAlpha, ONE );
|
||||
RenderState( DstBlendAlpha, INV_SRC_ALPHA );
|
||||
RenderState( DepthWriteEnable, D_OPAQUE || S_MODE_DEPTH == 1 );
|
||||
RenderState( AlphaToCoverageEnable, S_MODE_DEPTH == 1 );
|
||||
|
||||
#endif
|
||||
|
||||
RenderState( CullMode, NONE );
|
||||
@@ -290,6 +289,7 @@ PS
|
||||
int CurrentBufferSize < Attribute("SpriteCount"); >;
|
||||
|
||||
DynamicCombo( D_BLEND, 0..1, Sys( ALL ) );
|
||||
DynamicCombo( D_OPAQUE, 0..1, Sys( ALL ) );
|
||||
|
||||
float g_FogStrength < Attribute( "g_FogStrength" ); >;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user