Generate flat normals in shader #609
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR adds flat normal generation in the pixel shader for tilesets that do not have normals. Before this change, either smooth per-vertex normals, or flat face normals would be generated on the CPU. The latter required duplicating vertices per face which requires a much larger vertex buffer.


This behavior will be enabled by default when rendering a lit tileset (or unlit if the
Ignore Khr Unlit
option is enabled) if normals are not included in the tileset.Issue number or link
Author checklist
CHANGES.md
with a short summary of my change (for user-facing changes).Remaining Tasks
Testing plan
Load a tileset that does not have normals. Disable
Generate Smooth Normals
and enable theIgnore KHR Unlit
options. Note that the Normal material overlay contains no normals, but lighting is correct. One may also connect the normal generation output to the Base Color node on the