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

Author Topic: How to implement a multipass shader  (Read 2451 times)

0 Members and 1 Guest are viewing this topic.

oomek

  • Jr. Member
  • **
  • Posts: 90
    • View Profile
    • Email
How to implement a multipass shader
« on: January 15, 2018, 03:35:14 am »
Is anyone willing to help explaining in detail how to implement a multipass fragment shader in SFML?
I need it for kawase blur so it should have an uniform integer accessible from within shader with the pass number.

Mario

  • SFML Team
  • Hero Member
  • *****
  • Posts: 879
    • View Profile
Re: How to implement a multipass shader
« Reply #1 on: January 18, 2018, 09:08:46 am »
Easiest solution for your multiple passes is to use two or more render textures:

  • Scene is rendered to render texture 1 using pass 1 shader.
  • Render texture 1 is rendered to render texture 2 using pass 2 shader.
  • Render texture 2 is rendered to render texture 1 using pass 3 shader.
  • Repeat as often as needed…
  • Render texture is rendered to the window using the last shader.

oomek

  • Jr. Member
  • **
  • Posts: 90
    • View Profile
    • Email
Re: How to implement a multipass shader
« Reply #2 on: February 15, 2018, 04:10:17 am »
It could work for fullscreen effects, but what should I do If I need multipass for sprites with transformations? Normally sprite is drawn on a fullscreen rendertarget, but for every pass before the final one I should draw it to the intermediate render target and reset the transformations? Should the imrt be the size of the source sprite texture, or the size after scaling?

 

anything