Skip to content

Conversation

@xezon
Copy link

@xezon xezon commented Oct 12, 2025

This change doubles the 3D shadow buffers. Shadows are not cheap.

It also rearranges and comments the constants for ease of read.

Original Investigation

The original investigation was done in TheAssemblyArmada/Thyme#604

We know that 512 + 1 Scorpion Tanks in the scene will deplete the shadow memory pools.

I tested against 1024 Scorpion Tanks in the scene.

Double MAX_NUMBER_SLOTS only with 1024 Scorpion Tanks

        MAX_NUMBER_SLOTS = 4096 * 2
        MAX_VERTEX_BUFFERS_CREATED = 32
        MAX_INDEX_BUFFERS_CREATED = 32
        MAX_VB_SIZES = 128
        MAX_IB_SIZES = 128

results in

-		g_theW3DBufferManager
		m_numEmptyVertexSlotsAllocated	4318	int
		m_numEmptyVertexBuffersAllocated	32	int
		m_numEmptyIndexSlotsAllocated	4323	int
		m_numEmptyIndexBuffersAllocated	22	int

m_numEmptyVertexBuffersAllocated now caps out at 32 and it cannot draw shadows for all meshes. m_numEmptyVertexSlotsAllocated should cap out at 8192.

Double MAX_NUMBER_SLOTS and BUFFERS_CREATED with 1024 Scorpion Tanks

        MAX_NUMBER_SLOTS = 4096 * 2
        MAX_VERTEX_BUFFERS_CREATED = 32 * 2
        MAX_INDEX_BUFFERS_CREATED = 32 * 2
        MAX_VB_SIZES = 128
        MAX_IB_SIZES = 128

results in

-		g_theW3DBufferManager
		m_numEmptyVertexSlotsAllocated	8192	int
		m_numEmptyVertexBuffersAllocated	62	int
		m_numEmptyIndexSlotsAllocated	8192	int
		m_numEmptyIndexBuffersAllocated	41	int

m_numEmptyVertexSlotsAllocated now caps out at 8192 and all meshes cast shadows in the scene

shot_20240211_095540_1

Conclusion

Scaling the following 3 limits uniformly is the correct strategy.

MAX_NUMBER_SLOTS
MAX_VERTEX_BUFFERS_CREATED
MAX_INDEX_BUFFERS_CREATED

TODO

  • Replicate in Generals

@xezon xezon added Enhancement Is new feature or request Minor Severity: Minor < Major < Critical < Blocker Gen Relates to Generals ZH Relates to Zero Hour Rendering Is Rendering related labels Oct 12, 2025
Copy link

@Skyaero42 Skyaero42 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The one million dollar question: why double and not triple? I can fit more scorpions on that screen.

@xezon xezon force-pushed the xezon/tweak-shadows-limit branch from 2bb5777 to a86cc65 Compare October 15, 2025 20:23
@xezon
Copy link
Author

xezon commented Oct 15, 2025

Replicated in Generals without conflicts

@xezon xezon merged commit eb7093e into TheSuperHackers:main Oct 15, 2025
18 checks passed
@xezon xezon deleted the xezon/tweak-shadows-limit branch October 15, 2025 20:56
fbraz3 pushed a commit to fbraz3/GeneralsX that referenced this pull request Nov 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Enhancement Is new feature or request Gen Relates to Generals Minor Severity: Minor < Major < Critical < Blocker Rendering Is Rendering related ZH Relates to Zero Hour

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants