[Fixed] liquid warping effect not working

Bugs that have been investigated and resolved somehow.

Moderator: GZDoom Developers

liquid warping effect not working

Postby drfrag » Sun Feb 16, 2020 4:21 am

Warping flats appear frozen in SoftPoly with vid_rendermode 4. It can be seen in the player setup menu and with Brutal Doom v21 MAP15 (lava). Also models are corrupt/incomplete but that's another problem.
https://www.moddb.com/mods/brutal-doom/ ... m-v21-beta
User avatar
drfrag
Os voy a romper a pedazos!
Vintage GZDoom Developer
 
Joined: 23 Apr 2004
Location: Spain
Discord: drfrag#3555
Github ID: drfrag666

Re: liquid warping effect not working

Postby SanyaWaffles » Sun Feb 16, 2020 5:39 pm

I can confirm this happens with stuff outside of BD as well. DD1 and DD2 use warped textures extensively and they don't warp in Softpoly2 at all.
User avatar
SanyaWaffles
Wouldn't be an epic gamer if I didn't commit a few war crimes.
 
Joined: 25 Apr 2013
Location: Eastern Ohio
Discord: SanyaWaffles#5095
Twitch ID: sanyawaffles
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Re: liquid warping effect not working

Postby dpJudas » Sun Feb 16, 2020 6:58 pm

It isn't strange it doesn't work as the warp shader isn't implemented. Probably could be done with some kind of lookup table - the glsl version is way too slow to be ported directly over (afair it calls cos/sin for every pixel).
dpJudas
 
 
 
Joined: 28 May 2016

Re: liquid warping effect not working

Postby drfrag » Mon Feb 17, 2020 5:12 am

I know that it's not implemented. The legacy render path used software warping with a lookup table. Then there was some refactoring and it was left only for the software renderer. But AFAIK the code is here (warpbuffer.h):
Code: Select allExpand view
template<class TYPE>
void WarpBuffer(TYPE *Pixels, const TYPE *source, int width, int height, int xmul, int ymul, uint64_t time, float Speed, int warptype)
User avatar
drfrag
Os voy a romper a pedazos!
Vintage GZDoom Developer
 
Joined: 23 Apr 2004
Location: Spain
Discord: drfrag#3555
Github ID: drfrag666

Re: liquid warping effect not working

Postby drfrag » Sun Mar 22, 2020 5:06 pm

And i don't think i could add this myself. How could i "inject" that code somehow and where? :? This shader is different, it's not applied to the entire scene.
User avatar
drfrag
Os voy a romper a pedazos!
Vintage GZDoom Developer
 
Joined: 23 Apr 2004
Location: Spain
Discord: drfrag#3555
Github ID: drfrag666

Re: liquid warping effect not working

Postby dpJudas » Sun Mar 22, 2020 5:56 pm

In ProcessMaterial it samples the texture. If EffectState is set to Shader_Warp then it using the warp shader.

Create a new function, like FuncNormal, but name it FuncWarp. Make ProcessMaterial call it when the effect state matches. The caller expects the FuncWarp function to fill thread->scanline.FragColor with the sampled data. You can either sample the texels yourself in that function, or warp the UV coordinates and call the SampleTexture function.
dpJudas
 
 
 
Joined: 28 May 2016

Re: liquid warping effect not working

Postby drfrag » Tue Mar 24, 2020 6:07 am

Thanks, i'm looking into it but i haven't gone very far as expected. I created two functions for Warp1 and Warp2. Uggh, i tried master, i tried.
The original code in WarpBuffer does two passes "for (y = height - 1; y >= 0; y--)" and "for (x = width - 1; x >= 0; x--)" and here the texture is between x0 and x1 it seems.
I don't know how to go from one to the other. :? It's very complicated stuff and i'm not that smart.
The original code is:
Code: Select allExpand view
template<class TYPE>
void WarpBuffer(TYPE *Pixels, const TYPE *source, int width, int height, int xmul, int ymul, uint64_t time, float Speed, int warptype)
{
   int ymask = height - 1;
   int x, y;

   if (warptype == 1)
   {
      TYPE *buffer = (TYPE *)alloca(sizeof(TYPE) * MAX(width, height));
      // [mxd] Rewrote to fix animation for NPo2 textures
      unsigned timebase = unsigned(time * Speed * 32 / 28);
      for (y = height - 1; y >= 0; y--)
      {
         int xf = (TexMan.sintable[((timebase + y*ymul) >> 2)&TexMan.SINMASK] >> 11) % width;
         if (xf < 0) xf += width;
         int xt = xf;
         const TYPE *sourcep = source + y;
         TYPE *dest = Pixels + y;
         for (xt = width; xt; xt--, xf = (xf + 1) % width, dest += height)
            *dest = sourcep[xf + ymask * xf];
      }
      timebase = unsigned(time * Speed * 23 / 28);
      for (x = width - 1; x >= 0; x--)
      {
         int yf = (TexMan.sintable[((time + (x + 17)*xmul) >> 2)&TexMan.SINMASK] >> 11) % height;
         if (yf < 0) yf += height;
         int yt = yf;
         const TYPE *sourcep = Pixels + (x + ymask * x);
         TYPE *dest = buffer;
         for (yt = height; yt; yt--, yf = (yf + 1) % height)
            *dest++ = sourcep[yf];
         memcpy(Pixels + (x + ymask*x), buffer, height * sizeof(TYPE));
      }
   }
   else if (warptype == 2)
   {
      unsigned timebase = unsigned(time * Speed * 40 / 28);
      // [mxd] Rewrote to fix animation for NPo2 textures
      for (x = 0; x < width; x++)
      {
         TYPE *dest = Pixels + (x + ymask * x);
         for (y = 0; y < height; y++)
         {
            int xt = (x + 128
               + ((TexMan.sintable[((y*ymul + timebase * 5 + 900) >> 2) & TexMan.SINMASK]) >> 13)
               + ((TexMan.sintable[((x*xmul + timebase * 4 + 300) >> 2) & TexMan.SINMASK]) >> 13)) % width;

            int yt = (y + 128
               + ((TexMan.sintable[((y*ymul + timebase * 3 + 700) >> 2) & TexMan.SINMASK]) >> 13)
               + ((TexMan.sintable[((x*xmul + timebase * 4 + 1200) >> 2) & TexMan.SINMASK]) >> 13)) % height;

            *dest++ = source[(xt + ymask * xt) + yt];
         }
      }
   }
   else
   {
      // should never happen, just in case...
      memcpy(Pixels, source, width*height * sizeof(TYPE));
   }
}
User avatar
drfrag
Os voy a romper a pedazos!
Vintage GZDoom Developer
 
Joined: 23 Apr 2004
Location: Spain
Discord: drfrag#3555
Github ID: drfrag666

Re: liquid warping effect not working

Postby Rachael » Tue Mar 24, 2020 7:54 am

I wouldn't use the software rendering code, as that is inconsistent with the shader.

What I would do instead, is copy the shader itself, and then translate it from GLSL to C++. AFAIR dpJudas said that he set up SoftPoly2 to be conceptually like a hardware renderer, and the way shaders work is they are executed upon every drawn pixel. The software renderer warps the texture in advance, instead.

Doing it this way will create a much better looking warp.

If you insist that you must use the software renderer's warp code, then you have to keep in mind that texture coordination is different. SoftPoly2 will use a float 0.0 to 1.0 for the texture bounds, whereas the software renderer's warp code must use the actual texture's size.
User avatar
Rachael
Webmaster
 
Joined: 13 Jan 2004
Discord: Rachael#3767
Twitch ID: madamerachelle
Github ID: madame-rachelle
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Re: liquid warping effect not working

Postby Graf Zahl » Tue Mar 24, 2020 9:12 am

The main problem with emulating a shader here would be performance. Warping the texture up front is definitely faster, but the main question here is, what hardware this is for. IMO the softpoly renderer is far too slow for full-scene 3D rendering, it is fine for doing the 2D parts.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: liquid warping effect not working

Postby Rachael » Tue Mar 24, 2020 9:44 am

In that case, wouldn't it make sense to just call the software renderer's own internal texture warp, like the GL 2 code once did? I can't say I am a huge fan of this, to be quite honest.
User avatar
Rachael
Webmaster
 
Joined: 13 Jan 2004
Discord: Rachael#3767
Twitch ID: madamerachelle
Github ID: madame-rachelle
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Re: liquid warping effect not working

Postby dpJudas » Tue Mar 24, 2020 10:50 am

I added the warp effect. Note that the sin there should probably be done by some lookup table (don't know if gzdoom's sin already does that or not).
dpJudas
 
 
 
Joined: 28 May 2016

Re: liquid warping effect not working

Postby Rachael » Tue Mar 24, 2020 12:11 pm

Thanks dpJudas - with that, I've gone ahead and expanded the effect to include Warp2 as well. :)
User avatar
Rachael
Webmaster
 
Joined: 13 Jan 2004
Discord: Rachael#3767
Twitch ID: madamerachelle
Github ID: madame-rachelle
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Re: liquid warping effect not working

Postby drfrag » Tue Mar 24, 2020 12:20 pm

dpJudas wrote:I added the warp effect.

Cool. :) Performance is fine, pretty much the same as before, and this is a lowend laptop.
User avatar
drfrag
Os voy a romper a pedazos!
Vintage GZDoom Developer
 
Joined: 23 Apr 2004
Location: Spain
Discord: drfrag#3555
Github ID: drfrag666

Re: liquid warping effect not working

Postby Rachael » Tue Mar 24, 2020 12:36 pm

Have you tested both warp and warp2? I am curious how it performs on that laptop, if it performs acceptably.
User avatar
Rachael
Webmaster
 
Joined: 13 Jan 2004
Discord: Rachael#3767
Twitch ID: madamerachelle
Github ID: madame-rachelle
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Re: liquid warping effect not working

Postby drfrag » Tue Mar 24, 2020 12:47 pm

I haven't merged your commit yet. I've noticed that it seems the helicopter in BD E1M1 makes softpoly run very slow, voxels?
User avatar
drfrag
Os voy a romper a pedazos!
Vintage GZDoom Developer
 
Joined: 23 Apr 2004
Location: Spain
Discord: drfrag#3555
Github ID: drfrag666

Next

Return to Closed Bugs

Who is online

Users browsing this forum: No registered users and 0 guests