Skip to content
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 SKYDEFS scroll speed #2135

Merged
merged 3 commits into from
Jan 10, 2025
Merged

fix SKYDEFS scroll speed #2135

merged 3 commits into from
Jan 10, 2025

Conversation

fabiangreffrath
Copy link
Owner

Fixes #2107

@fabiangreffrath
Copy link
Owner Author

I tried this approach for interpolation but couldn't spot a difference between capped and uncapped rendering, probably because we are already at sub-pixel-per-second precision. What do you say @rfomin ?

diff --git a/src/r_plane.c b/src/r_plane.c
index 914a8e71..068bd894 100644
--- a/src/r_plane.c
+++ b/src/r_plane.c
@@ -39,6 +39,7 @@
 #include "doomstat.h"
 #include "doomtype.h"
 #include "i_system.h"
+#include "i_video.h"
 #include "m_fixed.h"
 #include "r_bmaps.h" // [crispy] R_BrightmapForTexName()
 #include "r_data.h"
@@ -415,7 +416,17 @@ static void DrawSkyTex(visplane_t *pl, skytex_t *skytex)
 
     dc_texturemid += skytex->curry;
 
-    angle_t an = viewangle + (skytex->currx << (ANGLETOSKYSHIFT - FRACBITS));
+    fixed_t deltax;
+    if (uncapped)
+    {
+        deltax = LerpFixed(skytex->prevx, skytex->currx);
+    }
+    else
+    {
+        deltax = skytex->currx;
+    }
+
+    angle_t an = viewangle + (deltax << (ANGLETOSKYSHIFT - FRACBITS));
 
     for (int x = pl->minx; x <= pl->maxx; x++)
     {
diff --git a/src/r_sky.c b/src/r_sky.c
index fc5a7148..908bbc04 100644
--- a/src/r_sky.c
+++ b/src/r_sky.c
@@ -176,12 +176,16 @@ void R_UpdateSky(void)
     }
 
     skytex_t *background = &sky->skytex;
+    background->prevx = background->currx;
+    background->prevy = background->curry;
     background->currx += background->scrollx;
     background->curry += background->scrolly;
 
     if (sky->type == SkyType_WithForeground)
     {
         skytex_t *foreground = &sky->foreground;
+        foreground->prevx = foreground->currx;
+        foreground->prevy = foreground->curry;
         foreground->currx += foreground->scrollx;
         foreground->curry += foreground->scrolly;
     }
diff --git a/src/r_skydefs.h b/src/r_skydefs.h
index 0f20b3cf..c4d54810 100644
--- a/src/r_skydefs.h
+++ b/src/r_skydefs.h
@@ -37,8 +37,10 @@ typedef struct
     double mid;
     fixed_t scrollx;
     fixed_t currx;
+    fixed_t prevx;
     fixed_t scrolly;
     fixed_t curry;
+    fixed_t prevy;
     fixed_t scalex;
     fixed_t scaley;
 } skytex_t;

@rfomin
Copy link
Collaborator

rfomin commented Jan 10, 2025

I tried this approach for interpolation but couldn't spot a difference between capped and uncapped rendering, probably because we are already at sub-pixel-per-second precision. What do you say @rfomin ?

Interpolation works, try to reduce the game speed to notice it. I'm using this test WAD: sky.zip

Looks good!

@rfomin
Copy link
Collaborator

rfomin commented Jan 10, 2025

How about scrolly interpolation? Also we need to add check for pause/menu:

diff --git a/src/r_plane.c b/src/r_plane.c
index 068bd894..bc919251 100644
--- a/src/r_plane.c
+++ b/src/r_plane.c
@@ -414,18 +414,20 @@ static void DrawSkyTex(visplane_t *pl, skytex_t *skytex)
     dc_texheight = textureheight[texture] >> FRACBITS;
     dc_iscale = FixedMul(skyiscale, skytex->scaley);
 
-    dc_texturemid += skytex->curry;
-
-    fixed_t deltax;
-    if (uncapped)
+    fixed_t deltax, deltay;
+    if (uncapped && leveltime > oldleveltime)
     {
         deltax = LerpFixed(skytex->prevx, skytex->currx);
+        deltay = LerpFixed(skytex->prevy, skytex->curry);
     }
     else
     {
         deltax = skytex->currx;
+        deltay = skytex->curry;
     }
 
+    dc_texturemid += deltay;
+
     angle_t an = viewangle + (deltax << (ANGLETOSKYSHIFT - FRACBITS));
 
     for (int x = pl->minx; x <= pl->maxx; x++)

@fabiangreffrath fabiangreffrath merged commit 866f5d8 into master Jan 10, 2025
8 checks passed
@fabiangreffrath fabiangreffrath deleted the sky_scroll branch January 10, 2025 08:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SKYDEFS scroll speed different to Kex release
2 participants