-
-
Notifications
You must be signed in to change notification settings - Fork 43
Getting Started
BACK > Home
This page explains how to get started using kMirrors in your project.
kMirrors is a package. Using this tool requires manual modification of your project's package manifest.
- Open your project manifest file (
MyProject/Packages/manifest.json
). - Add
"com.kink3d.mirrors": "https://github.com/Kink3d/kMirrors.git"
to thedependencies
list. - Open or focus on Unity Editor to resolve packages.
Placing Mirrors in Editor.
To Place mirrors in the Editor either use the Create menu in the Hierarchy and select kTools/Mirror
or use the Add Component menu to add the Mirror component via kTools/Mirror
.
Mirror can be positioned and orientated using the objects transform like any other GameObject. Transform scale values have no effect on the mirror rendering.
To place mirrors at runtime simply use AddComponent<Mirror>
and set values via the Mirror component's API. For more information see Scripting API.
Accessing reflections via kShadings Reflection Source property.
To access mirror reflections as part of the physically based environment reflection calculations it is recommended you use kShading. On both the Lit and Toon Lit shaders, if the Environment Reflections property is enabled, you can set the Source property to Mirror to use mirror reflections instead of environment probes. This shader will automatically sample the correct reflection texture (Global or Local) and apply it during the regular environment reflection calculations.
If you do not wish to use kShading it is recommended you use Shader Graph to access mirror reflections. Global reflections can be accessed by a Blackboard Texture2D property with a Reference Name of _ReflectionMap
. For Local reflections use _LocalReflectionMap
as the Reference Name. Both of these textures should be sampled using a Screen Position node with Mode set to Default as the input to the Sample Texture 2D node's UV input port.
Mirror component.
The Mirror component defines a mirror instance. It controls definition, settings and rendering of planar reflections for that instance. For more information see How it works.
Offset - Controls the offset value applied to the mirror's oblique front clip plane. Lower positive values result in a more accurate reflection contact position. Raising this value can help to avoid reflection leaks.
Layer Mask - Controls which layers are rendered by the reflection camera. For accurate reflections this value should match the main camera.
Scope - Controls how the output reflection texture is assigned to shaders. Global mode assigns the reflection texture to a global texture. All renderers that are not explicitly listed under Renderers of a mirror set to Local scope will receive the global reflection texture if mirror reflections are used. Only one global texture can be used. If more than one mirror is set to Global mode the source of the reflection texture is undefined. Local mode explicitly sets its reflection texture to all elements of the Renderers list. Renderers not listed under the Renderers list will not receive these reflections. You can have as many Local mirrors as you would like.
Texture Scale - Controls the scale value that the reflected camera's size is multiplied by. At a value of one the reflection texture is the same size as the source camera. At a value of zero the reflection camera is clamped at a scale of 4x4.
HDR - Controls whether the reflections are rendered in high dynamic range.
MSAA - Controls whether the reflections are resolved with multi sampled anti-aliasing.