Repository navigation
Configurable glow map intensity per lighting profile and per texture - #7865
dustinspace217 wants to merge 5 commits into
Conversation
|
This is fundamentally wrong and mixes concerns in a bad manner. Lighting profiles are supposed to hold global settings that apply to an entire mission. They should not hold data that, as per the intent expressed in this and the other PRs linked to this, is set on a per-model basis. The proper way to communicate this data is through the material system, not lighting profiles. |
|
The ltp should hold a global default that is then overridden by the per-model/-texture set data |
|
To clarify the flow: the per-texture values do go through the material system. |
|
My apologies, I did not read the flow correctly. I retract my objection. |
The char* version only checked the stored length with an Assertion, so in release builds a string longer than the buffer was read past its end, and a negative length wrote before it. It now reads at most buffer_size - 1 characters, skips the rest so the next read stays aligned, always terminates the buffer, and logs when characters are dropped. The SCP_string version clamps a negative or past-the-end length to what the file still holds, so a corrupt length can't cause a huge allocation. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ture
The shader multiplied every glow map by two fixed constants: 1.5 always, and
3.0 more with post-processing on. They are now per-draw shader values with the
same defaults, so nothing changes unless a mod sets them.
- Lighting profiles take $Glow Map Intensity: (default 1.5) and
$Glow Map HDR Multiplier:, which defaults to twice the intensity, so the old
1.5 x 3.0 is unchanged and raising the intensity raises both.
- A texture can override them in a plain-text file named after it and placed
next to it, for example shockwave3d.mat beside the shockwave3d texture:
$Glow Map Intensity: 2.5
$Glow Map HDR Multiplier: 6
The .mat is read once when the texture loads and kept with the bitmap, so it
follows texture replacement, covers every frame of an EFF, ANI or APNG, and
applies wherever the texture is drawn. Decals use their diffuse texture's
.mat, or their glow texture's when they have no diffuse.
- Files must be plain ASCII; ';' starts a comment. Unknown entries, bad
numbers and non-text files are ignored with a warning. Values are capped at
100 so glow stays within the 16-bit float emissive buffer; lighting profile
values get the same checks.
- .mat is added to the file types indexed in data/maps and data/effects, so
builds without this change never see the files. A .mat follows the usual mod
priority, like any other file.
The old shader constants stay in lighting.sdr for mods that ship their own
shaders referencing them.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
94d01af to
fd5b5e4
Compare
|
The revision is done. Per-texture values now come from a |
FSO treats text files as UTF-8 in Unicode mode, so a .mat file with a non-ASCII comment was being ignored. Valid UTF-8 is now read; other encodings, and files with control bytes such as UTF-16 without a byte order mark, still get a warning and are ignored. Release builds now also check that each rejected file returns no material. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Mac clang-tidy step reads the PR diff as UTF-8 and fails on their bytes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Small follow-up: The second commit marks the two deliberately non-UTF-8 test files as binary in |
mprintf is compiled out of release builds, so the block never ran. Co-Authored-By: Claude Mythos 5.1 <noreply@anthropic.com>
What?
Glow maps get two settings instead of the fixed values in the model shader (intensity 1.5, HDR multiplier 3.0):
$Glow Map Intensity:(default 1.5) and$Glow Map HDR Multiplier:(default twice the intensity, so 3.0).shockwave3d.matbeside MediaVPs'shockwave3dtexture for the 3D shockwave..mat, or their glow texture's if they have no diffuse, and otherwise the profile's values.With none of these set, rendering is unchanged.
Why?
Goober asked for this for the Scroll of Atankharzim. Some glow maps, like a shockwave's, need to be brighter or dimmer than everything else, and right now the only way to change glow strength is to edit the shaders.
How?
glowIntensityandglowHdrMultiplierin the model block, and two fields that were padding in the decal block).static_asserts pin the C++ layouts..matis read once, when its texture loads, and kept with the bitmap. So it follows texture replacement, covers every frame of an EFF, ANI or APNG, and applies wherever the texture is drawn. Edits need a restart..matfiles are UTF-8 (a byte order mark is fine);;starts a comment. Unknown entries, bad numbers and files in other encodings get a warning and are ignored. A Latin-1.matis ignored rather than converted as Unicode-mode tables are. Values are capped at 100 so glow stays within the 16-bit emissive buffer, and lighting profiles get the same checks..matjoins the file types indexed indata/mapsanddata/effects, so older builds never see the files. A.matfollows the usual mod priority: a mod can add one for a MediaVPs texture, and a mod that replaces a texture but wants the default glow can ship an empty.mat..matbelongs to the base texture: replacing only a glow map keeps the base texture's.mat.lighting.sdrfor mods that ship their own copies of the model shaders. A mod that overridesmain-v/g/f.sdrhas to update all three, as with any change to that block.Testing?
.matfiles: both keys, comments, UTF-8 comments, tabs, CRLF, a UTF-8 BOM, case and extension in the name,data/mapsanddata/effects, missing files, other encodings, control bytes and truncated UTF-8, bad, negative, nan and too-large values, unknown entries, and that a texture, an EFF and an APNG all carry their.mat. All pass in Release and Debug, shuffled and repeated. I also broke each rule on purpose and checked that a test failed..mat, screenshots match the nightly apart from 5 pixels on one hull that come from the build settings, not this change. A.matwith intensity 0 on the Hatshepsut's textures removes only that ship's glow, and the nightly ignores the files. A replacement texture uses its own.mat. The lab's hidden-diffuse view still applies the.mat, and one texture's.matdoesn't change the next texture drawn..maton a decal's texture brightens only that decal.Anything Else?
Following the discussion on Discord, the per-texture values now live in a
.matfile next to the texture instead of in the POF, so this no longer depends on #7864. The branch still carries #7863's commit until that merges; nothing here depends on it now.While testing I found that decals don't draw at all under Vulkan, including on current master (#7866). The review also turned up two existing overflows in the engine's text readers, filed as #7869 and #7870. Both are separate from this PR.
I used Claude Code to write the change and tests and to run the checks; I reviewed the code and this text.