How it works...

Since we now know how the basic screen effects system works, let's just cover the per-pixel operations we created in the ContrastSaturationBrightness() function.

The function starts by taking a few arguments. The first and most important is the current RenderTexture. The other arguments simply adjust the overall effect of the screen effect and are represented by sliders in the screen effect's Inspector tab. Once the function receives the RenderTexture and the adjustment values, it declares a few constant values that we use to modify and compare against the original RenderTexture.

The luminanceCoeff variable stores the values that will give us the overall brightness of the current image. These coefficients are based on the ...

Get Unity 2018 Shaders and Effects Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.