Repository navigation
Keep texture filter and wrap per stage, as the DirectX driver does - #14
Merged
Merged
Conversation
- TexParameter sets the value on the selected stage only, instead of one set of values shared by both stages - Each stage applies its own values to the texture it has bound, with its unit active - The active unit goes back to the one the game selected once a draw has applied the stages
Owner
|
Thanks, cheers |
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.
TexParameterkeeps one set of filter and wrap values for both stages, and the loop that should flag every stage for a refresh only flags stage 0 (textureUnits[0]instead oftextureUnits[i]). The refresh also callsglTexParameteriwithout making that stage's unit active, so stage 0's values can land on whatever stage 1 has bound.Fixing the index alone would make every value reach both stages, so stage 1's clamps would land on stage 0's textures. In scvk, my Vulkan driver, that model gave black patches on the terrain.
What the DirectX driver does, from SimCity 4 version 641:
TexParameter(0x884990) writes the value into the active stage's record (0x80 bytes per stage, filter and wrap at +0xc to +0x18).SetTexture(0x884810) never touches those fields, so filter and wrap belong to the stage, not to the texture.TexStageandTexParameterwhen the stage already holds the value. It relies on each stage keeping its own values.Changes:
TexParametersets the selected unit's.TexStage. A draw could leave another unit active before, andTexEnv,TexStageMatrixand the texture uploads inCreateTextureandLoadTextureLevelall act on the active unit.In scvk this model fixed building shadows repeating along streets (the shadow mask on stage 1 needs clamp) and black slabs on the cut-away terrain beside sloped lots.
OpenGL still keeps the values on the texture object, so one texture bound to both stages with different values at the same time gets the last stage's.
Tested in game on version 641 with an NVIDIA RTX 3070, against upstream main: building shadows along streets and cloud shadows look right.