SFML community forums
Help => Graphics => Topic started by: gsaurus on June 11, 2010, 05:49:43 pm
-
Well I have a few questions about Shaders on SFML 2
1 - PostFX was applied to the screen, now Shaders are applied to drawables when drawn on a RenderTarget. This is great, but is it still possible to apply shaders to the current state of the screen as before?
This may be explained somewhere but I didn't find it.
2 - I can only apply one shader to a drawable, right? Shaders can't be applied one after another on the same drawable (on 1.x it was possible to apply several PostFX on the screen).
-
1- You can, this is explained in the class documentation. Just capture the current contents of the window in a sf::Image, and draw it with a sprite and the shader.
2- Like with PostFx, you have to repeat the procedure explained above to produce the desired result. There's technically no way to apply N shaders in one pass, you must do N passes.
-
Ah, thanks. I was searching on the Shader documentation, I found now that there is a reference to it on the RenderImage :)
Just capture the current contents of the window in a sf::Image, and draw it with a sprite and the shader.
You mean by using the Image::CopyScreen function? I think I'd better to render everything in a RenderImage and then draw with the shader on the screen.
Edit: Ok I understand now that to apply a shader between draws I need an additional image in witch to render the current content with the shader, and replace the original content with that.
-
Ah, thanks. I was searching on the Shader documentation, I found now that there is a reference to it on the RenderImage
Sorry, I thought this was explained in the class headern but it is not :)
It's explained in this thread (http://www.sfml-dev.org/forum/viewtopic.php?t=1791), and it should probably be added to the class documentation.
You mean by using the Image::CopyScreen function? I think I'd better to render everything in a RenderImage and then draw with the shader on the screen.
Both solutions work. Using Copy::Screen is a little more expensive, but has the advantage of not impacting the rendering flow, you can use it exactly like you used sf::PostFx.
-
It's explained in this thread (http://www.sfml-dev.org/forum/viewtopic.php?t=1791)
Ah, I knew this thread exists! I haven't searched well enough (it wasn't on the first, let's say, 20 results of a search for "Shader" :P)
Thank you