PSX Flaming Sky

Remember, just because you request it, that doesn't mean you'll get it.

Moderator: GZDoom Developers

PSX Flaming Sky

Postby Enjay » Sun Dec 30, 2018 8:05 am

I was reading this (found via a link on Doomworld)

http://fabiensanglard.net/doom_fire_psx/

and I wondered how easy it would be to implement in GZDoom (perhaps GZDoom's full sky might make it a no-go?) and if there might be any enthusiasm for it?

It would be nice to have something engine-side rather than having to use a huge sequence of animated textures and, if it was implemented engine-side, the colour ranges might also be definable - allowing fire skies of any colour to be created.
User avatar
Enjay
Everyone is a moon, and has a dark side which he never shows to anybody. Twain
 
 
 
Joined: 15 Jul 2003
Location: Scotland

Re: PSX Flaming Sky

Postby Gez » Sun Dec 30, 2018 8:23 am

Some times ago I tried to see if it could be made with shaders; but unfortunately no -- each frame modifies the previous, and while you can access the source image from the shader I don't think you can access the previous render.

Other than that, the code is very simple and as long as you can access the previous frame's output, it's easy. If the texture manager gets exported to ZScript, for example, it could be done simply there.
Gez
 
 
 
Joined: 06 Jul 2007

Re: PSX Flaming Sky

Postby Erick194 » Sun Dec 30, 2018 1:50 pm

It would be nice to add it, but you have to take into account that the code of
Fabien Sanglard and the kaiser, is not the correct sequence for the fire of Psx Doom.
User avatar
Erick194
 
Joined: 10 Nov 2018
Location: Costa Rica

Re: PSX Flaming Sky

Postby Hellser » Mon Dec 31, 2018 3:25 pm

I don't think it has to be correct, but rather seems similar to.
User avatar
Hellser
Misdreavus used Psybeam!
 
Joined: 25 Jun 2006
Location: Mount Silver
Discord: Hellser#8156

Re: PSX Flaming Sky

Postby Rachael » Mon Dec 31, 2018 3:34 pm

In my opinion, this would be a lot easier to do if it was possible to dynamically manipulate textures using ZScript - something reminiscent of UE1's animated textures system. (Like FireFX)

Yes, it's possible to do things like ripples and other non-destructive changes using shaders, but as was pointed out shaders don't save their result in the texture to be reused later.
User avatar
Rachael
Webmaster
 
Joined: 13 Jan 2004
Discord: Rachael#3767
Twitch ID: madamerachelle
Github ID: madame-rachelle

Re: PSX Flaming Sky

Postby Graf Zahl » Mon Dec 31, 2018 4:41 pm

And that won't happen. Remember that we eliminated the last one that did such stuff half a year ago? Dynamic textures make renderer optimization a lot more complicated.
That said, of course you can store the result of a shader generated image in a texture, just not from the shader itself. If not there wouldn't be camera textures!

Manipulating shaders from script code is pretty much the ultimate performance killer. There was a reason that in older GZDooms the size of warped textures was limited.
User avatar
Graf Zahl
Lead GZDoom Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: PSX Flaming Sky

Postby Erick194 » Mon Dec 31, 2018 6:33 pm

Hellser wrote:I don't think it has to be correct, but rather seems similar to.


You're right, but it's good to feel as similar as possible, some time ago I did something similar with the psx fire, but I noticed that the pixels did not match the intro of psxdoom, which in the code of psxdoom v1.0 to be exact in the function (0x80027B90)

Code: Select allExpand view
L80027B90()//FIRE PSX
{
   r11 = r4;
   r3 = 0x80080000;
   r9 = 0;
   r5 = *((*(r11 + 16) << 2) + *L80078060) + 72;
   do {
      r8 = 1;
      r10 = 1;
      r6 = r5;
      do {

         //R_SpreadFire Here Start
         if ((*r6 & 255) != 0) {
            r2 = *(r28 + 1368) & 255;
            r4 = r2 + 1;
            r3 = r2 & 255;
            *(r28 + 1368) = r4;
            r1 = 0x80060000;
            *(r28 + 1368) = r2 + 2;
            r1 = 0x80060000;
            *((r10 - ( *(0x80058888 + r3) & 255 & 3) & 63) + r5 + -64) = r7 - ( *(0x80058888 + (r4 & 255)) & 255 & 1);
         }
         else {
            *(r6 + -64) = 0;
         }
         //R_SpreadFire Here End

         r6 = r6 + 64;
         r5 = r5 + 64;
      } while (r8 + 1 < 128);
      r5 = r5 + -8128;
   } while (r9 + 1 < 64);
   *(r11 + 28) = -1;
   return -1;
}


This results in:

Code: Select allExpand view
int fndindex = 0; // Fire Rand Index PSX

static void R_SpreadFirePSX(byte* src1, byte* src2, int pixel, int counter, int* rand)
{
    int randIdx = 0;
    int randIdx2 = 0;
    byte *tmpSrc;
   
    if(pixel != 0)
    {
      //[GEC] Like PsxDoom
        randIdx = (rndtable[*rand]);
        randIdx2 = (rndtable[*rand+1]);
        *rand = ((*rand+2) & 0xff);
        fndindex = *rand;
       
        tmpSrc = (src1 + (((counter - (randIdx & 3)) + 1) & (FIRESKY_WIDTH-1)));
       
        *(byte*)(tmpSrc - FIRESKY_WIDTH) = pixel - ((randIdx2 & 1));
    }
    else
    {
        *(byte*)(src2 - FIRESKY_WIDTH) = 0;                                                                                                                     
    }
}


 and so it performs the correct sequence.
User avatar
Erick194
 
Joined: 10 Nov 2018
Location: Costa Rica

Re: PSX Flaming Sky

Postby spiral » Tue Jan 01, 2019 12:48 am

Gez wrote:Some times ago I tried to see if it could be made with shaders; but unfortunately no -- each frame modifies the previous, and while you can access the source image from the shader I don't think you can access the previous render.

Other than that, the code is very simple and as long as you can access the previous frame's output, it's easy. If the texture manager gets exported to ZScript, for example, it could be done simply there.


I have been meaning to do that for a while so I threw together a GLSL port on Shadertoy that works using a backbuffer: https://www.shadertoy.com/view/3sX3W4

It might be cool to have an actual texture pipeline in GLDEFS in order to support this, but doesn't seem worth implementing unless there are other procedural effects people are interested in doing.
spiral
 
Joined: 20 Mar 2018

Re: PSX Flaming Sky

Postby Gez » Tue Jan 01, 2019 6:28 am

The demo on shadertoy doesn't seem to work for me, I get plenty of error messages.

Image
Gez
 
 
 
Joined: 06 Jul 2007

Re: PSX Flaming Sky

Postby Nash » Tue Jan 01, 2019 6:32 am



Seems to work for me.

Cool demo, but yeah, unfortunately you don't have access to additional buffers in GZDoom GLSL.
User avatar
Nash
Nash Muhandes
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia

Re: PSX Flaming Sky

Postby Graf Zahl » Tue Jan 01, 2019 8:01 am

Nash wrote:Cool demo, but yeah, unfortunately you don't have access to additional buffers in GZDoom GLSL.


The big problem here is that we still have to support some ancient GL versions due to too high user share. Right now dumping 3.3 would not be doable which really complicates the shader interface.
User avatar
Graf Zahl
Lead GZDoom Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: PSX Flaming Sky

Postby spiral » Tue Jan 01, 2019 7:34 pm

Gez wrote:The demo on shadertoy doesn't seem to work for me, I get plenty of error messages.


Sorry about that, if you're using an older browser it may not fully support WebGL2.

Graf Zahl wrote:The big problem here is that we still have to support some ancient GL versions due to too high user share. Right now dumping 3.3 would not be doable which really complicates the shader interface.


It's been maybe a few months since I looked at gzdoom master, is there anything complicating it besides lack of direct state access? I've done this kind of thing in 3.3 before, it's certainly not trivial, but paves the way for allowing arbitrary compositing effects like you would see with a true scene graph.
spiral
 
Joined: 20 Mar 2018

Re: PSX Flaming Sky

Postby Marisa Kirisame » Wed Jan 02, 2019 9:20 am

Graf Zahl wrote:Dynamic textures make renderer optimization a lot more complicated.


Can I take this as a "No" for scripted textures in general or just those that would be done like this, purely on the software side? Because I still plan to make some sort of canvas texture that can be drawn to using the same functions as the ZScript Screen API.
User avatar
Marisa Kirisame
ZScript Magician
 
 
 
Joined: 08 Feb 2008
Location: Vigo, Galicia
Discord: Marisa Kirisame#4689
Twitch ID: magusmarisa

Re: PSX Flaming Sky

Postby Graf Zahl » Wed Jan 02, 2019 9:35 am

Scripted textures would mean 'scripting through GLSL'.
Scripting textures through ZScript is too performance intensive, even with a JIT compiler. this is an area where speed is the only thing that matters.
User avatar
Graf Zahl
Lead GZDoom Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: PSX Flaming Sky

Postby phantombeta » Wed Jan 02, 2019 12:45 pm

User avatar
phantombeta
In the meadow of sinful thoughts, every flower's a perfect one
 
Joined: 02 May 2013
Location: The United Soviet Socialist Dictatorship of Hueland
Discord: phantombeta#2461
Twitch ID: phantombeta_

Next

Return to Feature Suggestions

Who is online

Users browsing this forum: JJP and 1 guest