Bär wartet nach aufwachen etc

This commit is contained in:
2026-01-25 17:22:11 +01:00
parent 6504147456
commit e38a2b05e7
384 changed files with 132389 additions and 54 deletions
@@ -0,0 +1,13 @@
# Changelog
All notable changes to this package are documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
## 0.1.0 - 2020-01-30
### Added
- Camera management
- Reflection rendering
- Camera controls
- Local mirrors
- Support for kShading Lit and Toon Lit
@@ -0,0 +1,14 @@
fileFormatVersion: 2
guid: e6f16d9661a4cd04bb5b4b6af1f5e9a3
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 297566
packageName: Water Stylized Shader Orto & Perspective Camera
packageVersion: 1.0
assetPath: Assets/AureDevGames/Water Stylized Shader Orto & Perspective Camera/kMirrors/CHANGELOG.md
uploadId: 700359
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 91b6875a43543e9459f88d979b41fec1
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,184 @@
using UnityEngine;
using UnityEditor;
using UnityEditorInternal;
namespace kTools.Mirrors.Editor
{
using Editor = UnityEditor.Editor;
[CustomEditor(typeof(Mirror)), CanEditMultipleObjects]
sealed class MirrorEditor : Editor
{
#region Structs
struct Styles
{
// Foldouts
public static readonly GUIContent ProjectionOptions = new GUIContent("Projection Options");
public static readonly GUIContent OutputOptions = new GUIContent("Output Options");
// Properties
public static readonly GUIContent Offset = new GUIContent("Offset",
"Offset value for oplique near clip plane.");
public static readonly GUIContent LayerMask = new GUIContent("Layer Mask",
"Which layers should the Mirror render.");
public static readonly GUIContent Scope = new GUIContent("Scope",
"Global output renders to the global texture. Only one Mirror can be global. Local output renders to one texture per Mirror, this is set on all elements of the Renderers list.");
public static readonly GUIContent Renderers = new GUIContent("Renderers",
"Renderers to set the reflection texture on.");
public static readonly GUIContent TextureScale = new GUIContent("Texture Scale",
"Scale value applied to the size of the source camera texture.");
public static readonly GUIContent HDR = new GUIContent("HDR",
"Should reflections be rendered in HDR.");
public static readonly GUIContent MSAA = new GUIContent("MSAA",
"Should reflections be resolved with MSAA.");
}
struct PropertyNames
{
public static readonly string Offset = "m_Offset";
public static readonly string LayerMask = "m_LayerMask";
public static readonly string Scope = "m_Scope";
public static readonly string Renderers = "m_Renderers";
public static readonly string TextureScale = "m_TextureScale";
public static readonly string AllowHDR = "m_AllowHDR";
public static readonly string AllowMSAA = "m_AllowMSAA";
}
#endregion
#region Fields
const string kEditorPrefKey = "kMirrors:MirrorData:";
Mirror m_Target;
// Foldouts
bool m_ProjectionOptionsFoldout;
bool m_OutputOptionsFoldout;
// Properties
SerializedProperty m_OffsetProp;
SerializedProperty m_LayerMaskProp;
SerializedProperty m_ScopeProp;
SerializedProperty m_RenderersProp;
SerializedProperty m_TextureScaleProp;
SerializedProperty m_AllowHDR;
SerializedProperty m_AllowMSAA;
#endregion
#region State
void OnEnable()
{
// Set data
m_Target = target as Mirror;
// Get Properties
m_OffsetProp = serializedObject.FindProperty(PropertyNames.Offset);
m_LayerMaskProp = serializedObject.FindProperty(PropertyNames.LayerMask);
m_ScopeProp = serializedObject.FindProperty(PropertyNames.Scope);
m_RenderersProp = serializedObject.FindProperty(PropertyNames.Renderers);
m_TextureScaleProp = serializedObject.FindProperty(PropertyNames.TextureScale);
m_AllowHDR = serializedObject.FindProperty(PropertyNames.AllowHDR);
m_AllowMSAA = serializedObject.FindProperty(PropertyNames.AllowMSAA);
}
#endregion
#region GUI
public override void OnInspectorGUI()
{
// Get foldouts from EditorPrefs
m_ProjectionOptionsFoldout = GetFoldoutState("ProjectionOptions");
m_OutputOptionsFoldout = GetFoldoutState("OutputOptions");
// Setup
serializedObject.Update();
// Projection Options
var projectionOptions = EditorGUILayout.BeginFoldoutHeaderGroup(m_ProjectionOptionsFoldout, Styles.ProjectionOptions);
if(projectionOptions)
{
DrawProjectionOptions();
EditorGUILayout.Space();
}
SetFoldoutState("ProjectionOptions", m_ProjectionOptionsFoldout, projectionOptions);
EditorGUILayout.EndFoldoutHeaderGroup();
// Output Options
var outputOptions = EditorGUILayout.BeginFoldoutHeaderGroup(m_OutputOptionsFoldout, Styles.OutputOptions);
if(outputOptions)
{
DrawOutputOptions();
EditorGUILayout.Space();
}
SetFoldoutState("OutputOptions", m_OutputOptionsFoldout, outputOptions);
EditorGUILayout.EndFoldoutHeaderGroup();
// Finalize
serializedObject.ApplyModifiedProperties();
}
void DrawProjectionOptions()
{
// Clip Plane Offset
EditorGUILayout.PropertyField(m_OffsetProp, Styles.Offset);
// Layer Mask
EditorGUI.BeginChangeCheck();
LayerMask tempMask = EditorGUILayout.MaskField(Styles.LayerMask, (LayerMask)m_LayerMaskProp.intValue, InternalEditorUtility.layers);
if(EditorGUI.EndChangeCheck())
{
m_LayerMaskProp.intValue = (int)tempMask;
}
}
void DrawOutputOptions()
{
// Scope
EditorGUILayout.PropertyField(m_ScopeProp, Styles.Scope);
// Renderers
if(m_ScopeProp.enumValueIndex == (int)Mirror.OutputScope.Local)
{
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(m_RenderersProp, Styles.Renderers);
EditorGUI.indentLevel--;
}
// Texture Scale
EditorGUI.BeginChangeCheck();
var textureScale = EditorGUILayout.Slider(Styles.TextureScale, m_TextureScaleProp.floatValue, 0, 1);
if(EditorGUI.EndChangeCheck())
{
m_TextureScaleProp.floatValue = textureScale;
}
// HDR
EditorGUILayout.PropertyField(m_AllowHDR, Styles.HDR);
// MSAA
EditorGUILayout.PropertyField(m_AllowMSAA, Styles.MSAA);
}
#endregion
#region EditorPrefs
bool GetFoldoutState(string name)
{
// Get value from EditorPrefs
return EditorPrefs.GetBool($"{kEditorPrefKey}.{name}");
}
void SetFoldoutState(string name, bool field, bool value)
{
if(field == value)
return;
// Set value to EditorPrefs and field
EditorPrefs.SetBool($"{kEditorPrefKey}.{name}", value);
field = value;
}
#endregion
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: f989b0e08ab6cc34f9643e90fcb99cd8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 297566
packageName: Water Stylized Shader Orto & Perspective Camera
packageVersion: 1.0
assetPath: Assets/AureDevGames/Water Stylized Shader Orto & Perspective Camera/kMirrors/Editor/MirrorEditor.cs
uploadId: 700359
@@ -0,0 +1,17 @@
{
"name": "kTools.Mirrors.Editor",
"references": [
"GUID:9e705d6a72d9a354b810376671ddb3ac"
],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": true,
"precompiledReferences": [],
"autoReferenced": false,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}
@@ -0,0 +1,14 @@
fileFormatVersion: 2
guid: bfe6fbd0060e7e94883a1710b8ae7995
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 297566
packageName: Water Stylized Shader Orto & Perspective Camera
packageVersion: 1.0
assetPath: Assets/AureDevGames/Water Stylized Shader Orto & Perspective Camera/kMirrors/Editor/kTools.Mirrors.Editor.asmdef
uploadId: 700359
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 2aa965d0b276c594685f9dac6f21c0d0
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

@@ -0,0 +1,110 @@
fileFormatVersion: 2
guid: 679c06de8e095fc4d8489115cfc43352
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 10
mipmaps:
mipMapMode: 0
enableMipMap: 1
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: -1
aniso: -1
mipBias: -100
wrapU: -1
wrapV: -1
wrapW: -1
nPOTScale: 1
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 0
textureShape: 1
singleChannelComponent: 0
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID:
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 297566
packageName: Water Stylized Shader Orto & Perspective Camera
packageVersion: 1.0
assetPath: Assets/AureDevGames/Water Stylized Shader Orto & Perspective Camera/kMirrors/Gizmos/Mirror.png
uploadId: 700359
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2020 Matt Dean
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
@@ -0,0 +1,14 @@
fileFormatVersion: 2
guid: 0b1ef955611321d4c964399689ef1ef7
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 297566
packageName: Water Stylized Shader Orto & Perspective Camera
packageVersion: 1.0
assetPath: Assets/AureDevGames/Water Stylized Shader Orto & Perspective Camera/kMirrors/LICENSE
uploadId: 700359
@@ -0,0 +1,17 @@
# kMirrors
### Planar reflections for Unitys Universal Render Pipeline.
![alt text](https://github.com/Kink3d/kMirrors/wiki/Images/Home00.png?raw=true)
*An example of global and local reflections.*
kMirrors is a system for defining and rendering planar reflection cameras in Unity's Universal Render Pipeline. It supports **Global** mode, where a single reflection camera can be used across an entire scene (useful for water and other large reflective surfaces) and **Local** mode, where a list of **Renderers** can be defined to receive reflections (useful for smaller surfaces like wall mirrors).
Refer to the [Wiki](https://github.com/Kink3d/kMirrors/wiki/Home) for more information.
## Instructions
- Open your project manifest file (`MyProject/Packages/manifest.json`).
- Add `"com.kink3d.mirrors": "https://github.com/Kink3d/kMirrors.git"` to the `dependencies` list.
- Open or focus on Unity Editor to resolve packages.
## Requirements
- Unity 2019.3.0f3 or higher.
@@ -0,0 +1,14 @@
fileFormatVersion: 2
guid: 348769316597fe54b9db2cd435d11a02
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 297566
packageName: Water Stylized Shader Orto & Perspective Camera
packageVersion: 1.0
assetPath: Assets/AureDevGames/Water Stylized Shader Orto & Perspective Camera/kMirrors/README.md
uploadId: 700359
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 683872b7a9e58404d86a72f64355a908
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,399 @@
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.Universal;
namespace kTools.Mirrors
{
/// <summary>
/// Mirror Object component.
/// </summary>
[AddComponentMenu("kTools/Mirror"), ExecuteInEditMode]
[RequireComponent(typeof(Camera), typeof(UniversalAdditionalCameraData))]
public class Mirror : MonoBehaviour
{
#region Enumerations
/// <summary>
/// Camera override enumeration for Mirror properties
/// <summary>
public enum MirrorCameraOverride
{
UseSourceCameraSettings,
Off,
}
/// <summary>
/// Scope enumeration for Mirror output destination
/// <summary>
public enum OutputScope
{
Global,
Local,
}
#endregion
#region Serialized Fields
[SerializeField]
float m_Offset;
[SerializeField]
int m_LayerMask;
[SerializeField]
OutputScope m_Scope;
[SerializeField]
List<Renderer> m_Renderers;
[SerializeField]
float m_TextureScale;
[SerializeField]
MirrorCameraOverride m_AllowHDR;
[SerializeField]
MirrorCameraOverride m_AllowMSAA;
#endregion
#region Fields
const string kGizmoPath = "Packages/com.kink3d.mirrors/Gizmos/Mirror.png";
Camera m_ReflectionCamera;
UniversalAdditionalCameraData m_CameraData;
RenderTexture m_RenderTexture;
RenderTextureDescriptor m_PreviousDescriptor;
#endregion
#region Constructors
public Mirror()
{
// Set data
m_Offset = 0.01f;
m_LayerMask = -1;
m_Scope = OutputScope.Global;
m_Renderers = new List<Renderer>();
m_TextureScale = 1.0f;
m_AllowHDR = MirrorCameraOverride.UseSourceCameraSettings;
m_AllowMSAA = MirrorCameraOverride.UseSourceCameraSettings;
}
#endregion
#region Properties
/// <summary>Offset value for oplique near clip plane.</summary>
public float offest
{
get => m_Offset;
set => m_Offset = value;
}
/// <summary>Which layers should the Mirror render.</summary>
public LayerMask layerMask
{
get => m_LayerMask;
set => m_LayerMask = value;
}
/// <summary>
/// Global output renders to the global texture. Only one Mirror can be global.
/// Local output renders to one texture per Mirror, this is set on all elements of the Renderers list.
/// </summary>
public OutputScope scope
{
get => m_Scope;
set => m_Scope = value;
}
/// <summary>Renderers to set the reflection texture on.</summary>
public List<Renderer> renderers
{
get => m_Renderers;
set => m_Renderers = value;
}
/// <summary>Scale value applied to the size of the source camera texture.</summary>
public float textureScale
{
get => m_TextureScale;
set => m_TextureScale = value;
}
/// <summary>Should reflections be rendered in HDR.</summary>
public MirrorCameraOverride allowHDR
{
get => m_AllowHDR;
set => m_AllowHDR = value;
}
/// <summary>Should reflections be resolved with MSAA.</summary>
public MirrorCameraOverride allowMSAA
{
get => m_AllowMSAA;
set => m_AllowMSAA = value;
}
Camera reflectionCamera
{
get
{
if(m_ReflectionCamera == null)
m_ReflectionCamera = GetComponent<Camera>();
return m_ReflectionCamera;
}
}
UniversalAdditionalCameraData cameraData
{
get
{
if(m_CameraData == null)
m_CameraData = GetComponent<UniversalAdditionalCameraData>();
return m_CameraData;
}
}
#endregion
#region State
void OnEnable()
{
// Callbacks
RenderPipelineManager.beginCameraRendering += BeginCameraRendering;
// Initialize Components
InitializeCamera();
}
void OnDisable()
{
// Callbacks
RenderPipelineManager.beginCameraRendering -= BeginCameraRendering;
// Dispose RenderTexture
SafeDestroyObject(m_RenderTexture);
}
#endregion
#region Initialization
void InitializeCamera()
{
// Setup Camera
reflectionCamera.cameraType = CameraType.Reflection;
reflectionCamera.targetTexture = m_RenderTexture;
// Setup AdditionalCameraData
cameraData.renderShadows = false;
cameraData.requiresColorOption = CameraOverrideOption.Off;
cameraData.requiresDepthOption = CameraOverrideOption.Off;
}
#endregion
#region RenderTexture
RenderTextureDescriptor GetDescriptor(Camera camera)
{
// Get scaled Texture size
var width = (int)Mathf.Max(camera.pixelWidth * textureScale, 4);
var height = (int)Mathf.Max(camera.pixelHeight * textureScale, 4);
// Get Texture format
var hdr = allowHDR == MirrorCameraOverride.UseSourceCameraSettings ? camera.allowHDR : false;
var renderTextureFormat = hdr ? RenderTextureFormat.DefaultHDR : RenderTextureFormat.Default;
return new RenderTextureDescriptor(width, height, renderTextureFormat, 16) { autoGenerateMips = true, useMipMap = true };
}
#endregion
#region Rendering
void BeginCameraRendering(ScriptableRenderContext context, Camera camera)
{
// Never render Mirrors for Preview or Reflection cameras
if(camera.cameraType == CameraType.Preview || camera.cameraType == CameraType.Reflection)
return;
// Profiling command
CommandBuffer cmd = CommandBufferPool.Get($"Mirror {gameObject.GetInstanceID()}");
using (new ProfilingSample(cmd, $"Mirror {gameObject.GetInstanceID()}"))
{
ExecuteCommand(context, cmd);
// Test for Descriptor changes
var descriptor = GetDescriptor(camera);
if(!descriptor.Equals(m_PreviousDescriptor))
{
// Dispose RenderTexture
if(m_RenderTexture != null)
{
SafeDestroyObject(m_RenderTexture);
}
// Create new RenderTexture
m_RenderTexture = new RenderTexture(descriptor);
m_PreviousDescriptor = descriptor;
reflectionCamera.targetTexture = m_RenderTexture;
}
// Execute
RenderMirror(context, camera);
SetShaderUniforms(context, m_RenderTexture, cmd);
}
ExecuteCommand(context, cmd);
}
void RenderMirror(ScriptableRenderContext context, Camera camera)
{
// Mirror the view matrix
var mirrorMatrix = GetMirrorMatrix();
reflectionCamera.worldToCameraMatrix = camera.worldToCameraMatrix * mirrorMatrix;
// Make oplique projection matrix where near plane is mirror plane
var mirrorPlane = GetMirrorPlane(reflectionCamera);
var projectionMatrix = camera.CalculateObliqueMatrix(mirrorPlane);
reflectionCamera.projectionMatrix = projectionMatrix;
// Miscellanious camera settings
reflectionCamera.cullingMask = layerMask;
reflectionCamera.allowHDR = allowHDR == MirrorCameraOverride.UseSourceCameraSettings ? camera.allowHDR : false;
reflectionCamera.allowMSAA = allowMSAA == MirrorCameraOverride.UseSourceCameraSettings ? camera.allowMSAA : false;
reflectionCamera.enabled = false;
// Render reflection camera with inverse culling
GL.invertCulling = true;
UniversalRenderPipeline.RenderSingleCamera(context, reflectionCamera);
GL.invertCulling = false;
}
#endregion
#region Projection
Matrix4x4 GetMirrorMatrix()
{
// Setup
var position = transform.position;
var normal = transform.forward;
var depth = -Vector3.Dot(normal, position) - offest;
// Create matrix
var mirrorMatrix = new Matrix4x4()
{
m00 = (1f - 2f * normal.x * normal.x),
m01 = (-2f * normal.x * normal.y),
m02 = (-2f * normal.x * normal.z),
m03 = (-2f * depth * normal.x),
m10 = (-2f * normal.y * normal.x),
m11 = (1f - 2f * normal.y * normal.y),
m12 = (-2f * normal.y * normal.z),
m13 = (-2f * depth * normal.y),
m20 = (-2f * normal.z * normal.x),
m21 = (-2f * normal.z * normal.y),
m22 = (1f - 2f * normal.z * normal.z),
m23 = (-2f * depth * normal.z),
m30 = 0f,
m31 = 0f,
m32 = 0f,
m33 = 1f,
};
return mirrorMatrix;
}
Vector4 GetMirrorPlane(Camera camera)
{
// Calculate mirror plane in camera space.
var pos = transform.position - Vector3.forward * 0.1f;
var normal = transform.forward;
var offsetPos = pos + normal * offest;
var cpos = camera.worldToCameraMatrix.MultiplyPoint(offsetPos);
var cnormal = camera.worldToCameraMatrix.MultiplyVector(normal).normalized;
return new Vector4(cnormal.x, cnormal.y, cnormal.z, -Vector3.Dot(cpos, cnormal));
}
#endregion
#region Output
void SetShaderUniforms(ScriptableRenderContext context, RenderTexture renderTexture, CommandBuffer cmd)
{
var block = new MaterialPropertyBlock();
switch(scope)
{
case OutputScope.Global:
// Globals
cmd.SetGlobalTexture("_ReflectionMap", renderTexture);
ExecuteCommand(context, cmd);
// Property Blocm
block.SetFloat("_LocalMirror", 0.0f);
foreach(var renderer in renderers)
{
renderer.SetPropertyBlock(block);
}
break;
case OutputScope.Local:
// Keywords
Shader.EnableKeyword("_BLEND_MIRRORS");
// Property Block
block.SetTexture("_LocalReflectionMap", renderTexture);
block.SetFloat("_LocalMirror", 1.0f);
foreach(var renderer in renderers)
{
renderer.SetPropertyBlock(block);
}
break;
}
}
#endregion
#region CommandBufer
void ExecuteCommand(ScriptableRenderContext context, CommandBuffer cmd)
{
context.ExecuteCommandBuffer(cmd);
cmd.Clear();
}
#endregion
#region Object
void SafeDestroyObject(Object obj)
{
if(obj == null)
return;
#if UNITY_EDITOR
DestroyImmediate(obj);
#else
Destroy(obj);
#endif
}
#endregion
#region AssetMenu
#if UNITY_EDITOR
// Add a menu item to Mirrors
[UnityEditor.MenuItem("GameObject/kTools/Mirror", false, 10)]
static void CreateMirrorObject(UnityEditor.MenuCommand menuCommand)
{
// Create Mirror
GameObject go = new GameObject("New Mirror", typeof(Mirror));
// Transform
UnityEditor.GameObjectUtility.SetParentAndAlign(go, menuCommand.context as GameObject);
// Undo and Selection
UnityEditor.Undo.RegisterCreatedObjectUndo(go, "Create " + go.name);
UnityEditor.Selection.activeObject = go;
}
#endif
#endregion
#region Gizmos
#if UNITY_EDITOR
void OnDrawGizmos()
{
// Setup
var bounds = new Vector3(1.0f, 1.0f, 0.0f);
var color = new Color32(0, 120, 255, 255);
var selectedColor = new Color32(255, 255, 255, 255);
var isSelected = UnityEditor.Selection.activeObject == gameObject;
// Draw Gizmos
Gizmos.matrix = transform.localToWorldMatrix;
Gizmos.color = isSelected ? selectedColor : color;
Gizmos.DrawIcon(transform.position, kGizmoPath, true);
Gizmos.DrawWireCube(Vector3.zero, bounds);
}
#endif
#endregion
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 20b9488e8346e6445b175d59f4d2cd5c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {fileID: 2800000, guid: 679c06de8e095fc4d8489115cfc43352, type: 3}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 297566
packageName: Water Stylized Shader Orto & Perspective Camera
packageVersion: 1.0
assetPath: Assets/AureDevGames/Water Stylized Shader Orto & Perspective Camera/kMirrors/Runtime/Mirror.cs
uploadId: 700359
@@ -0,0 +1,32 @@
{
"name": "kTools.Mirrors.Runtime",
"references": [
"GUID:15fc0a57446b3144c949da3e2b9737a9",
"GUID:df380645f10b7bc4b97d4f5eb6303d95"
],
"includePlatforms": [
"Android",
"Editor",
"iOS",
"LinuxStandalone64",
"Lumin",
"macOSStandalone",
"PS4",
"Stadia",
"Switch",
"tvOS",
"WSA",
"WebGL",
"WindowsStandalone32",
"WindowsStandalone64",
"XboxOne"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}
@@ -0,0 +1,14 @@
fileFormatVersion: 2
guid: 9e705d6a72d9a354b810376671ddb3ac
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 297566
packageName: Water Stylized Shader Orto & Perspective Camera
packageVersion: 1.0
assetPath: Assets/AureDevGames/Water Stylized Shader Orto & Perspective Camera/kMirrors/Runtime/kTools.Mirrors.Runtime.asmdef
uploadId: 700359
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: e45556970c8b54c46b3ee1eadf721cbd
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 22f2c05c0f4e4d14b9c3ebcd98868851
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,23 @@
{
"name": "kTools.Mirrors.Editor.Tests",
"references": [
"GUID:27619889b8ba8c24980f49ee34dbb44a",
"GUID:0acc523941302664db1f4e527237feb3",
"GUID:9e705d6a72d9a354b810376671ddb3ac"
],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": true,
"precompiledReferences": [
"nunit.framework.dll"
],
"autoReferenced": false,
"defineConstraints": [
"UNITY_INCLUDE_TESTS"
],
"versionDefines": [],
"noEngineReferences": false
}
@@ -0,0 +1,14 @@
fileFormatVersion: 2
guid: 64aacc806d6d42c4bb2ca701deaaf9ea
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 297566
packageName: Water Stylized Shader Orto & Perspective Camera
packageVersion: 1.0
assetPath: Assets/AureDevGames/Water Stylized Shader Orto & Perspective Camera/kMirrors/Tests/Editor/kTools.Mirrors.Editor.Tests.asmdef
uploadId: 700359
@@ -0,0 +1,10 @@
{
"name": "com.kink3d.mirrors",
"description": "Planar reflections for Unity's Universal Render Pipeline.",
"version": "0.1.0",
"unity": "2019.3",
"displayName": "kMirrors",
"dependencies": {
"com.unity.render-pipelines.universal": "7.x.x"
}
}
@@ -0,0 +1,14 @@
fileFormatVersion: 2
guid: 5996b974fb4948d4fb830ac288fefbd1
PackageManifestImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 297566
packageName: Water Stylized Shader Orto & Perspective Camera
packageVersion: 1.0
assetPath: Assets/AureDevGames/Water Stylized Shader Orto & Perspective Camera/kMirrors/package.json
uploadId: 700359