User Tools

Site Tools


pidi_planar_reflections_2

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
pidi_planar_reflections_2 [2019/08/27 19:16]
irrsoft [Additional and advanced features]
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 and upgrade ====+==== 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 266: Line 270:
  
 ### ###
-In this section of the documentation we will learn more about advanced features included with the system, as well as some features that while now deprecated and unsupported may be useful for some projects with specific needs. Any feature that is no longer supported, experimental or deprecated is marked as such. Please read carefully all instructions before trying to use any of the settings described below.+In this section of the documentation we will learn more about advanced features included with the system, as well as some features that while now deprecated and unsupported may be useful for some projects with specific needs. Any feature that is no longer supported, is experimental or is deprecated is marked as such. Please read carefully all instructions before trying to use any of the settings described below.
 ### ###
  
Line 309: Line 313:
  
 ### ###
-IMPORTANT : The custom components workflow depends entirely on System.Reflection commands which may not be supported in your target device. Please research about your devices' capabilities before trying to use this feature. Because of the System.Reflection calls, this feature can be very demanding when the Sync Custom Components flag is enabled so it is heavily recommended to disable it during play time and for the final build.+**IMPORTANT : The custom components workflow depends entirely on System.Reflection commands which may not be supported in your target device. Please research about your devices' capabilities before trying to use this feature. Because of the System.Reflection calls, this feature can be very demanding when the Sync Custom Components flag is enabled so it is heavily recommended to disable it during play time and for the final build.**
 ### ###
 ### ###
Line 327: Line 331:
 ### ###
 In short, treat your reflective object as if it was another camera and to add support for post process rendering add the same components you would add to a standard unity camera. In short, treat your reflective object as if it was another camera and to add support for post process rendering add the same components you would add to a standard unity camera.
 +###
 +
 +\\
 +
 +----
 +
 +==== Reflection Shaders ====
 +###
 +In this section we will cover the basics of all the shaders included on this package as well as a small tutorial that will teach you how to add reflections support to your own custom shaders.
 +###
 +###
 +While the plugin is compatible with Mobile devices, most of the included shaders require support for at least OpenGL 3.0. If you are developing for Mobile devices, check the device's capabilities before using the included shaders.
 +###
 +###
 +The included shaders can be divided in 5 different groups : Water shader, Mirror Shaders, Generic, Chroma Key and full PBR surface shaders. 
 +###
 +\\
 +----
 +
 +=== Water Shaders ===
 +;#;
 +**SIMPLE WATER, REFLECTION+REFRACTION**
 +;#;
 +;#;
 +**(PIDI SHADERS COLLECTION/PLANAR REFLECTION/MIRROR/SIMPLE)**
 +;#;
 +###
 +There is one water shader included with this package, the Simple - Reflection+Refraction water shader. While part of the Simple branch of water shaders, has several important features that allow it to be easily extended into more complex shaders.
 +###
 +
 +\\
 +{{ :planar2_watershader.png?direct&600 |}}
 +\\
 +
 +###
 +The only texture required by the shader is the Waves Normal map. A default Normal map is provided with this package.
 +###
 +
 +\\
 +{{ :planar2_watershaderui.jpg?direct&400 |}}
 +\\
 +###
 +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.
 +###
 +
 +\\
 +
 +----
 +
 +=== Mirror Shaders ===
 +
 +###
 +There are several variants included under the mirror shaders section: a simple mirror that just renders the reflection without any further effects; a PBR mirror with support for fogginess and blurred reflections; a mirror with blur support only; mirror with fog support only and mirrors with distortions for broken reflections. 
 +###
 +\\
 +;#;
 +**SIMPLE REFLECTION SHADER**
 +;#;
 +;#;
 +**(PIDI SHADERS COLLECTION/PLANAR REFLECTION/MIRROR/SIMPLE)**
 +;#;
 +
 +\\
 +{{ :planar2_basicmirrorshader.jpg?direct&600 |}}
 +\\
 +
 +###
 +The most basic reflective shader available, it takes a render texture with the reflection from a PIDI_PlanarReflection object and applies a color to it.
 +###
 +\\
 +;#;
 +**FOGGY MIRROR SHADER**
 +;#;
 +;#;
 +**(PIDI SHADERS COLLECTION/PLANAR REFLECTION/MIRROR/FOG+BLUR)**
 +;#;
 +
 +{{ :planar2_foggymirror.png?direct&600 |}}
 +\\
 +
 +###
 +This shader is useful to simulate a more complex mirror with support for overlay textures, radial fog coverage, normals to distort the reflections among other effects.
 +###
 +
 +\\
 +{{ :planar2_foggymirrorui.jpg?direct&400 |}}
 +\\
 +
 +###
 +The shader takes an overlay/decal texture which will be rendered on top of the reflection and fog and will react to the scene's lighting. The alpha of the texture is used to show the reflection through.
 +###
 +
 +###
 +A Normal map can be assigned as well, to distort the reflections, be used as a normal map or both. The Bump+Distortion/Just Distortion slider controls this transition.
 +###
 +
 +The strength of the distortion effect is controlled with the Reflection Distortion slider.
 +
 +A color tint can be applied to the reflection through the Reflection Tint color.
 +
 +The reflection texture can be assigned automatically by the PIDI_PlanarReflection object.
 +
 +
 +###
 +The fog color modifies the final color of the fog in the mirror while the fog texture controls how it spreads. The red channel of the fog texture controls the spreading of the fog. When the Fog Level is changed, the fog will appear spreading from the highest to the lowest red values in the fog texture. 
 +###
 +###
 +In the example texture this is in a radial gradient towards the center. This is further multiplied by the green and blue channels to give some variation to the spreading. The alpha channel of the fog texture is used to control precisely which parts of the mirror will not have any fog. Internally, the shader automatically blurs the reflection in the fogged zones, making the blur as strong as the fog.
 +###
 +
 +Additional variants with support for only blur, only fog or only the overlay are also provided.
 +\\
 +\\
 +;#;
 +**BROKEN MIRROR SHADER**
 +;#;
 +;#;
 +**(PIDI SHADERS COLLECTION/PLANAR REFLECTION/MIRROR/BROKEN)**
 +;#;
 +
 +{{ :planar2_brokenmirror.png?direct&600 |}}
 +\\
 +
 +###
 +This shader is used to simulate broken reflections such as in damaged mirrors and other similar surfaces. Each shard of the mirror applies distortion and offset to the reflection without generating additional passes, generating complex effects at a very low performance cost.
 +###
 +
 +\\
 +{{ :planar2_brokenmirrorui.jpg?direct&400 |}}
 +\\
 +
 +###
 +The shader takes an overlay/decal texture which will be rendered on top of the broken effect while being slightly distorted by it.
 +###
 +
 +The Normal map is used to make a more believable effect and should match the broken pattern.
 +
 +###
 +The Reflection distortion is applied to the reflection texture to make it deform along the breaking patterns and the normal map.
 +###
 +
 +###
 +The broken map is a texture that controls the full breaking effect. The alpha channel acts as the height map for the distortion, the red and green channels control the displacement of the reflection along the X/Y axis and the blue channel controls the sign of the direction of the movement (B>0.5 = positive,  B< 0.5 = negative )
 +###
 +
 +\\
 +
 +----
 +=== Generic Reflection Shaders ===
 +\\
 +{{ :planar2_generic.jpg?direct&600 |}}
 +\\
 +
 +###
 +Four variants of generic reflective shaders based on the Standard Specular shader are included with this package. These generic shaders are meant for regular PBR materials that should display a slight real-time reflection (such as marble floors, plastics, etc ). The variants are : Simple Surface, Simple Surface+ Blur, Depth+Blur, Alpha Surface and Alpha Surface+Blur.
 +###
 +
 +\\
 +{{ :planar2_genericui.jpg?direct&400 |}}
 +\\
 +
 +###
 +They take a Main texture to be displayed on the surface, a Normal map that will also distort the reflection, a GSOH Map (R=Gloss, G = Specularity,  B = Occlusion, A = Height)
 +###
 +
 +The Parallax Height value controls a basic Parallax mapping effect.
 +
 +The Reflection Tint adds some coloring to the final reflection.
 +
 +###
 +Bump Reflection Distortion is the amount of distortion that the bump mapping will apply over the real-time reflections.
 +###
 +Surface Distortion allows the reflections to be affected by the curvature of surfaces that are not entirely flat
 +
 +Both the ReflectionTex and ReflectionDepth are provided by the Planar Reflections component automatically.
 +
 +###
 +The reflections can be distorted and blurred (depending on the shader variant) and the alpha channel of the main texture can control the transparency of the material (in Alpha enabled variants )
 +###
 +###
 +Additionally, all the generic surface shader have full support for an emission channel to be used and give full control over how the emission will mix with the reflections.
 +###
 +
 +###
 +In additive mode the reflection and the emission channels will be added to one another and mixed. In masked mode the emission channel will cover the reflections, hiding them.
 +###
 +
 +###
 +Besides these parameters there is also a HDR mode that allows you to use over brightness in your emission channel which is very useful for HDR based effects such as advanced bloom.
 +###
 +
 +\\
 +
 +----
 + 
 +=== Cube map Mix / Chroma keyed shaders ===
 +
 +
 +\\
 +{{ :planar2_chromashader.jpg?direct&600 |}}
 +\\
 +
 +###
 +In version 1.4+ we have included a new kind of shader designed for performance limited platforms such as mobile, which combines a static cubemap with a real-time reflection whose background color is dynamically removed with a chroma key effect. While the effect is still expensive due to the shader operations, it is far less demanding than rendering unnecessary geometry several times (once for the main scene, once for each reflection). 
 +###
 +
 +\\
 +{{ :planar2_chromashaderui.jpg?direct&400 |}}
 +\\
 +
 +###
 +To use these shaders effectively, enable the **Chroma Key Effects** flag on the PIDI_PlanarReflection component and define a background color that will be removed. Then, using the Chroma Key Tolerance value, control the amount of background that will be removed.
 +###
 +
 +\\
 +
 +----
 +
 +=== 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's Standard shader as close as possible. The variants are : 
 +###
 +
 +  * 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/PLANAR REFLECTION/PBR)**
 +;#; 
 +
 +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.
 +
 +\\
 +{{ :planar2_pbrshaderui.jpg?direct&400 |}}
 +\\
 +###
 +For some values such as the metallic, gloss (smoothness), roughness and specular, the shader allows you to select the source of these inputs. The source can be either the direct values as shown in the shader's interface or the corresponding texture. By using the drop down menu you can select which source to use
 +###
 +
 +###
 +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. 
 +###
 +
 +\\
 +{{ :planar2_pbrshaderui_2.jpg?direct&400 |}}
 +\\
 +
 +###
 +This Depth power variable controls how the depth will affect the reflections, either by controlling the amount of blur applied depending on the distance between the reflected objects and the surfaces or by fading out the far away objects in the case of the Depth Fade shaders. 
 +###
 +
 +\\
 +{{ :planar2_pbrshaderui_3.png?direct&600 |}}
 +\\
 +
 +\\
 +
 +
 +----
 +==== 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.
 +###
 +
 +\\
 +{{ :planar2_shadercode1.jpg?direct |}}
 +\\
 +
 +###
 +This reflection texture will then be unwrapped using screen coordinates. The standard code for screen coordinates is the following :
 +###
 +
 +\\
 +{{ :planar2_shadercode2.jpg?direct |}}
 +\\
 +
 +###
 +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's depth for any purpose (as measured from the reflective surface) you just need to add a 2D parameter called “_ReflectionDepth” to your shader and the PIDI_PlanarReflection component will assign it at runtime in the same way as the normal reflection. 
 +###
 +
 +\\
 +{{ :planar2_shadercode4.jpg?direct |}}
 +\\
 +
 +###
 +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.
 ### ###
pidi_planar_reflections_2.1566933401.txt.gz · Last modified: 2019/08/27 19:16 by irrsoft