Add normal maps - #2904
Merged
Merged
Conversation
space_tug and space_cruiser_4 are not updated, because we'll need to create normal maps from scratch for them. Split msgamedev.pack into msgamedev-1.pack and msgamedev-2.pack because the added textures push the combined pack past GitHub's 100MB file limit. License.txt names both files.
Mesh loader derived tangent from UV parameterisation but discarded the determinant sign. The shader assumed every island was right-handed. Models that mirror their UVs across the hull centreline (most of the freighters/destroyers) rendered one half with an inverted bitangent, producing a hard seam with two sides lit from opposite directions. We store handedness in tangent.w and apply it when rebuilding the bitangent. The 1/determinant scale is dropped since the shader normalizes the basis, which also removes a possible division by zero
Every model in model_data.lua that sets a normal map also sets specular, so no shipped asset currently leaves the active unit at 3.
The source art is no longer in this repo, and this script cannot rebuild the bundles that currently ship in packs/.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Add normal maps
Note
this builds on #2603, which laid most of the work out already.
Wires normal mapping through the mesh pipeline, ships normal maps for the
models in the resource packs, and fixes the tangent basis so mirrored UV
islands are lit correctly.
Changes
Tangent basis (
src/mesh.h,src/mesh.cpp,resources/shaders/objectShader.shader)The mesh loader derived a tangent from the UV parameterisation but discarded
the sign of the determinant, and the shader assumed every UV island was
right-handed. Models that mirror their UVs across the hull centreline (most of
the freighters and destroyers) rendered one half with an inverted bitangent,
producing a hard seam with the two sides lit from opposite directions.
MeshVertex::tangentbecomes avec4, with the handedness inw, and theshader rebuilds the bitangent as
cross(n, t.xyz) * t.w. The1/determinantscale is dropped, since the shader normalizes the basis, which also removes a
division by zero on triangles with degenerate UVs.
Replication (
src/multiplayer/rendering.cpp)normal_texture.namewas never replicated, so clients never received the map.Texture unit reset (
src/systems/rendering.cpp)The active texture unit is now also reset when a mesh has a normal map but no
specular or illumination map. Every model in
model_data.luathat sets anormal map also sets a specular map, so no shipped asset currently hits this,
but the loader no longer depends on that.
Model viewer (
src/screenComponents/rotatingModelView.cpp)Adds the normal map toggle to the debug view, so the map's contribution can be
judged against the flat-shaded model.
Assets (
packs/,scripts/model_data.lua)46
setNormalMap()entries.space_tugandspace_cruiser_4are not updated;they need normal maps authored from scratch.
Note for the release: stale
msgamedev.packmsgamedev.packis split intomsgamedev-1.packandmsgamedev-2.pack, becausethe added textures push the combined pack past GitHub's 100 MB file limit.
The rename means an in-place upgrade that unpacks over an existing install
may accidentally load the old
msgamedev.pack, missing out on the new texturedata.
If that is a concern, the split can keep the name
msgamedev.packfor onehalf and add only
msgamedev-2.pack, so the old file is always overwritten.Happy to change it either way.