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

Author Topic: Working with shaders with multiple views and renderTexture  (Read 1067 times)

0 Members and 1 Guest are viewing this topic.

WeezoMaster

  • Newbie
  • *
  • Posts: 1
    • View Profile
    • Email
Working with shaders with multiple views and renderTexture
« on: September 22, 2019, 07:04:29 pm »
Hello everyone,

It's the first time I post on this forum, and as my problem is about shaders, I think I'm posting under the good section ^^.

I'm working on a game engine since the last two years and recently wanted to play with shaders.
I wanted to recreate the effect of heat distorsion and find this tutorial here:  https://github.com/SFML/SFML/wiki/Source:-HeatHazeShader

Everything seems to work, except when my player moves.

To be more precise, my tilemaps layers and sprites are rendered on a renderTexture.
Also, I've created two sf::views, one which follows the player by setting the centerPosition to
its coordinates. The renderWindow draws the resulting sprite with the shader on the second view. With this combination I can follow the player all over the map by having just a renderTexture of the size of the window (1280*720).

However, I noticed that by moving the player, the distortion was "above" the rendering.
I would have preferred the distortion to be "fixed" when the player moves.

I created a small, clean project available here: https://github.com/WeezoMaster/sfml_shader_distorsion
I modified the original shader to freeze the distortion. The ultimate goal would be to move the player and make the distortion "scroll" also.

I don't know if the problem comes from my code or if I have to modify the shader.
I hope I have been clear enough. I have been working on it for several days without having had a satisfactory solution.

Thank you in advance!