1. Home
  2. Docs
  3. PIDI : Planar Reflections...
  4. Advanced Topics
  5. Legacy RP Shaders

Legacy RP Shaders

While several different shaders are provided for the Legacy Rendering Pipeline that cover a wide variety of uses including PBR materials, water shaders and basic mirror-like shaders, there may be a need to create your own for the specific project you are working on.

A CGInclude file is provided with the asset that contains several helpful functions that should simplify the integration of the asset with custom made shaders. Helpers for getting the reflection UVs as well as for generating a fully PBR adjusted reflection color (with and without contact depth) are provided.

half2 screen2ReflectionUVs( float4 screenPosition )

This function turns the screen position (in Unity shaders IN.screenPosition) into a set of usable UVs to unwrap the reflection data (both color and depth).

half4 PBRBasedBlur( half4 albedo, half smoothness, half4 screenPosition, half maxBlur, half3 viewDir, half3 normal ) and PBRBasedBlurDepth

This function takes several properties from the PBR shader (the same that will be sent to the corresponding PBR outputs) such as albedo, smoothness and normal, as well as the reflectionUVs, a maxBlur value (to define how much will the reflection blur on very rough surfaces) and a view direction to apply a simple fresnel effect. It can be used as follows :

This is an example of how to add accurate reflections to a PBR shader using the Specular workflow in the Legacy RP (it is based around the Specular shader included with the asset). Using the functions included in the CGInclude file as well as a shader_feature called USE_DEPTH to define whether a depth pass will be used or not (which can save some performance at the shader level by reducing the amount of texture operations).