1. Home
  2. Docs
  3. PIDI : Planar Reflections...
  4. Advanced Topics
  5. Bonus : Better Shaders

Bonus : Better Shaders

A minimal sample of how to integrate our asset to Better Shaders made shaders is included with the asset, in the Shared Assets folder. The process is quite straightforward and very similar to the way it is handled in standard ShaderLab. Be aware that Better Shaders is not officially supported and you are expected to handle the implementation of our asset with your own custom shaders by yourself, and some proficiency in writing shaders is expected in order to integrate our asset and Better Shaders made shaders. This small guide is simply a starting point in how to do so. 

First, you will need to have a _ReflectionTex property declared as a texture sampler. In order to sample it across the planar surfaces, you simply need to use the tex2D function while passing the Screen Space UVs with the x coordinate flipped:

 

BEGIN_OPTIONS
END_OPTIONS
BEGIN_PROPERTIES
//Our property for Reflection textures has to be the Reflection Tex property
[HideInInspector]_ReflectionTex("Reflection Tex", 2D) = "white" {}
END_PROPERTIES
BEGIN_CBUFFER
END_CBUFFER
BEGIN_CODE
sampler2D _ReflectionTex;
void SurfaceFunction(inout Surface o, ShaderData d)
{
//The Reflection UVs will be the screen coordinates with a flipped X coordinate.
float2 refUV = d.screenUV;
refUV.x = 1-refUV.x;
o.Albedo = tex2D(_ReflectionTex, refUV).rgb;
}
END_CODE