This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
pidi_planar_reflections_2 [2019/08/28 03:21] irrsoft [Reflection Shaders] |
pidi_planar_reflections_2 [2019/09/05 14:23] (current) irrsoft [Installation] |
||
---|---|---|---|
Line 35: | Line 35: | ||
### | ### | ||
- | Two newer packages are provided to support the actual LWRP releases, one for LWRP 5.7 on Unity 2019.1 and one for LWRP 6-9 on Unity 2019.2. These packages are clearly labeled as such and easy to install, just by unpacking their contents inside the Unity Editor after double clicking on either one. | + | Two newer packages are provided to support the actual LWRP releases, one for LWRP 5.7 on Unity 2019.1 and one for LWRP 6.9 on Unity 2019.2. These packages are clearly labeled as such and easy to install, just by unpacking their contents inside the Unity Editor after double clicking on either one. |
### | ### | ||
Line 57: | Line 57: | ||
\\ | \\ | ||
- | ==== Installation | + | ==== Installation ==== |
### | ### | ||
- | While PIDI : Planar Reflections 2 has been designed to be integrated to any project at any stage of development with little to no setup required, there are still some considerations to be made for projects which are upgrading from the original release (version 1.0 - 1.9 ) or projects using the new Lightweight Rendering Pipeline (LWRP). Below you will find the steps to follow in order to install and setup PIDI : 2D Reflections 2 in any of these cases. | + | While PIDI : Planar Reflections 2 has been designed to be integrated to any project at any stage of development with little to no setup required, there are still some considerations to be made |
### | ### | ||
Line 186: | Line 186: | ||
### | ### | ||
Please keep in mind that due to the way Planar Reflections work (by basically re-drawing all the reflected objects for each camera that looks at the reflection) the best way to optimize the framerate of your project is to reduce the total amount of draw calls either by simplifying the scene or by reducing the amount of objects that are reflected. Reducing the resolution of the reflection, its update frequency and other factors will only help performance up to a point. | Please keep in mind that due to the way Planar Reflections work (by basically re-drawing all the reflected objects for each camera that looks at the reflection) the best way to optimize the framerate of your project is to reduce the total amount of draw calls either by simplifying the scene or by reducing the amount of objects that are reflected. Reducing the resolution of the reflection, its update frequency and other factors will only help performance up to a point. | ||
+ | ### | ||
+ | |||
+ | ### | ||
+ | Also keep in mind that due to the way the reflection textures are handled you will need a different material for each reflective surface unless they are all located in the same plane. | ||
### | ### | ||
Line 363: | Line 367: | ||
### | ### | ||
The only texture required by the shader is the Waves Normal map. A default Normal map is provided with this package. | The only texture required by the shader is the Waves Normal map. A default Normal map is provided with this package. | ||
- | ### | ||
- | ### | ||
- | The reflection texture can be any Render Texture and is automatically assigned if you create a plane with this material and add the PlanarReflection component to it. | ||
- | ### | ||
- | ### | ||
- | The Shore, Bottom and Clarity levels all control the depth based rendering of the transparency and colors of the water. Change these values to move the shore line, the deep end of the water and how clear or colored is the water near the shorelines. | ||
- | ### | ||
- | ### | ||
- | While the water material is easily configurable to look great in both Gamma and Linear color spaces, Linear is recommended for best and most coherent results. | ||
### | ### | ||
Line 377: | Line 372: | ||
{{ : | {{ : | ||
\\ | \\ | ||
- | |||
- | ### | ||
- | The only texture required by the shader is the Waves Normal map. A default Normal map is provided with this package. | ||
- | ### | ||
### | ### | ||
The reflection texture can be any Render Texture and is automatically assigned if you create a plane with this material and add the PlanarReflection component to it. | The reflection texture can be any Render Texture and is automatically assigned if you create a plane with this material and add the PlanarReflection component to it. | ||
Line 390: | Line 381: | ||
While the water material is easily configurable to look great in both Gamma and Linear color spaces, Linear is recommended for best and most coherent results. | While the water material is easily configurable to look great in both Gamma and Linear color spaces, Linear is recommended for best and most coherent results. | ||
### | ### | ||
+ | |||
+ | \\ | ||
---- | ---- | ||
Line 556: | Line 549: | ||
### | ### | ||
To use these shaders effectively, | To use these shaders effectively, | ||
+ | ### | ||
+ | |||
+ | \\ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | === Full PBR Shaders === | ||
+ | ### | ||
+ | Finally, nine variants of PBR reflective shaders are included with this package. These shaders are meant for regular PBR materials that should mimic Unity' | ||
+ | ### | ||
+ | |||
+ | * Metallic | ||
+ | * Metallic + Depth (Blur) | ||
+ | * Metallic + Depth (Fade) | ||
+ | * Specular | ||
+ | * Specular + Depth (Blur) | ||
+ | * Specular + Depth (Fade) | ||
+ | * Roughness | ||
+ | * Roughness + Depth (Blur) | ||
+ | * Roughness + Depth (Fade). | ||
+ | \\ | ||
+ | |||
+ | ;#; | ||
+ | **PBR REFLECTIVE SHADERS** | ||
+ | ;#; | ||
+ | ;#; | ||
+ | **(PIDI SHADERS COLLECTION/ | ||
+ | ;#; | ||
+ | |||
+ | This collection of shaders is based on the Standard shader included with Unity and all the inputs match those of the Standard Unity shader, with just a few differences. | ||
+ | |||
+ | \\ | ||
+ | {{ : | ||
+ | \\ | ||
+ | ### | ||
+ | For some values such as the metallic, gloss (smoothness), | ||
+ | ### | ||
+ | |||
+ | ### | ||
+ | On top of the standard shader properties and the default reflection properties such as the reflection tint, distortion and blur, the Depth versions of these shaders also include a variable called “Depth Blur Power” in the Depth variants and “Depth Fade Power” in the Depth (Fade) variants. | ||
+ | ### | ||
+ | |||
+ | \\ | ||
+ | {{ : | ||
+ | \\ | ||
+ | |||
+ | ### | ||
+ | This Depth power variable controls how the depth will affect the reflections, | ||
+ | ### | ||
+ | |||
+ | \\ | ||
+ | {{ : | ||
+ | \\ | ||
+ | |||
+ | \\ | ||
+ | |||
+ | |||
+ | ---- | ||
+ | ==== Adding Reflections to Custom Shaders ==== | ||
+ | ### | ||
+ | Adding reflections support to a custom shader or any existing shader is very easy. There are just a few bits of code that you need to add to be ready to take full advantage of our tool. | ||
+ | ### | ||
+ | ### | ||
+ | The minimum implementation possible requires a 2D parameter called “_ReflectionTex” which will receive the output reflection texture from the PIDI_PlanarReflection component. | ||
+ | ### | ||
+ | |||
+ | \\ | ||
+ | {{ : | ||
+ | \\ | ||
+ | |||
+ | ### | ||
+ | This reflection texture will then be unwrapped using screen coordinates. The standard code for screen coordinates is the following : | ||
+ | ### | ||
+ | |||
+ | \\ | ||
+ | {{ : | ||
+ | \\ | ||
+ | |||
+ | ### | ||
+ | Once the texture has been unwrapped and its value stored in a half4 variable the reflection can be used without any issue. In most cases the reflection will be used through the Emission channel of the shader, but this is entirely optional and depends on the effect you want to achieve. | ||
+ | ### | ||
+ | |||
+ | ### | ||
+ | If you need complex examples of the different uses you can give to the reflections and how to integrate them to shaders we recommend you to read the source code of the included shaders as they will provide a good learning material. | ||
+ | ### | ||
+ | |||
+ | ### | ||
+ | If you need to use the reflection' | ||
+ | ### | ||
+ | |||
+ | \\ | ||
+ | {{ : | ||
+ | \\ | ||
+ | |||
+ | ### | ||
+ | Then unwrap this texture by using the tex2Dproj function and use the length of the resulting color vector as your depth value. This depth will go from black (closest to the surface) to color (red for X axis, green for Y and blue for Z) depending on the distance to the reflective surface. | ||
### | ### |