I've been looking to implement a deferred rendering system in SFML.

I've read the tutorials on OGLdev for it, and I was wondering how to draw a scene built in SFML (sprites, text, etc) to the multiple render targets needed for the deferred shading process.

Basically, I need to be able to get SFML to draw every object to the GBuffer's MRTs, so I can have the parameters needed to do what I want.

Is this possible, or will I have to build my own rendering backend from scratch?


Something you could try using only SFML is to use a sf::RenderTexture. It allows you to render sf::Drawables offscreen.

So you could define multiple RenderTexture and mix them together before rendering on screen.

Be aware that by directly using SFML you cannot achieve 3D rendering.

Here's a link to the documentation : http://www.sfml-dev.org/documentation/2.3-fr/classsf_1_1RenderTexture.php

EDIT: Since I can't comment, here is my suggestion. You create 3 (or more) RenderTextures to hold the informations about the positions, the colors and the normals of your final image. You can then pass these textures to a shader computing your final image by using the informations stored in your textures. I have no clues about the performance of this approach since I never tried it.

  • \$\begingroup\$ Thank you! I tried using RT's before, but now I understand the process a bit better, so I might try it! I'm developing a 2D game, so that won't be an issue. Also, how would you "mix" the textures? Are you saying that I use one RT for each texture (position, diffuse, and normal), too? \$\endgroup\$ – Tetramputechture May 28 '15 at 18:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.