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

Author Topic: Fullscreen shaders and views  (Read 1704 times)

0 Members and 1 Guest are viewing this topic.

omegastick

  • Newbie
  • *
  • Posts: 2
    • View Profile
Fullscreen shaders and views
« on: January 21, 2019, 06:29:01 am »
I'm trying to apply a fullscreen shader to my program. To apply the shader, I'm drawing everything to a 1920x1080px sf::RenderTexture, then drawing that sf::RenderTexture to the window with the shader. The window has an sf::View applied, which is set to scale 1920x1080px to the whole window. This works perfectly fine with the shader disabled. It also works fine with the shader enabled and the window resolution set to the same as the sf::RenderTexture resolution (1920x1080).

However, when I enable the shader (change window.draw(texture) to window.draw(texture, &shader)) and the window resolution is something other thatn 1920x1080. The view is ignored, and the shader seems to be drawing straight to the window. I could bypass this by drawing to another sf::RenderTexture first, but doing 3 fullscreen draw calls seems unnecessary.

Am I doing this wrong?

Shader disabled (1440x810 resolution):
(click to show/hide)

Shader enable (1440x810 resolution):
(click to show/hide)

Shader code:
(click to show/hide)

omegastick

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Fullscreen shaders and views
« Reply #1 on: January 23, 2019, 06:27:03 am »
I've managed to get something roughly working by passing the screen resolution into the shader rather than the texture resolution. But this means that the effect scales badly at different screen resolutions (scanlines are hardly visible on a 4k screen). Any ideas?