-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix texture scroll, optimise texture matrix operations a bit #1538
base: master
Are you sure you want to change the base?
Conversation
c53f89d
to
3dc3cae
Compare
At another spot on Pulse, with this PR I get a new instance of the scrolling glitch where there wasn't one before. The lorem ipsum star wars text thing at the spectator spawn only shows the first 2 lines then resets. |
d1c963d
to
5527ad1
Compare
Oh, right, there were some divs by 0 and a wrong index. Fixed now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried combining a rotate with a scroll and it still suffers from discontinuity:
textures/pulse/title
{
qer_editorimage textures/pulse/title.jpg
noPicMip
surfaceparm noimpact
surfaceparm nolightmap
surfaceparm trans
surfaceparm nomarks
{
map textures/pulse/title.jpg
tcMod rotate 5
tcMod scroll 0 0.025
blendFunc add
}
}
This could still be merged as-is though, as it fixes some things and doesn't break anything that is not already broken AFAIK.
src/engine/qcommon/q_shared.h
Outdated
@@ -877,6 +877,38 @@ inline vec_t VectorNormalize2( const vec3_t v, vec3_t out ) | |||
MatrixFromAngles( m, angles[ PITCH ], angles[ YAW ], angles[ ROLL ] ); | |||
} | |||
|
|||
inline void Mat3x2MultiplyScale( matrix_t m, const float x, const float y ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These probably don't need to be in q_shared.h
which is included by all files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I guess I can move those to tr_shade_calc.cpp
. I had just put those near where the original declarations were, no other reason.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've moved these to tr_shade_calc.cpp
now.
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 using `scrollPeriod[0] / ( matrix[0] + matrix[4] )` and `scrollPeriod[0] / ( matrix[0] + matrix[4] )` to get the actual time at which wrap-around for `x` and `y` will occur, and use `fmodf( backEnd.refdef.floatTime, period )` to get the part that is equivalent to just using `backEnd.refdef.floatTime`, but without the value getting continuously larger. Also NUKED some useless matrix computations from texMod scroll.
The texture matrices only use elements 0, 1, 4, 5, 12, and 13, so doing all the other computations there is wasteful.
5527ad1
to
f1b8984
Compare
Fixed, also fixed some more potential divisions by 0. |
The rotation+scroll shader I wrote above got more buggy with the latest code. It still makes discontinuous jumps, and also seems to accelerate faster and faster over time. |
Hmm, I probably messed something up before pushing to the remote. |
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