It is currently Tue Nov 20, 2018 11:38 pm

All times are UTC - 7 hours



Forum rules





Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: Dracula X's fire effect
PostPosted: Fri Jun 29, 2018 6:34 pm 
Offline

Joined: Sun May 25, 2014 8:03 pm
Posts: 7
Location: College Park, MD
Does anyone here know exactly how Dracula X gets that awesome fire effect on the first stage? Badly upscaled image:

Image

It seems to be applying raster animation to a static "fire image" (basically, selectively repeating or omitting vertical strips), in addition to additive blending. But how, exactly?

I'm trying to replicate the effect for a level in my game (on PC, but sprite-based at 240p). This is the closest I've got so far (background of the stage removed):

Image

Not nearly as smooth or cool-looking!

And the code for how I'm producing the above:

Code:
double stripY = 0;

for (int i = 0; i < flameHeight; i++) {
    double pct = i / (double)flameHeight;
    double time = counter / 8.0;

    double inc = Math.Cos(pct * 3.14159 * 8 + time * 0.5);
    inc = (1.0 + inc);

    stripY += inc;

    // render horizontal strip at stripY, advance one line down
}

...where the counter increments every frame.

I could step through an emulator and figure out the effect myself, but it's been years (going on half a decade??) since I've looked at any assembly, and I have zero experience with the SNES hardware. So I was wondering if anyone here knew about this.

Thanks for your time!


Top
 Profile  
 
PostPosted: Fri Jun 29, 2018 6:38 pm 
Offline

Joined: Sun Apr 13, 2008 11:12 am
Posts: 7724
Location: Seattle
There's two layers. One's the building, it's just doing a sine-wave wobble left-right.
The other is the fire layer. It's transparent, and doing a sine-wave wobble up-down.

The important part for the up-down wobble is to use different amplitudes for the different sine wave components (w.r.t. time and y coordinate)

Er. Let me try again. What I mean is, if you plot y+sin(y), you see places where it's flat and places where it's twice as fast. That's why you those bars move the way they do in your implementation. If you scale either y or sin(y) by some number such that the derivative doesn't spend much time around zero, it looks better.


Top
 Profile  
 
PostPosted: Fri Jun 29, 2018 7:11 pm 
Offline

Joined: Sun May 25, 2014 8:03 pm
Posts: 7
Location: College Park, MD
Thanks for the quick reply!! Seems like I was overcomplicating stuff. It looks great now (both horizontal and vertical distortion applied):

Image

Final "code" for the effect:

Code:
for (int i = 0; i < flameHeight; i++) {
    double pct = i / flameHeight;
    double s = counter / 8.0;

    double inc = 8.0 * Math.Cos(0.5 * s + 8.0 * 3.14159 * pct);

    double yPos = i + inc;
    if (yPos < 0) yPos = 0;
    if (yPos > textureHeight) yPos = textureHeight;

    double xPos =  3.0 * Math.Cos(1.0 * s + 8.0 * 3.14159 * pct);

    // render strip at xPos, yPos
}


Top
 Profile  
 
PostPosted: Fri Jun 29, 2018 9:46 pm 
Offline
User avatar

Joined: Thu Aug 13, 2015 4:40 pm
Posts: 310
Location: Rio de Janeiro - Brazil
It looks great! What engine is it? edit: I see it's in C++. Well done :)
I would experiment adding a front fire layer (think tmnt arcade level 1).

_________________
https://twitter.com/bitinkstudios <- Follow me on twitter! Thanks!


Top
 Profile  
 
PostPosted: Fri Jun 29, 2018 11:00 pm 
Offline

Joined: Sun May 25, 2014 8:03 pm
Posts: 7
Location: College Park, MD
C#, actually (it was originally in C++ when we ran a Kickstarter a couple years back, but I got tired of programming in C++...) You can follow the game here: https://twitter.com/SteelAssault

The front fire layer is a good idea, I'll look into it. Thanks!


Top
 Profile  
 
PostPosted: Sat Jun 30, 2018 6:56 am 
Offline

Joined: Wed May 19, 2010 6:12 pm
Posts: 2774
Did you get those backgrounds done in just a couple hours?


Top
 Profile  
 
PostPosted: Sat Jun 30, 2018 9:09 am 
Offline

Joined: Mon Mar 30, 2015 10:14 am
Posts: 276
i did this fire effect on pecengine .

https://www.youtube.com/watch?v=qsSsNe3RfSk


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group