Game Development Reference
In-Depth Information
The shader requires three uniforms—the render texture, the size of the texture, and the
pixel size (in screen space). The size of the texture is required to normalize the pixel size
in the range of [0…1]. After we have that, we can clamp the value of the texture coordin-
ate for the current fragment to the nearest pixel (depending on our pixel size). The final
line sets the color of the fragment from the texture with the newly calculated texture co-
ordinate.
Once we have the shader written, we load it and set the values for the uniform:
The texture and texture size uniforms should only be set once (if we are using the shader
with a single texture), but the pixel size can be changed as many times as we like. It is not
restricted to an integer—any positive float value works. To achieve a transition effect,
Search WWH ::




Custom Search