Game Development Reference
Setting up RenderTexture
When we want to create a post-processing effect, in most cases we want our texture to be
as big (if not bigger) as the screen which we are rendering on to preserve the quality of the
resulting image. As such, the first step is to initialize our window and RenderTexture :
After we create the window, we also instantiate AssetManager . It is useful for all our
scene assets (even if we don't use it for RenderTexture ). Then we check for shader
support and exit the program if the check returns negative. Next, we create RenderTex-
ture with the exact size of the window and finally we create a sprite, which is used to
render the texture to the window.
The first step is then completed. Two things are left: the scene objects and the shader. For
scene objects we can use whatever we like—the shader works with anything, as long as it's
not transparent (then we won't actually see anything).
To achieve the pixelation we use the vertex shader from the previous example ( ver-
tShader.vert ) and this new fragment shader, which actually creates the effect: