Fix texture scroll, optimise texture matrix operations a bit #1538
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.
Fixes #1278.
The previous code assumed that a texture with a scroll textureMod would always wrap around when
scroll * backEnd.refdef.floatTime == floor( scroll * backEnd.refdef.floatTime )
. This is incorrect if the texture matrix had already been modified by another texMod, so the relevant values are no longer 1.0f and 0.0f. Fix this by usingscrollPeriod[0] / ( matrix[0] + matrix[4] )
andscrollPeriod[0] / ( matrix[0] + matrix[4] )
to get the actual time at which wrap-around forx
andy
will occur, and usefmodf( backEnd.refdef.floatTime, period )
to get the part that is equivalent to just usingbackEnd.refdef.floatTime
, but without the value getting continuously larger.Also NUKED some useless matrix computations from texMod scroll, and added some functions to only calculate the relevant part of a matrix for texture matrices.
This change can be observed on:
Map
tds
,r_forceRendererTime 49999
andr_forceRendererTime 50000
:Old:
https://imgsli.com/MzQ0MjYy
New:
https://imgsli.com/MzQ0MjY1
Map
pulse
,r_forceRendererTime 50000
andr_forceRendererTime 50001
:Old:
https://imgsli.com/MzQ0MjY0
New:
https://imgsli.com/MzQ0MjY2