Skip to content

NUKE surface sorting by fog#1610

Merged
VReaperV merged 3 commits intoDaemonEngine:masterfrom
VReaperV:nuke-fog-sort
Mar 23, 2025
Merged

NUKE surface sorting by fog#1610
VReaperV merged 3 commits intoDaemonEngine:masterfrom
VReaperV:nuke-fog-sort

Conversation

@VReaperV
Copy link
Copy Markdown
Contributor

@VReaperV VReaperV commented Mar 18, 2025

#1408 had removed the hacky way of drawing fog surfaces and made them into actual stages. This change removes the sorting by fog index since it now has no positive effect (and potentially has a negative one, preventing surfaces from being merged). The fognum bits are redistributed towards drawsurf indexes and entity count.

This will also allow increasing MAX_REF_ENTITIES.

@VReaperV VReaperV added T-Improvement Improvement for an existing feature A-Renderer T-Cleanup labels Mar 18, 2025
@slipher
Copy link
Copy Markdown
Member

slipher commented Mar 19, 2025

This change removes the sorting by fog index since it now has no positive effect (and potentially has a negative one, preventing surfaces from being merged).

Can you really merge surfaces of different fogs though? It seems like they have some parameters which could be different such as fog->color and fog->tcScale.

@VReaperV
Copy link
Copy Markdown
Contributor Author

Can you really merge surfaces of different fogs though? It seems like they have some parameters which could be different such as fog->color and fog->tcScale.

You can't merge the actual fog surfaces, but you can merge the "main" surfaces that emitted them. Although I'll need to make the main surfaces not use the actual fognum for that to work, otherwise the backend still won't merge them.

@slipher
Copy link
Copy Markdown
Member

slipher commented Mar 22, 2025

Right, now I get it. You want to sort by fog num for fog surfaces, but not surfaces in the fog. LGTM

To get fog surfaces sorted/merged properly, maybe it would be easiest to just generate a shader_t for each fog so that we could take advantage of existing machinery for sorting.

@VReaperV
Copy link
Copy Markdown
Contributor Author

That is correct, yeah.

I've thought of generating the shader_ts too, that should work.

DaemonEngine#1408 had removed the hacky way of drawing fog surfaces and made them into actual stages. This change removes the sorting by fog index since it now has no positive effect (and potentially has a negative one, preventing surfaces from being merged). The fognum bits are redistributed towards drawsurf indexes and entity count.
These surfaces themselves won't be used to render fog, instead that is done by adding surfaces referencing the same geometry, but using one of `tr.fogEqualShader` or `tr.fogLEShader`.
@VReaperV
Copy link
Copy Markdown
Contributor Author

I've added two more commits that set fogNum on main surfaces to 0 so they can be merged, and fix a comment on drawSurf sort.

@VReaperV VReaperV merged commit 18a9745 into DaemonEngine:master Mar 23, 2025
9 checks passed
@VReaperV VReaperV deleted the nuke-fog-sort branch March 23, 2025 12:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Renderer T-Cleanup T-Improvement Improvement for an existing feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants