Not logged inGosu Forums
Forum back to libgosu.org Help Search Register Login
Up Topic Gosu / Extending Gosu / PostProcessing: A (fragment) shader framework
- - By mathias Date 2009-05-18 23:36 Edited 2009-05-18 23:42
The last few days I experimented a bit with fragment shaders and their use in a 2D game development library like Gosu, and with the help of jlnr I came up with this extension header for Gosu, that simplifies the use of fragment shader.
With the use of GLEW to check for shader support this should work on Windows, Mac OS X and Linux aswell.

What the class does is, that each time a fragment shader is executed Gosu is forced to draw everything (=> flush the DrawOpQueue) and then the framebuffer contents are copied to a texture. This texture is rendered with the shader applied, and thus the PostProcessing class can handle multiple shaders.
If no shader support is available the class does not create a texture and simply does not execute the shader.

It should be even possible to apply the shader to only certain parts of a game, i.e. running a shader not at the end of your draw function, but in between it. This maybe even necessary for parts of the game that should not have the shader applied to, like on-screen text and HUDs.

I included a few sample shaders (Which I found on the internet and modified to get them working, and I really don't recall where I got them, sorry) which demonstrate the usage of the shaders.
Here is a video on YouTube demonstrating a few simple shaders

I am looking forward to test further applications of fragment shader in 2D games (per-pixel lighting and bloom comes to my mind). Feel free to post suggestions and criticism about the extension, implementation of it or new shaders.

This is C++ only for now, until jlnr figures a way to wrap this to ruby *hinthint* ;)
Attachment: Gosu-PostProcessing.zip (0B)
Parent - By jlnr (dev) Date 2011-08-26 02:40
The attachment is no longer available, but I think it was basically this header:

https://github.com/psde/GosuEx/blob/master/Shader/Shader.hpp

Plus example shaders for pixelation etc...
- By Maverick Date 2009-05-19 03:38
It looks awesome. Wish I could help but I have not traversed far into the land of pixel-shading. :]
Seeing as you have it for C++, would you mind helping me out? Did you get the tutorial with animation to work? I'm having difficulties. :D

Keep us updated on those shaders!
- By benko Date 2009-05-19 10:57
Looks amazing!
- By hima Date 2009-05-21 05:03
Wow that really is amazing. Keep up the good work :)
Up Topic Gosu / Extending Gosu / PostProcessing: A (fragment) shader framework

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill