Repository navigation
Share the texture environment colour between stages, as the DirectX driver does - #16
Merged
Merged
Conversation
…river does - TexEnv writes the colour to every texture unit, since DirectX has one texture factor for all stages - The game sets it right after selecting stage 1 for stage 0's combiner to read, which left the building shadows unfaded at night - Unchanged colours are skipped
Contributor
Author
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.
Building shadows turn purple at night.
TexEnvwith a colour setsGL_TEXTURE_ENV_COLORon the active unit only, but OpenGL keeps that colour per unit, while DirectX has a single one for every stage.What the game and the DirectX driver do, from SimCity 4 version 641:
TexEnvwith a colour (0x8830a0) setsD3DRS_TEXTUREFACTORand ignores the stage.TexEnv(0, 1, colour)without selecting a stage. That happens right after 0x7d4340 selected stage 1, but the colour is meant for stage 0's combiner, which readsGL_CONSTANT(the texture factor) for the alpha.So on SCGL, stage 1 gets the faded colour and stage 0 keeps an older one, and the shadows come out with the wrong colour and strength.
Changes:
TexEnvwrites the colour to every texture unit, then makes the previously active unit active again.scvk had the same bug (blue night shadows) and this fixed it there.
Tested in game on version 641 with an NVIDIA RTX 3070, against upstream main: night shadows are grey instead of purple.