Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Heat haze  (Read 3511 times)

0 Members and 1 Guest are viewing this topic.

Geheim

  • Full Member
  • ***
  • Posts: 201
    • View Profile
    • Email
Heat haze
« on: July 21, 2014, 01:18:55 pm »
Hey community,

For those of you who don't know the effect, showing it.
I always love to see this effect in real life, especially when driving the car or watching a fire  :D
So I thought this would also look great in any game which has fires or other hot stuff.

However my research ended unsuccessfully after reading tons of old forum posts about this topic...
The only thing I found (for 2d) was this devlog, but I don't quite understand the theory explained there.
What I also found was this pdf, but again I couldn't pick the necessary bits out of that to implement it.

I would really like to use this effect as a glsl shader, so if anyone could give me a better starting point, I would appreciate that :)
Also I know this forum might not be the perfect one for this question, so I don't really expect to get an answer, but who knows, maybe someone implemented something similar already.

Thanks and greetings, Geheim!
« Last Edit: July 21, 2014, 01:20:58 pm by Geheim »
Failing to succeed does not mean failing to progress!

binary1248

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1405
  • I am awesome.
    • View Profile
    • The server that really shouldn't be running
Re: Heat haze
« Reply #1 on: July 21, 2014, 10:45:08 pm »
SFGUI # SFNUL # GLS # Wyrm <- Why do I waste my time on such a useless project? Because I am awesome (first meaning).

Geheim

  • Full Member
  • ***
  • Posts: 201
    • View Profile
    • Email
Re: Heat haze
« Reply #2 on: July 22, 2014, 02:26:46 pm »
Thats more than I could have expected :o It works perfectly!
(click to show/hide)

The wiki page is great and well explained, no problems to follow and pretty straight forward! Also showing libnoise is a great choice :)

I wish this will also help others, because heat hazes are awesome and we need more of them :P
Failing to succeed does not mean failing to progress!

Geheim

  • Full Member
  • ***
  • Posts: 201
    • View Profile
    • Email
Re: Heat haze
« Reply #3 on: July 29, 2014, 01:16:51 pm »
Alright, after experimenting a lot, I got an issue:

Let's say I have my scenery and I want an area of it to be heat hazed. What I do is render everything on a render texture, then I make a shape (could be any, so let's take a convex shape) and set the texture of that shape to the render texture. I calculate the texture rect with mapCoordsToPixel and the zoom factor of my view. After that I just draw everything in correct order on the render window.

The problem now is, if I zoom, I have a different effect, the more I zoom in the slower / less distorted the heat haze gets and the other way round. The reason why is also clear to me: If it is zoomed in, the area of the heat haze gets bigger and the shader needs more time to go through the big area, than an area with no zoom.

I then tried to change the riseFactor and the distortionFactor according to the zoom factor (and many other "logical seeming" factors), but it's not fully working.

Any ideas how to accomplish this?
If you need a small and complete example, please let me know.
Thanks!
Failing to succeed does not mean failing to progress!

Mario

  • SFML Team
  • Hero Member
  • *****
  • Posts: 878
    • View Profile
Re: Heat haze
« Reply #4 on: July 30, 2014, 05:25:03 pm »
Thing is that the shader will always scale to your whole texture size. Why don't you apply the shader directly to the flames when rendering them?

Geheim

  • Full Member
  • ***
  • Posts: 201
    • View Profile
    • Email
Re: Heat haze
« Reply #5 on: July 30, 2014, 05:54:31 pm »
Because the haze also goes beyond the flames on whatever might be above the fire.
Also you could use this effect in other situations too, where you just don't know what objects it might distort, thats why (I think) you can only do this efficient as a post rendering effect, or am I wrong?
Failing to succeed does not mean failing to progress!

 

anything