Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,188 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 3
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: WaterBasicDaytime
m_Shader: {fileID: 4800000, guid: 9dccc8e8f0da4494991c26ef59019551, type: 3}
m_ShaderKeywords: []
m_CustomRenderQueue: -1
m_SavedProperties:
serializedVersion: 2
m_TexEnvs:
data:
first:
name: _MainTex
second:
m_Texture: {fileID: 2800000, guid: c2ef94ff9d11915d1100a04b44295342, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
data:
first:
name: _BumpMap
second:
m_Texture: {fileID: 2800000, guid: a53cf5449d11a15d1100a04b44295342, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
data:
first:
name: _ReflectionTex
second:
m_Texture: {fileID: 8400000, guid: 21bb33409d118354d000dcabe39e7c39, type: 2}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
data:
first:
name: _ColorControlCube
second:
m_Texture: {fileID: 8900000, guid: 98c330f39d11745ad0004adb8d76c639, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
data:
first:
name: _ColorControl
second:
m_Texture: {fileID: 2800000, guid: 047330f39d11745ad0004adb8d76c639, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
data:
first:
name: _WavesTex
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
data:
first:
name: _BumpMap2
second:
m_Texture: {fileID: 2800000, guid: 279fb0a19d11d4a6d00051fa8d76c639, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
data:
first:
name: _ColorGradient
second:
m_Texture: {fileID: 2800000, guid: 8403d3349d112ba4d000be1be39e7c39, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
data:
first:
name: _Shininess
second: 1
data:
first:
name: _WaveScale
second: .0702830181
data:
first:
name: _Highlight
second: 33.2075462
data:
first:
name: _bScale
second: .0700000003
data:
first:
name: _BumpPeturb
second: 82.07547
data:
first:
name: _BumpPeturb2
second: .745283008
data:
first:
name: _bTwirl
second: .0500000007
data:
first:
name: _distort
second: .100000001
m_Colors:
data:
first:
name: _Color
second: {r: 0, g: 0, b: 0, a: 1}
data:
first:
name: _MainTex_ST
second: {r: 1, g: 1, b: 0, a: 0}
data:
first:
name: _SpecColor
second: {r: 0, g: 0, b: 0, a: .400000006}
data:
first:
name: _BumpMap_ST
second: {r: 1, g: 1, b: 0, a: 0}
data:
first:
name: WaveSpeed
second: {r: 9, g: 4.5, b: -8, a: -3.5}
data:
first:
name: _horizonColor
second: {r: 0, g: .125133663, b: .191176474, a: 0}
data:
first:
name: _ColorControl_ST
second: {r: 1, g: 1, b: 0, a: 0}
data:
first:
name: _ColorControlCube_ST
second: {r: 1, g: 1, b: 0, a: 0}
data:
first:
name: BumpParm
second: {r: 1, g: 1, b: 1, a: 1}
data:
first:
name: _EdgeColor
second: {r: 0, g: .100000001, b: 0, a: .100000001}
data:
first:
name: _RefTex_0
second: {r: -1517.37024, g: -23.9408531, b: -3154.91675, a: 2715.94165}
data:
first:
name: _RefTex_1
second: {r: 356.584351, g: -313.125671, b: -962.84906, a: 2791.50659}
data:
first:
name: _RefTex_2
second: {r: 4.95644999, g: -.187056601, b: -13.3834057, a: 20.1233597}
data:
first:
name: _RefTex_3
second: {r: 4.95595503, g: -.18703793, b: -13.3820696, a: 20.2213535}
data:
first:
name: horizonColor
second: {r: .61500001, g: .796000004, b: .875999987, a: 1}
data:
first:
name: uvParams
second: {r: 10, g: .0199999996, b: .0299999993, a: 0}
data:
first:
name: waveDirX
second: {r: -2.5, g: 0, b: 7, a: 8}
data:
first:
name: waveDirY
second: {r: 0, g: 1.5, b: -7, a: 1}
data:
first:
name: waveHeights
second: {r: .800000012, g: 1, b: .100000001, a: .0500000007}
data:
first:
name: _WaveSpeed
second: {r: 1, g: -1, b: -1, a: 1}
--- !u!1002 &2100001
EditorExtensionImpl:
serializedVersion: 6
@@ -0,0 +1,192 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 3
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: WaterBasicNighttime
m_Shader: {fileID: 4800000, guid: 9dccc8e8f0da4494991c26ef59019551, type: 3}
m_ShaderKeywords: []
m_CustomRenderQueue: -1
m_SavedProperties:
serializedVersion: 2
m_TexEnvs:
data:
first:
name: _MainTex
second:
m_Texture: {fileID: 2800000, guid: c2ef94ff9d11915d1100a04b44295342, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
data:
first:
name: _BumpMap
second:
m_Texture: {fileID: 2800000, guid: a53cf5449d11a15d1100a04b44295342, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
data:
first:
name: _ReflectionTex
second:
m_Texture: {fileID: 8400000, guid: 21bb33409d118354d000dcabe39e7c39, type: 2}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
data:
first:
name: _WavesTex
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
data:
first:
name: _ColorControlCube
second:
m_Texture: {fileID: 8900000, guid: 006a5f739d1105f6a000538a2aef8c59, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
data:
first:
name: _ColorControl
second:
m_Texture: {fileID: 2800000, guid: 8403d3349d112ba4d000be1be39e7c39, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
data:
first:
name: _BumpMap2
second:
m_Texture: {fileID: 2800000, guid: 279fb0a19d11d4a6d00051fa8d76c639, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
data:
first:
name: _ColorGradient
second:
m_Texture: {fileID: 2800000, guid: 8403d3349d112ba4d000be1be39e7c39, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
data:
first:
name: _Shininess
second: 1
data:
first:
name: _WaveScale
second: .0702830181
data:
first:
name: _Highlight
second: 33.2075462
data:
first:
name: _bScale
second: .0629245341
data:
first:
name: _BumpPeturb
second: 82.07547
data:
first:
name: _BumpPeturb2
second: .745283008
data:
first:
name: _bTwirl
second: .0500000007
data:
first:
name: _distort
second: .100000001
data:
first:
name: _BumpStrength
second: .100000001
m_Colors:
data:
first:
name: _Color
second: {r: .700785816, g: .481223762, b: .474296182, a: 1}
data:
first:
name: _MainTex_ST
second: {r: 1, g: 1, b: 0, a: 0}
data:
first:
name: _SpecColor
second: {r: 0, g: 0, b: 0, a: .400000006}
data:
first:
name: _BumpMap_ST
second: {r: 1, g: 1, b: 0, a: 0}
data:
first:
name: WaveSpeed
second: {r: 9.68770027, g: 4.81898165, b: -7.91322803, a: 2.87029743}
data:
first:
name: _horizonColor
second: {r: .148485541, g: .282429248, b: .379949659, a: 0}
data:
first:
name: _ColorControl_ST
second: {r: 1, g: 1, b: 0, a: 0}
data:
first:
name: _ColorControlCube_ST
second: {r: 1, g: 1, b: 0, a: 0}
data:
first:
name: BumpParm
second: {r: 1, g: 1, b: -1, a: -1}
data:
first:
name: _EdgeColor
second: {r: 0, g: .100000001, b: 0, a: .100000001}
data:
first:
name: _RefTex_0
second: {r: -1517.37024, g: -23.9408531, b: -3154.91675, a: 2715.94165}
data:
first:
name: _RefTex_1
second: {r: 356.584351, g: -313.125671, b: -962.84906, a: 2791.50659}
data:
first:
name: _RefTex_2
second: {r: 4.95644999, g: -.187056601, b: -13.3834057, a: 20.1233597}
data:
first:
name: _RefTex_3
second: {r: 4.95595503, g: -.18703793, b: -13.3820696, a: 20.2213535}
data:
first:
name: horizonColor
second: {r: .61500001, g: .796000004, b: .875999987, a: 1}
data:
first:
name: uvParams
second: {r: 10, g: .0199999996, b: .0299999993, a: 0}
data:
first:
name: waveDirX
second: {r: -2.5, g: 0, b: 7, a: 8}
data:
first:
name: waveDirY
second: {r: 0, g: 1.5, b: -7, a: 1}
data:
first:
name: waveHeights
second: {r: .800000012, g: 1, b: .100000001, a: .0500000007}
data:
first:
name: _WaveSpeed
second: {r: 1, g: -1, b: -1, a: 1}
--- !u!1002 &2100001
EditorExtensionImpl:
serializedVersion: 6
@@ -0,0 +1,31 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 3
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: WaterDefault
m_Shader: {fileID: 7, guid: 0000000000000000f000000000000000, type: 0}
m_ShaderKeywords: []
m_CustomRenderQueue: -1
m_SavedProperties:
serializedVersion: 2
m_TexEnvs:
data:
first:
name: _MainTex
second:
m_Texture: {fileID: 2800000, guid: c2ef94ff9d11915d1100a04b44295342, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats: {}
m_Colors:
data:
first:
name: _Color
second: {r: .5, g: .5, b: .5, a: 1}
--- !u!1002 &2100001
EditorExtensionImpl:
serializedVersion: 6
Binary file not shown.
@@ -0,0 +1,104 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &100000
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 4
m_Component:
- 4: {fileID: 400000}
- 33: {fileID: 3300000}
- 23: {fileID: 2300000}
- 114: {fileID: 11400000}
m_Layer: 4
m_Name: WaterBasicDaytime
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!1002 &100001
EditorExtensionImpl:
serializedVersion: 6
--- !u!4 &400000
Transform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 100000}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
--- !u!1002 &400001
EditorExtensionImpl:
serializedVersion: 6
--- !u!23 &2300000
MeshRenderer:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 100000}
m_Enabled: 1
m_CastShadows: 0
m_ReceiveShadows: 0
m_LightmapIndex: 255
m_LightmapIndexDynamic: 255
m_LightmapTilingOffset: {x: 1, y: 1, z: 0, w: 0}
m_LightmapTilingOffsetDynamic: {x: 1, y: 1, z: 0, w: 0}
m_Materials:
- {fileID: 2100000, guid: 52b7d70b1de7c4ce09662b77c14d9fda, type: 2}
m_SubsetIndices:
m_StaticBatchRoot: {fileID: 0}
m_UseLightProbes: 0
m_UseReflectionProbes: 1
m_ProbeAnchor: {fileID: 0}
m_ScaleInLightmap: 1
m_EnlightenSystemBuildParameters: {fileID: 0}
m_GIBackfaceCull: 0
m_SortingLayerID: 0
m_SortingOrder: 0
--- !u!1002 &2300001
EditorExtensionImpl:
serializedVersion: 6
--- !u!33 &3300000
MeshFilter:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 100000}
m_Mesh: {fileID: 4300008, guid: ce8d79c79d11b8f9d00076e98d76c639, type: 3}
--- !u!1002 &3300001
EditorExtensionImpl:
serializedVersion: 6
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 100000}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 0d2f50a8e0bb841a5aaa90ae55db8849, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1002 &11400001
EditorExtensionImpl:
serializedVersion: 6
--- !u!1001 &100100000
Prefab:
m_ObjectHideFlags: 1
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications: []
m_RemovedComponents: []
m_ParentPrefab: {fileID: 0}
m_RootGameObject: {fileID: 100000}
m_IsPrefabParent: 1
--- !u!1002 &100100001
EditorExtensionImpl:
serializedVersion: 6
@@ -0,0 +1,104 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &100000
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 4
m_Component:
- 4: {fileID: 400000}
- 33: {fileID: 3300000}
- 23: {fileID: 2300000}
- 114: {fileID: 11400000}
m_Layer: 4
m_Name: WaterBasicNightime
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!1002 &100001
EditorExtensionImpl:
serializedVersion: 6
--- !u!4 &400000
Transform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 100000}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -3.10330009, y: 10.3140001, z: -40.5900002}
m_LocalScale: {x: 16, y: 1, z: 16}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
--- !u!1002 &400001
EditorExtensionImpl:
serializedVersion: 6
--- !u!23 &2300000
MeshRenderer:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 100000}
m_Enabled: 1
m_CastShadows: 0
m_ReceiveShadows: 0
m_LightmapIndex: 255
m_LightmapIndexDynamic: 255
m_LightmapTilingOffset: {x: 1, y: 1, z: 0, w: 0}
m_LightmapTilingOffsetDynamic: {x: 1, y: 1, z: 0, w: 0}
m_Materials:
- {fileID: 2100000, guid: c55afdc4a8a3b4890b07cc7d176510bb, type: 2}
m_SubsetIndices:
m_StaticBatchRoot: {fileID: 0}
m_UseLightProbes: 0
m_UseReflectionProbes: 1
m_ProbeAnchor: {fileID: 0}
m_ScaleInLightmap: 1
m_EnlightenSystemBuildParameters: {fileID: 0}
m_GIBackfaceCull: 0
m_SortingLayerID: 0
m_SortingOrder: 0
--- !u!1002 &2300001
EditorExtensionImpl:
serializedVersion: 6
--- !u!33 &3300000
MeshFilter:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 100000}
m_Mesh: {fileID: 4300008, guid: ce8d79c79d11b8f9d00076e98d76c639, type: 3}
--- !u!1002 &3300001
EditorExtensionImpl:
serializedVersion: 6
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 100000}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 0d2f50a8e0bb841a5aaa90ae55db8849, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1002 &11400001
EditorExtensionImpl:
serializedVersion: 6
--- !u!1001 &100100000
Prefab:
m_ObjectHideFlags: 1
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications: []
m_RemovedComponents: []
m_ParentPrefab: {fileID: 0}
m_RootGameObject: {fileID: 100000}
m_IsPrefabParent: 1
--- !u!1002 &100100001
EditorExtensionImpl:
serializedVersion: 6
@@ -0,0 +1,32 @@
using System;
using UnityEngine;

namespace UnityStandardAssets.Water
{
[ExecuteInEditMode]
public class WaterBasic : MonoBehaviour
{
void Update()
{
Renderer r = GetComponent<Renderer>();
if (!r)
{
return;
}
Material mat = r.sharedMaterial;
if (!mat)
{
return;
}

Vector4 waveSpeed = mat.GetVector("WaveSpeed");
float waveScale = mat.GetFloat("_WaveScale");
float t = Time.time / 20.0f;

Vector4 offset4 = waveSpeed * (t * waveScale);
Vector4 offsetClamped = new Vector4(Mathf.Repeat(offset4.x, 1.0f), Mathf.Repeat(offset4.y, 1.0f),
Mathf.Repeat(offset4.z, 1.0f), Mathf.Repeat(offset4.w, 1.0f));
mat.SetVector("_WaveOffset", offsetClamped);
}
}
}
@@ -0,0 +1,90 @@
// Upgrade NOTE: replaced '_Object2World' with 'unity_ObjectToWorld'

Shader "FX/Water (Basic)" {
Properties {
_horizonColor ("Horizon color", COLOR) = ( .172 , .463 , .435 , 0)
_WaveScale ("Wave scale", Range (0.02,0.15)) = .07
[NoScaleOffset] _ColorControl ("Reflective color (RGB) fresnel (A) ", 2D) = "" { }
[NoScaleOffset] _BumpMap ("Waves Normalmap ", 2D) = "" { }
WaveSpeed ("Wave speed (map1 x,y; map2 x,y)", Vector) = (19,9,-16,-7)
}

CGINCLUDE

#include "UnityCG.cginc"

uniform float4 _horizonColor;

uniform float4 WaveSpeed;
uniform float _WaveScale;
uniform float4 _WaveOffset;

struct appdata {
float4 vertex : POSITION;
float3 normal : NORMAL;
};

struct v2f {
float4 pos : SV_POSITION;
float2 bumpuv[2] : TEXCOORD0;
float3 viewDir : TEXCOORD2;
UNITY_FOG_COORDS(3)
};

v2f vert(appdata v)
{
v2f o;
float4 s;

o.pos = mul (UNITY_MATRIX_MVP, v.vertex);

// scroll bump waves
float4 temp;
float4 wpos = mul (unity_ObjectToWorld, v.vertex);
temp.xyzw = wpos.xzxz * _WaveScale + _WaveOffset;
o.bumpuv[0] = temp.xy * float2(.4, .45);
o.bumpuv[1] = temp.wz;

// object space view direction
o.viewDir.xzy = normalize( WorldSpaceViewDir(v.vertex) );

UNITY_TRANSFER_FOG(o,o.pos);
return o;
}

ENDCG


Subshader {
Tags { "RenderType"="Opaque" }
Pass {

CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile_fog

sampler2D _BumpMap;
sampler2D _ColorControl;

half4 frag( v2f i ) : COLOR
{
half3 bump1 = UnpackNormal(tex2D( _BumpMap, i.bumpuv[0] )).rgb;
half3 bump2 = UnpackNormal(tex2D( _BumpMap, i.bumpuv[1] )).rgb;
half3 bump = (bump1 + bump2) * 0.5;

half fresnel = dot( i.viewDir, bump );
half4 water = tex2D( _ColorControl, float2(fresnel,fresnel) );

half4 col;
col.rgb = lerp( water.rgb, _horizonColor.rgb, water.a );
col.a = _horizonColor.a;

UNITY_APPLY_FOG(i.fogCoord, col);
return col;
}
ENDCG
}
}

}
Binary file not shown.
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,154 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 3
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: WaterPlaneMaterial
m_Shader: {fileID: 45, guid: 0000000000000000f000000000000000, type: 0}
m_ShaderKeywords:
- _LIGHTMAPPING_STATIC_LIGHTMAPS
- _UVSEC_UV1
m_CustomRenderQueue: -1
m_SavedProperties:
serializedVersion: 2
m_TexEnvs:
data:
first:
name: _MainTex
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
data:
first:
name: _BumpMap
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
data:
first:
name: _EmissionMap
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
data:
first:
name: _ParallaxMap
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
data:
first:
name: _Occlusion
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
data:
first:
name: _SpecGlossMap
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
data:
first:
name: _DetailMask
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
data:
first:
name: _DetailAlbedoMap
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
data:
first:
name: _DetailNormalMap
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
data:
first:
name: _Lightmapping
second: 0
data:
first:
name: _SrcBlend
second: 1
data:
first:
name: _DstBlend
second: 0
data:
first:
name: _Parallax
second: .0199999996
data:
first:
name: _ZWrite
second: 1
data:
first:
name: _AlphaTestRef
second: .5
data:
first:
name: _Glossiness
second: 0
data:
first:
name: _BumpScale
second: 1
data:
first:
name: _OcclusionStrength
second: 1
data:
first:
name: _DetailNormalMapScale
second: 1
data:
first:
name: _UVSec
second: 0
data:
first:
name: _Mode
second: 0
data:
first:
name: _EmissionScaleUI
second: 1
m_Colors:
data:
first:
name: _Color
second: {r: .5, g: .5, b: .5, a: 1}
data:
first:
name: _EmissionColor
second: {r: 0, g: 0, b: 0, a: 1}
data:
first:
name: _SpecularColor
second: {r: .200000003, g: .200000003, b: .200000003, a: 1}
data:
first:
name: _EmissionColorUI
second: {r: 0, g: 0, b: 0, a: 1}
data:
first:
name: _EmissionColorWithMapUI
second: {r: 1, g: 1, b: 1, a: 1}
@@ -0,0 +1,121 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 3
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: WaterProDaytime
m_Shader: {fileID: 4800000, guid: 1cac2e0bcc34e4b3cbb4bd85982eba83, type: 3}
m_ShaderKeywords: []
m_CustomRenderQueue: -1
m_SavedProperties:
serializedVersion: 2
m_TexEnvs:
data:
first:
name: _MainTex
second:
m_Texture: {fileID: 2800000, guid: e6f8288974c664a309d6c66de636978c, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
data:
first:
name: _BumpMap
second:
m_Texture: {fileID: 2800000, guid: 2dd3788f8589b40bf82a92d76ffc5091, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
data:
first:
name: _Fresnel
second:
m_Texture: {fileID: 2800000, guid: 5b5c5575fd4c74abd9f7b30862fb76a3, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
data:
first:
name: _ReflectiveColor
second:
m_Texture: {fileID: 2800000, guid: ab97f9ab7c2ce724ebc9446060a819a4, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
data:
first:
name: _ReflectionTex
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
data:
first:
name: _RefractionTex
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
data:
first:
name: _ReflectiveColorCube
second:
m_Texture: {fileID: 8900000, guid: 9cda328e4b6954d70841a8a66f42ec08, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
data:
first:
name: _WaveScale
second: .118000001
data:
first:
name: _ReflDistort
second: .439999998
data:
first:
name: _RefrDistort
second: .400000006
m_Colors:
data:
first:
name: _RefrColor
second: {r: .937254906, g: .937254906, b: .937254906, a: 1}
data:
first:
name: _Fresnel_ST
second: {r: 1, g: 1, b: 0, a: 0}
data:
first:
name: _BumpMap_ST
second: {r: 1, g: 1, b: 0, a: 0}
data:
first:
name: WaveSpeed
second: {r: 9, g: 4.5, b: -8, a: -3.5}
data:
first:
name: _ReflectiveColor_ST
second: {r: 1, g: 1, b: 0, a: 0}
data:
first:
name: _HorizonColor
second: {r: .135759518, g: .228107125, b: .381078809, a: 0}
data:
first:
name: _ReflectionTex_ST
second: {r: 1, g: 1, b: 0, a: 0}
data:
first:
name: _RefractionTex_ST
second: {r: 1, g: 1, b: 0, a: 0}
data:
first:
name: _MainTex_ST
second: {r: 1, g: 1, b: 0, a: 0}
data:
first:
name: _ReflectiveColorCube_ST
second: {r: 1, g: 1, b: 0, a: 0}
--- !u!1002 &2100001
EditorExtensionImpl:
serializedVersion: 6
@@ -0,0 +1,125 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 3
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: WaterProNighttime
m_Shader: {fileID: 4800000, guid: 1cac2e0bcc34e4b3cbb4bd85982eba83, type: 3}
m_ShaderKeywords: []
m_CustomRenderQueue: -1
m_SavedProperties:
serializedVersion: 2
m_TexEnvs:
data:
first:
name: _MainTex
second:
m_Texture: {fileID: 2800000, guid: e6f8288974c664a309d6c66de636978c, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
data:
first:
name: _BumpMap
second:
m_Texture: {fileID: 2800000, guid: 2dd3788f8589b40bf82a92d76ffc5091, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
data:
first:
name: _Fresnel
second:
m_Texture: {fileID: 2800000, guid: 5b5c5575fd4c74abd9f7b30862fb76a3, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
data:
first:
name: _ReflectiveColor
second:
m_Texture: {fileID: 2800000, guid: b725b62cfc9d04e4886735ab2a8107d1, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
data:
first:
name: _ReflectionTex
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
data:
first:
name: _RefractionTex
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
data:
first:
name: _ReflectiveColorCube
second:
m_Texture: {fileID: 8900000, guid: 15c6acc4f11254a04b03849245d80574, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
data:
first:
name: _WaveScale
second: .063000001
data:
first:
name: _ReflDistort
second: .439999998
data:
first:
name: _RefrDistort
second: .400000006
m_Colors:
data:
first:
name: _Color
second: {r: 1, g: 1, b: 1, a: 1}
data:
first:
name: _RefrColor
second: {r: 1, g: 1, b: 1, a: 1}
data:
first:
name: _Fresnel_ST
second: {r: 1, g: 1, b: 0, a: 0}
data:
first:
name: _BumpMap_ST
second: {r: 1, g: 1, b: 0, a: 0}
data:
first:
name: WaveSpeed
second: {r: 9, g: 4.5, b: -8, a: -3.5}
data:
first:
name: _ReflectiveColor_ST
second: {r: 1, g: 1, b: 0, a: 0}
data:
first:
name: _HorizonColor
second: {r: .149019614, g: .282352954, b: .380392164, a: 0}
data:
first:
name: _ReflectionTex_ST
second: {r: 1, g: 1, b: 0, a: 0}
data:
first:
name: _RefractionTex_ST
second: {r: 1, g: 1, b: 0, a: 0}
data:
first:
name: _MainTex_ST
second: {r: 1, g: 1, b: 0, a: 0}
data:
first:
name: _ReflectiveColorCube_ST
second: {r: 1, g: 1, b: 0, a: 0}
--- !u!1002 &2100001
EditorExtensionImpl:
serializedVersion: 6
Binary file not shown.
@@ -0,0 +1,114 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &100000
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 4
m_Component:
- 4: {fileID: 400000}
- 33: {fileID: 3300000}
- 23: {fileID: 2300000}
- 114: {fileID: 11400000}
m_Layer: 4
m_Name: WaterProDaytime
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!1002 &100001
EditorExtensionImpl:
serializedVersion: 6
--- !u!4 &400000
Transform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 100000}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 16, y: 1, z: 16}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
--- !u!1002 &400001
EditorExtensionImpl:
serializedVersion: 6
--- !u!23 &2300000
MeshRenderer:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 100000}
m_Enabled: 1
m_CastShadows: 0
m_ReceiveShadows: 0
m_LightmapIndex: 255
m_LightmapIndexDynamic: 255
m_LightmapTilingOffset: {x: 1, y: 1, z: 0, w: 0}
m_LightmapTilingOffsetDynamic: {x: 1, y: 1, z: 0, w: 0}
m_Materials:
- {fileID: 2100000, guid: 7350b65a6431f604a8496c39db1ac9c5, type: 2}
m_SubsetIndices:
m_StaticBatchRoot: {fileID: 0}
m_UseLightProbes: 1
m_UseReflectionProbes: 1
m_ProbeAnchor: {fileID: 0}
m_ScaleInLightmap: 1
m_EnlightenSystemBuildParameters: {fileID: 0}
m_GIBackfaceCull: 0
m_SortingLayerID: 0
m_SortingOrder: 0
--- !u!1002 &2300001
EditorExtensionImpl:
serializedVersion: 6
--- !u!33 &3300000
MeshFilter:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 100000}
m_Mesh: {fileID: 4300006, guid: ba6a41dc489914734857bb5924eb70ad, type: 3}
--- !u!1002 &3300001
EditorExtensionImpl:
serializedVersion: 6
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 100000}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: a3d3ef1a5bbfb4e0a910fbbe5830b1f9, type: 3}
m_Name:
m_EditorClassIdentifier:
m_WaterMode: 2
m_DisablePixelLights: 1
m_TextureSize: 256
m_ClipPlaneOffset: .0700000003
m_ReflectLayers:
serializedVersion: 2
m_Bits: 4294967295
m_RefractLayers:
serializedVersion: 2
m_Bits: 4294967295
--- !u!1002 &11400001
EditorExtensionImpl:
serializedVersion: 6
--- !u!1001 &100100000
Prefab:
m_ObjectHideFlags: 1
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications: []
m_RemovedComponents: []
m_ParentPrefab: {fileID: 0}
m_RootGameObject: {fileID: 100000}
m_IsPrefabParent: 1
--- !u!1002 &100100001
EditorExtensionImpl:
serializedVersion: 6
@@ -0,0 +1,114 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &100000
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 4
m_Component:
- 4: {fileID: 400000}
- 33: {fileID: 3300000}
- 23: {fileID: 2300000}
- 114: {fileID: 11400000}
m_Layer: 4
m_Name: WaterProNighttime
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!1002 &100001
EditorExtensionImpl:
serializedVersion: 6
--- !u!4 &400000
Transform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 100000}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 16, y: 1, z: 16}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
--- !u!1002 &400001
EditorExtensionImpl:
serializedVersion: 6
--- !u!23 &2300000
MeshRenderer:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 100000}
m_Enabled: 1
m_CastShadows: 0
m_ReceiveShadows: 0
m_LightmapIndex: 255
m_LightmapIndexDynamic: 255
m_LightmapTilingOffset: {x: 1, y: 1, z: 0, w: 0}
m_LightmapTilingOffsetDynamic: {x: 1, y: 1, z: 0, w: 0}
m_Materials:
- {fileID: 2100000, guid: e633a20421c47426aa04444234225b69, type: 2}
m_SubsetIndices:
m_StaticBatchRoot: {fileID: 0}
m_UseLightProbes: 1
m_UseReflectionProbes: 1
m_ProbeAnchor: {fileID: 0}
m_ScaleInLightmap: 1
m_EnlightenSystemBuildParameters: {fileID: 0}
m_GIBackfaceCull: 0
m_SortingLayerID: 0
m_SortingOrder: 0
--- !u!1002 &2300001
EditorExtensionImpl:
serializedVersion: 6
--- !u!33 &3300000
MeshFilter:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 100000}
m_Mesh: {fileID: 4300006, guid: ba6a41dc489914734857bb5924eb70ad, type: 3}
--- !u!1002 &3300001
EditorExtensionImpl:
serializedVersion: 6
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 100000}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: a3d3ef1a5bbfb4e0a910fbbe5830b1f9, type: 3}
m_Name:
m_EditorClassIdentifier:
m_WaterMode: 2
m_DisablePixelLights: 1
m_TextureSize: 256
m_ClipPlaneOffset: .0700000003
m_ReflectLayers:
serializedVersion: 2
m_Bits: 4294967295
m_RefractLayers:
serializedVersion: 2
m_Bits: 4294967295
--- !u!1002 &11400001
EditorExtensionImpl:
serializedVersion: 6
--- !u!1001 &100100000
Prefab:
m_ObjectHideFlags: 1
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications: []
m_RemovedComponents: []
m_ParentPrefab: {fileID: 0}
m_RootGameObject: {fileID: 100000}
m_IsPrefabParent: 1
--- !u!1002 &100100001
EditorExtensionImpl:
serializedVersion: 6
@@ -0,0 +1,36 @@
using System;
using UnityEngine;

namespace UnityStandardAssets.Water
{
[ExecuteInEditMode]
[RequireComponent(typeof(WaterBase))]
public class Displace : MonoBehaviour
{
public void Awake()
{
if (enabled)
{
OnEnable();
}
else
{
OnDisable();
}
}


public void OnEnable()
{
Shader.EnableKeyword("WATER_VERTEX_DISPLACEMENT_ON");
Shader.DisableKeyword("WATER_VERTEX_DISPLACEMENT_OFF");
}


public void OnDisable()
{
Shader.EnableKeyword("WATER_VERTEX_DISPLACEMENT_OFF");
Shader.DisableKeyword("WATER_VERTEX_DISPLACEMENT_ON");
}
}
}
@@ -0,0 +1,9 @@
using System;
using UnityEngine;

namespace UnityStandardAssets.Water
{
[ExecuteInEditMode]
[RequireComponent(typeof(WaterBase))]
public class GerstnerDisplace : Displace { }
}
@@ -0,0 +1,27 @@
using System;
using UnityEngine;

namespace UnityStandardAssets.Water
{
public class MeshContainer
{
public Mesh mesh;
public Vector3[] vertices;
public Vector3[] normals;


public MeshContainer(Mesh m)
{
mesh = m;
vertices = m.vertices;
normals = m.normals;
}


public void Update()
{
mesh.vertices = vertices;
mesh.normals = normals;
}
}
}
@@ -0,0 +1,284 @@
using System;
using System.Collections.Generic;
using UnityEngine;

namespace UnityStandardAssets.Water
{
[ExecuteInEditMode]
[RequireComponent(typeof(WaterBase))]
public class PlanarReflection : MonoBehaviour
{
public LayerMask reflectionMask;
public bool reflectSkybox = false;
public Color clearColor = Color.grey;
public String reflectionSampler = "_ReflectionTex";
public float clipPlaneOffset = 0.07F;


Vector3 m_Oldpos;
Camera m_ReflectionCamera;
Material m_SharedMaterial;
Dictionary<Camera, bool> m_HelperCameras;


public void Start()
{
m_SharedMaterial = ((WaterBase)gameObject.GetComponent(typeof(WaterBase))).sharedMaterial;
}


Camera CreateReflectionCameraFor(Camera cam)
{
String reflName = gameObject.name + "Reflection" + cam.name;
GameObject go = GameObject.Find(reflName);

if (!go)
{
go = new GameObject(reflName, typeof(Camera));
}
if (!go.GetComponent(typeof(Camera)))
{
go.AddComponent(typeof(Camera));
}
Camera reflectCamera = go.GetComponent<Camera>();

reflectCamera.backgroundColor = clearColor;
reflectCamera.clearFlags = reflectSkybox ? CameraClearFlags.Skybox : CameraClearFlags.SolidColor;

SetStandardCameraParameter(reflectCamera, reflectionMask);

if (!reflectCamera.targetTexture)
{
reflectCamera.targetTexture = CreateTextureFor(cam);
}

return reflectCamera;
}


void SetStandardCameraParameter(Camera cam, LayerMask mask)
{
cam.cullingMask = mask & ~(1 << LayerMask.NameToLayer("Water"));
cam.backgroundColor = Color.black;
cam.enabled = false;
}


RenderTexture CreateTextureFor(Camera cam)
{
RenderTexture rt = new RenderTexture(Mathf.FloorToInt(cam.pixelWidth * 0.5F),
Mathf.FloorToInt(cam.pixelHeight * 0.5F), 24);
rt.hideFlags = HideFlags.DontSave;
return rt;
}


public void RenderHelpCameras(Camera currentCam)
{
if (null == m_HelperCameras)
{
m_HelperCameras = new Dictionary<Camera, bool>();
}

if (!m_HelperCameras.ContainsKey(currentCam))
{
m_HelperCameras.Add(currentCam, false);
}
if (m_HelperCameras[currentCam])
{
return;
}

if (!m_ReflectionCamera)
{
m_ReflectionCamera = CreateReflectionCameraFor(currentCam);
}

RenderReflectionFor(currentCam, m_ReflectionCamera);

m_HelperCameras[currentCam] = true;
}


public void LateUpdate()
{
if (null != m_HelperCameras)
{
m_HelperCameras.Clear();
}
}


public void WaterTileBeingRendered(Transform tr, Camera currentCam)
{
RenderHelpCameras(currentCam);

if (m_ReflectionCamera && m_SharedMaterial)
{
m_SharedMaterial.SetTexture(reflectionSampler, m_ReflectionCamera.targetTexture);
}
}


public void OnEnable()
{
Shader.EnableKeyword("WATER_REFLECTIVE");
Shader.DisableKeyword("WATER_SIMPLE");
}


public void OnDisable()
{
Shader.EnableKeyword("WATER_SIMPLE");
Shader.DisableKeyword("WATER_REFLECTIVE");
}


void RenderReflectionFor(Camera cam, Camera reflectCamera)
{
if (!reflectCamera)
{
return;
}

if (m_SharedMaterial && !m_SharedMaterial.HasProperty(reflectionSampler))
{
return;
}

reflectCamera.cullingMask = reflectionMask & ~(1 << LayerMask.NameToLayer("Water"));

SaneCameraSettings(reflectCamera);

reflectCamera.backgroundColor = clearColor;
reflectCamera.clearFlags = reflectSkybox ? CameraClearFlags.Skybox : CameraClearFlags.SolidColor;
if (reflectSkybox)
{
if (cam.gameObject.GetComponent(typeof(Skybox)))
{
Skybox sb = (Skybox)reflectCamera.gameObject.GetComponent(typeof(Skybox));
if (!sb)
{
sb = (Skybox)reflectCamera.gameObject.AddComponent(typeof(Skybox));
}
sb.material = ((Skybox)cam.GetComponent(typeof(Skybox))).material;
}
}

GL.invertCulling = true;

Transform reflectiveSurface = transform; //waterHeight;

Vector3 eulerA = cam.transform.eulerAngles;

reflectCamera.transform.eulerAngles = new Vector3(-eulerA.x, eulerA.y, eulerA.z);
reflectCamera.transform.position = cam.transform.position;

Vector3 pos = reflectiveSurface.transform.position;
pos.y = reflectiveSurface.position.y;
Vector3 normal = reflectiveSurface.transform.up;
float d = -Vector3.Dot(normal, pos) - clipPlaneOffset;
Vector4 reflectionPlane = new Vector4(normal.x, normal.y, normal.z, d);

Matrix4x4 reflection = Matrix4x4.zero;
reflection = CalculateReflectionMatrix(reflection, reflectionPlane);
m_Oldpos = cam.transform.position;
Vector3 newpos = reflection.MultiplyPoint(m_Oldpos);

reflectCamera.worldToCameraMatrix = cam.worldToCameraMatrix * reflection;

Vector4 clipPlane = CameraSpacePlane(reflectCamera, pos, normal, 1.0f);

Matrix4x4 projection = cam.projectionMatrix;
projection = CalculateObliqueMatrix(projection, clipPlane);
reflectCamera.projectionMatrix = projection;

reflectCamera.transform.position = newpos;
Vector3 euler = cam.transform.eulerAngles;
reflectCamera.transform.eulerAngles = new Vector3(-euler.x, euler.y, euler.z);

reflectCamera.Render();

GL.invertCulling = false;
}


void SaneCameraSettings(Camera helperCam)
{
helperCam.depthTextureMode = DepthTextureMode.None;
helperCam.backgroundColor = Color.black;
helperCam.clearFlags = CameraClearFlags.SolidColor;
helperCam.renderingPath = RenderingPath.Forward;
}


static Matrix4x4 CalculateObliqueMatrix(Matrix4x4 projection, Vector4 clipPlane)
{
Vector4 q = projection.inverse * new Vector4(
Sgn(clipPlane.x),
Sgn(clipPlane.y),
1.0F,
1.0F
);
Vector4 c = clipPlane * (2.0F / (Vector4.Dot(clipPlane, q)));
// third row = clip plane - fourth row
projection[2] = c.x - projection[3];
projection[6] = c.y - projection[7];
projection[10] = c.z - projection[11];
projection[14] = c.w - projection[15];

return projection;
}


static Matrix4x4 CalculateReflectionMatrix(Matrix4x4 reflectionMat, Vector4 plane)
{
reflectionMat.m00 = (1.0F - 2.0F * plane[0] * plane[0]);
reflectionMat.m01 = (- 2.0F * plane[0] * plane[1]);
reflectionMat.m02 = (- 2.0F * plane[0] * plane[2]);
reflectionMat.m03 = (- 2.0F * plane[3] * plane[0]);

reflectionMat.m10 = (- 2.0F * plane[1] * plane[0]);
reflectionMat.m11 = (1.0F - 2.0F * plane[1] * plane[1]);
reflectionMat.m12 = (- 2.0F * plane[1] * plane[2]);
reflectionMat.m13 = (- 2.0F * plane[3] * plane[1]);

reflectionMat.m20 = (- 2.0F * plane[2] * plane[0]);
reflectionMat.m21 = (- 2.0F * plane[2] * plane[1]);
reflectionMat.m22 = (1.0F - 2.0F * plane[2] * plane[2]);
reflectionMat.m23 = (- 2.0F * plane[3] * plane[2]);

reflectionMat.m30 = 0.0F;
reflectionMat.m31 = 0.0F;
reflectionMat.m32 = 0.0F;
reflectionMat.m33 = 1.0F;

return reflectionMat;
}


static float Sgn(float a)
{
if (a > 0.0F)
{
return 1.0F;
}
if (a < 0.0F)
{
return -1.0F;
}
return 0.0F;
}


Vector4 CameraSpacePlane(Camera cam, Vector3 pos, Vector3 normal, float sideSign)
{
Vector3 offsetPos = pos + normal * clipPlaneOffset;
Matrix4x4 m = cam.worldToCameraMatrix;
Vector3 cpos = m.MultiplyPoint(offsetPos);
Vector3 cnormal = m.MultiplyVector(normal).normalized * sideSign;

return new Vector4(cnormal.x, cnormal.y, cnormal.z, -Vector3.Dot(cpos, cnormal));
}
}
}