Repository navigation
Model uniforms: let a -reflect map win over a -shine map again - #8065
Conversation
Both maps are loaded when a texture has them. The OpenGL and Vulkan binds put the spec-gloss (-reflect) map in the specular slot, but convert_model_material() then let the legacy -shine map overwrite sSpecmapIndex and clear gammaSpec and alphaGloss. The bound -reflect texture was therefore shaded as a legacy shine map: its alpha was not read as gloss, and the spec-gloss path (minimum specular, full fresnel) was skipped. The array layer also came from the -shine map, so an animated -reflect map could sample the wrong frame. The two checks were an if/else until scp-fs2open#5055 split them into two ifs. Restore the else.
dustinspace217
left a comment
There was a problem hiding this comment.
Tested with this PR applied onto current master (f0d45f6), against master. Debug builds, retail FS2 data plus MediaVPs 5.0.3, Linux.
Retail data has no -shine or -reflect maps, and in MediaVPs 5.0.3 only four textures have both: rak_01 to rak_03 and goldglass-trans. So I looked at the Rakshasa in SM1-04 (Behemoth) from 600 m, on OpenGL and on Vulkan. With this PR its hull shows the glossy highlights of the spec-gloss path, mostly along the bow; on master the same hull is flat. The two renderers agree.
From reading: when a texture has both maps, OpenGL and Vulkan both bind the -reflect map in the specular slot, so with the else back the uniforms describe the texture that is actually bound.
Optional: the binds and convert_model_material() each pick the specular map on their own, which is how they drifted apart. A small shared helper would keep them in step.
The renderer binds and uniform conversion selected the specular map independently, which let their precedence drift apart. Share the choice and encoding flag through material::get_specular_map(), preserving -reflect precedence and the raw -shine fallback at every render site. Pin selection and encoding in the material test, including reflect handle 0, and document the fallback beside the shared accessor.
|
Thanks for testing it with the MediaVPs. Added the helper in 2c67d87: |
When a texture has both a
-reflectand a legacy-shinemap, both are loaded, and the OpenGL and Vulkan binds put the-reflect(spec-gloss) map in the specular slot.convert_model_material()then lets the-shinemap overwritesSpecmapIndexand cleargammaSpecandalphaGloss. So the bound-reflecttexture is shaded as a legacy shine map: its alpha isn't read as gloss, and the spec-gloss path inmain-f.sdr(minimum specular, full fresnel) is skipped. The array layer also comes from the-shinemap, so an animated-reflectmap can sample the wrong frame.The two checks were an if/else until #5055 split them into two ifs. This PR restores the
else, so the uniforms follow the texture that is actually bound.Only textures with both maps change; they now shade as their
-reflectmap intends. A LuaSpecularMapor$Texture Replacethat supplies only-shineon a model with-reflectwas already not bound, and now no longer changes the shading flags either.Testing
OptionsManagerOverride.ShadowRenderMethodDefaultFollowsTheGlobal, which is unrelated. No unit test coversconvert_model_material().-shineRGB 60,-reflectRGBA 200 with alpha 235.-reflectonly: pixel-identical.-reflectonly. Master differs (about 80k changed pixels) and shows legacy shine highlights.