Skip to content

Commit 953762f

Browse files
Merge branch 'master' into repeat-action-base
2 parents 5dca298 + 43565d6 commit 953762f

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

engine/Sandbox.Engine/Systems/Render/Shadows/ShadowMapper.Directional.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -316,11 +316,9 @@ internal unsafe void FindOrCreateDirectionalShadowMaps( SceneLight light, IScene
316316
// Render shadow view
317317
CSceneSystem.AddShadowView( CascadeNames[i], view, frustum, new( 0, 0, shadowmapSize, shadowmapSize ), rt.DepthTarget.native, 0, SceneObjectFlags.None, excludeFlags, ShadowDepthBias, ShadowSlopeScale, i > 0 ? exclusionFrustum : default );
318318

319-
// Cache a sphere-sized exclusion frustum for the next cascade.
320-
var exclusionForward = cascade.Angles.ToRotation().Forward;
321-
var exclusionOrigin = cascade.SphereCenter - exclusionForward * cascade.SphereRadius;
322-
var sphereDiagonal = cascade.SphereRadius * MathF.PI * 0.5f; // Box inside of sphere
323-
exclusionFrustum.InitOrthoCamera( exclusionOrigin, cascade.Angles, 0f, sphereDiagonal, sphereDiagonal, sphereDiagonal );
319+
// Cache an exclusion frustum sized to the largest square inscribed in the cascade's bounding sphere.
320+
var size = cascade.SphereRadius / MathF.Sqrt( 2.0f );
321+
exclusionFrustum.InitOrthoCamera( cascade.SphereCenter, cascade.Angles, -size * 0.5f, size * 0.5f, size, size );
324322

325323
// Set our gpu data
326324
Matrix texScaleBiasMat = GetScaleBiasMatrix( shadowmapSize, 0 );

engine/Sandbox.Engine/Utility/BlobData.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ public abstract class BlobData
1111
/// </summary>
1212
public virtual int Version => 1;
1313

14+
internal Guid BlobId;
15+
1416
/// <summary>
1517
/// Serialize this object to binary format.
1618
/// </summary>

engine/Sandbox.Engine/Utility/BlobDataSerializer.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,14 @@ internal static Guid RegisterBlob( BlobData blob )
3434
return Guid.Empty;
3535

3636
var blobs = _current.Blobs;
37-
var guid = Guid.NewGuid();
37+
38+
var guid = blob.BlobId;
39+
if ( guid == Guid.Empty )
40+
{
41+
guid = Guid.NewGuid();
42+
blob.BlobId = guid;
43+
}
44+
3845
blobs[guid] = blob;
3946
return guid;
4047
}
@@ -51,6 +58,8 @@ internal static BlobData ReadBlob( Guid guid, Type expectedType )
5158
if ( Activator.CreateInstance( expectedType ) is not BlobData instance )
5259
return null;
5360

61+
instance.BlobId = guid;
62+
5463
var stream = ByteStream.CreateReader( blobData );
5564
try
5665
{

0 commit comments

Comments
 (0)