@ -0,0 +1,38 @@ | |||
using UnityEngine; | |||
public static class Bezier { | |||
public static Vector3 GetPoint (Vector3 p0, Vector3 p1, Vector3 p2, float t) { | |||
t = Mathf.Clamp01(t); | |||
float oneMinusT = 1f - t; | |||
return | |||
oneMinusT * oneMinusT * p0 + | |||
2f * oneMinusT * t * p1 + | |||
t * t * p2; | |||
} | |||
public static Vector3 GetFirstDerivative (Vector3 p0, Vector3 p1, Vector3 p2, float t) { | |||
return | |||
2f * (1f - t) * (p1 - p0) + | |||
2f * t * (p2 - p1); | |||
} | |||
public static Vector3 GetPoint (Vector3 p0, Vector3 p1, Vector3 p2, Vector3 p3, float t) { | |||
t = Mathf.Clamp01(t); | |||
float OneMinusT = 1f - t; | |||
return | |||
OneMinusT * OneMinusT * OneMinusT * p0 + | |||
3f * OneMinusT * OneMinusT * t * p1 + | |||
3f * OneMinusT * t * t * p2 + | |||
t * t * t * p3; | |||
} | |||
public static Vector3 GetFirstDerivative (Vector3 p0, Vector3 p1, Vector3 p2, Vector3 p3, float t) { | |||
t = Mathf.Clamp01(t); | |||
float oneMinusT = 1f - t; | |||
return | |||
3f * oneMinusT * oneMinusT * (p1 - p0) + | |||
6f * oneMinusT * t * (p2 - p1) + | |||
3f * t * t * (p3 - p2); | |||
} | |||
} |
@ -0,0 +1,11 @@ | |||
fileFormatVersion: 2 | |||
guid: 2b14b8c3e9cc04a13898e1e50c9f1024 | |||
timeCreated: 18446744011573954816 | |||
MonoImporter: | |||
serializedVersion: 2 | |||
defaultReferences: [] | |||
executionOrder: 0 | |||
icon: {instanceID: 0} | |||
userData: | |||
assetBundleName: | |||
assetBundleVariant: |
@ -0,0 +1,5 @@ | |||
public enum BezierControlPointMode { | |||
Free, | |||
Aligned, | |||
Mirrored | |||
} |
@ -0,0 +1,11 @@ | |||
fileFormatVersion: 2 | |||
guid: 1c78ec24cea4e478bb35a5ce401fa7a6 | |||
timeCreated: 18446744011573954816 | |||
MonoImporter: | |||
serializedVersion: 2 | |||
defaultReferences: [] | |||
executionOrder: 0 | |||
icon: {instanceID: 0} | |||
userData: | |||
assetBundleName: | |||
assetBundleVariant: |
@ -0,0 +1,27 @@ | |||
using UnityEngine; | |||
public class BezierCurve : MonoBehaviour { | |||
public Vector3[] points; | |||
public Vector3 GetPoint (float t) { | |||
return transform.TransformPoint(Bezier.GetPoint(points[0], points[1], points[2], points[3], t)); | |||
} | |||
public Vector3 GetVelocity (float t) { | |||
return transform.TransformPoint(Bezier.GetFirstDerivative(points[0], points[1], points[2], points[3], t)) - transform.position; | |||
} | |||
public Vector3 GetDirection (float t) { | |||
return GetVelocity(t).normalized; | |||
} | |||
public void Reset () { | |||
points = new Vector3[] { | |||
new Vector3(1f, 0f, 0f), | |||
new Vector3(2f, 0f, 0f), | |||
new Vector3(3f, 0f, 0f), | |||
new Vector3(4f, 0f, 0f) | |||
}; | |||
} | |||
} |
@ -0,0 +1,11 @@ | |||
fileFormatVersion: 2 | |||
guid: b7b6b4e22427e4efbb847bd026324e59 | |||
timeCreated: 18446744011573954816 | |||
MonoImporter: | |||
serializedVersion: 2 | |||
defaultReferences: [] | |||
executionOrder: 0 | |||
icon: {instanceID: 0} | |||
userData: | |||
assetBundleName: | |||
assetBundleVariant: |
@ -0,0 +1,199 @@ | |||
using UnityEngine; | |||
using System; | |||
public class BezierSpline : MonoBehaviour { | |||
[SerializeField] | |||
private Vector3[] points; | |||
[SerializeField] | |||
private BezierControlPointMode[] modes; | |||
[SerializeField] | |||
private bool loop; | |||
public bool Loop { | |||
get { | |||
return loop; | |||
} | |||
set { | |||
loop = value; | |||
if (value == true) { | |||
modes[modes.Length - 1] = modes[0]; | |||
SetControlPoint(0, points[0]); | |||
} | |||
} | |||
} | |||
public int ControlPointCount { | |||
get { | |||
return points.Length; | |||
} | |||
} | |||
public Vector3 GetControlPoint (int index) { | |||
return points[index]; | |||
} | |||
public void SetControlPoint (int index, Vector3 point) { | |||
if (index % 3 == 0) { | |||
Vector3 delta = point - points[index]; | |||
if (loop) { | |||
if (index == 0) { | |||
points[1] += delta; | |||
points[points.Length - 2] += delta; | |||
points[points.Length - 1] = point; | |||
} | |||
else if (index == points.Length - 1) { | |||
points[0] = point; | |||
points[1] += delta; | |||
points[index - 1] += delta; | |||
} | |||
else { | |||
points[index - 1] += delta; | |||
points[index + 1] += delta; | |||
} | |||
} | |||
else { | |||
if (index > 0) { | |||
points[index - 1] += delta; | |||
} | |||
if (index + 1 < points.Length) { | |||
points[index + 1] += delta; | |||
} | |||
} | |||
} | |||
points[index] = point; | |||
EnforceMode(index); | |||
} | |||
public BezierControlPointMode GetControlPointMode (int index) { | |||
return modes[(index + 1) / 3]; | |||
} | |||
public void SetControlPointMode (int index, BezierControlPointMode mode) { | |||
int modeIndex = (index + 1) / 3; | |||
modes[modeIndex] = mode; | |||
if (loop) { | |||
if (modeIndex == 0) { | |||
modes[modes.Length - 1] = mode; | |||
} | |||
else if (modeIndex == modes.Length - 1) { | |||
modes[0] = mode; | |||
} | |||
} | |||
EnforceMode(index); | |||
} | |||
private void EnforceMode (int index) { | |||
int modeIndex = (index + 1) / 3; | |||
BezierControlPointMode mode = modes[modeIndex]; | |||
if (mode == BezierControlPointMode.Free || !loop && (modeIndex == 0 || modeIndex == modes.Length - 1)) { | |||
return; | |||
} | |||
int middleIndex = modeIndex * 3; | |||
int fixedIndex, enforcedIndex; | |||
if (index <= middleIndex) { | |||
fixedIndex = middleIndex - 1; | |||
if (fixedIndex < 0) { | |||
fixedIndex = points.Length - 2; | |||
} | |||
enforcedIndex = middleIndex + 1; | |||
if (enforcedIndex >= points.Length) { | |||
enforcedIndex = 1; | |||
} | |||
} | |||
else { | |||
fixedIndex = middleIndex + 1; | |||
if (fixedIndex >= points.Length) { | |||
fixedIndex = 1; | |||
} | |||
enforcedIndex = middleIndex - 1; | |||
if (enforcedIndex < 0) { | |||
enforcedIndex = points.Length - 2; | |||
} | |||
} | |||
Vector3 middle = points[middleIndex]; | |||
Vector3 enforcedTangent = middle - points[fixedIndex]; | |||
if (mode == BezierControlPointMode.Aligned) { | |||
enforcedTangent = enforcedTangent.normalized * Vector3.Distance(middle, points[enforcedIndex]); | |||
} | |||
points[enforcedIndex] = middle + enforcedTangent; | |||
} | |||
public int CurveCount { | |||
get { | |||
return (points.Length - 1) / 3; | |||
} | |||
} | |||
public Vector3 GetPoint (float t) { | |||
int i; | |||
if (t >= 1f) { | |||
t = 1f; | |||
i = points.Length - 4; | |||
} | |||
else { | |||
t = Mathf.Clamp01(t) * CurveCount; | |||
i = (int)t; | |||
t -= i; | |||
i *= 3; | |||
} | |||
return transform.TransformPoint(Bezier.GetPoint(points[i], points[i + 1], points[i + 2], points[i + 3], t)); | |||
} | |||
public Vector3 GetVelocity (float t) { | |||
int i; | |||
if (t >= 1f) { | |||
t = 1f; | |||
i = points.Length - 4; | |||
} | |||
else { | |||
t = Mathf.Clamp01(t) * CurveCount; | |||
i = (int)t; | |||
t -= i; | |||
i *= 3; | |||
} | |||
return transform.TransformPoint(Bezier.GetFirstDerivative(points[i], points[i + 1], points[i + 2], points[i + 3], t)) - transform.position; | |||
} | |||
public Vector3 GetDirection (float t) { | |||
return GetVelocity(t).normalized; | |||
} | |||
public void AddCurve () { | |||
Vector3 point = points[points.Length - 1]; | |||
Array.Resize(ref points, points.Length + 3); | |||
point.x += 1f; | |||
points[points.Length - 3] = point; | |||
point.x += 1f; | |||
points[points.Length - 2] = point; | |||
point.x += 1f; | |||
points[points.Length - 1] = point; | |||
Array.Resize(ref modes, modes.Length + 1); | |||
modes[modes.Length - 1] = modes[modes.Length - 2]; | |||
EnforceMode(points.Length - 4); | |||
if (loop) { | |||
points[points.Length - 1] = points[0]; | |||
modes[modes.Length - 1] = modes[0]; | |||
EnforceMode(0); | |||
} | |||
} | |||
public void Reset () { | |||
points = new Vector3[] { | |||
new Vector3(1f, 0f, 0f), | |||
new Vector3(2f, 0f, 0f), | |||
new Vector3(3f, 0f, 0f), | |||
new Vector3(4f, 0f, 0f) | |||
}; | |||
modes = new BezierControlPointMode[] { | |||
BezierControlPointMode.Free, | |||
BezierControlPointMode.Free | |||
}; | |||
} | |||
} |
@ -0,0 +1,11 @@ | |||
fileFormatVersion: 2 | |||
guid: b154883273c2845f39445c8015d81639 | |||
timeCreated: 18446744011573954816 | |||
MonoImporter: | |||
serializedVersion: 2 | |||
defaultReferences: [] | |||
executionOrder: 0 | |||
icon: {instanceID: 0} | |||
userData: | |||
assetBundleName: | |||
assetBundleVariant: |
@ -1,5 +1,5 @@ | |||
fileFormatVersion: 2 | |||
guid: f87a054963b01dc4c8aa2e3ffedcca21 | |||
guid: 34a683cb629c49e41b1859f0f3dc797a | |||
folderAsset: yes | |||
DefaultImporter: | |||
externalObjects: {} |
@ -0,0 +1,54 @@ | |||
using UnityEditor; | |||
using UnityEngine; | |||
[CustomEditor(typeof(BezierCurve))] | |||
public class BezierCurveInspector : Editor { | |||
private const int lineSteps = 10; | |||
private const float directionScale = 0.5f; | |||
private BezierCurve curve; | |||
private Transform handleTransform; | |||
private Quaternion handleRotation; | |||
private void OnSceneGUI () { | |||
curve = target as BezierCurve; | |||
handleTransform = curve.transform; | |||
handleRotation = Tools.pivotRotation == PivotRotation.Local ? | |||
handleTransform.rotation : Quaternion.identity; | |||
Vector3 p0 = ShowPoint(0); | |||
Vector3 p1 = ShowPoint(1); | |||
Vector3 p2 = ShowPoint(2); | |||
Vector3 p3 = ShowPoint(3); | |||
Handles.color = Color.gray; | |||
Handles.DrawLine(p0, p1); | |||
Handles.DrawLine(p2, p3); | |||
ShowDirections(); | |||
Handles.DrawBezier(p0, p3, p1, p2, Color.white, null, 2f); | |||
} | |||
private void ShowDirections () { | |||
Handles.color = Color.green; | |||
Vector3 point = curve.GetPoint(0f); | |||
Handles.DrawLine(point, point + curve.GetDirection(0f) * directionScale); | |||
for (int i = 1; i <= lineSteps; i++) { | |||
point = curve.GetPoint(i / (float)lineSteps); | |||
Handles.DrawLine(point, point + curve.GetDirection(i / (float)lineSteps) * directionScale); | |||
} | |||
} | |||
private Vector3 ShowPoint (int index) { | |||
Vector3 point = handleTransform.TransformPoint(curve.points[index]); | |||
EditorGUI.BeginChangeCheck(); | |||
point = Handles.DoPositionHandle(point, handleRotation); | |||
if (EditorGUI.EndChangeCheck()) { | |||
Undo.RecordObject(curve, "Move Point"); | |||
EditorUtility.SetDirty(curve); | |||
curve.points[index] = handleTransform.InverseTransformPoint(point); | |||
} | |||
return point; | |||
} | |||
} |
@ -0,0 +1,11 @@ | |||
fileFormatVersion: 2 | |||
guid: 28cd1cdefdaf24d6cb98f0cb87845b3a | |||
timeCreated: 18446744011573954816 | |||
MonoImporter: | |||
serializedVersion: 2 | |||
defaultReferences: [] | |||
executionOrder: 0 | |||
icon: {instanceID: 0} | |||
userData: | |||
assetBundleName: | |||
assetBundleVariant: |
@ -0,0 +1,115 @@ | |||
using UnityEditor; | |||
using UnityEngine; | |||
[CustomEditor(typeof(BezierSpline))] | |||
public class BezierSplineInspector : Editor { | |||
private const int stepsPerCurve = 10; | |||
private const float directionScale = 0.5f; | |||
private const float handleSize = 0.04f; | |||
private const float pickSize = 0.06f; | |||
private static Color[] modeColors = { | |||
Color.white, | |||
Color.yellow, | |||
Color.cyan | |||
}; | |||
private BezierSpline spline; | |||
private Transform handleTransform; | |||
private Quaternion handleRotation; | |||
private int selectedIndex = -1; | |||
public override void OnInspectorGUI () { | |||
spline = target as BezierSpline; | |||
EditorGUI.BeginChangeCheck(); | |||
bool loop = EditorGUILayout.Toggle("Loop", spline.Loop); | |||
if (EditorGUI.EndChangeCheck()) { | |||
Undo.RecordObject(spline, "Toggle Loop"); | |||
EditorUtility.SetDirty(spline); | |||
spline.Loop = loop; | |||
} | |||
if (selectedIndex >= 0 && selectedIndex < spline.ControlPointCount) { | |||
DrawSelectedPointInspector(); | |||
} | |||
if (GUILayout.Button("Add Curve")) { | |||
Undo.RecordObject(spline, "Add Curve"); | |||
spline.AddCurve(); | |||
EditorUtility.SetDirty(spline); | |||
} | |||
} | |||
private void DrawSelectedPointInspector() { | |||
GUILayout.Label("Selected Point"); | |||
EditorGUI.BeginChangeCheck(); | |||
Vector3 point = EditorGUILayout.Vector3Field("Position", spline.GetControlPoint(selectedIndex)); | |||
if (EditorGUI.EndChangeCheck()) { | |||
Undo.RecordObject(spline, "Move Point"); | |||
EditorUtility.SetDirty(spline); | |||
spline.SetControlPoint(selectedIndex, point); | |||
} | |||
EditorGUI.BeginChangeCheck(); | |||
BezierControlPointMode mode = (BezierControlPointMode)EditorGUILayout.EnumPopup("Mode", spline.GetControlPointMode(selectedIndex)); | |||
if (EditorGUI.EndChangeCheck()) { | |||
Undo.RecordObject(spline, "Change Point Mode"); | |||
spline.SetControlPointMode(selectedIndex, mode); | |||
EditorUtility.SetDirty(spline); | |||
} | |||
} | |||
private void OnSceneGUI () { | |||
spline = target as BezierSpline; | |||
handleTransform = spline.transform; | |||
handleRotation = Tools.pivotRotation == PivotRotation.Local ? | |||
handleTransform.rotation : Quaternion.identity; | |||
Vector3 p0 = ShowPoint(0); | |||
for (int i = 1; i < spline.ControlPointCount; i += 3) { | |||
Vector3 p1 = ShowPoint(i); | |||
Vector3 p2 = ShowPoint(i + 1); | |||
Vector3 p3 = ShowPoint(i + 2); | |||
Handles.color = Color.gray; | |||
Handles.DrawLine(p0, p1); | |||
Handles.DrawLine(p2, p3); | |||
Handles.DrawBezier(p0, p3, p1, p2, Color.white, null, 2f); | |||
p0 = p3; | |||
} | |||
ShowDirections(); | |||
} | |||
private void ShowDirections () { | |||
Handles.color = Color.green; | |||
Vector3 point = spline.GetPoint(0f); | |||
Handles.DrawLine(point, point + spline.GetDirection(0f) * directionScale); | |||
int steps = stepsPerCurve * spline.CurveCount; | |||
for (int i = 1; i <= steps; i++) { | |||
point = spline.GetPoint(i / (float)steps); | |||
Handles.DrawLine(point, point + spline.GetDirection(i / (float)steps) * directionScale); | |||
} | |||
} | |||
private Vector3 ShowPoint (int index) { | |||
Vector3 point = handleTransform.TransformPoint(spline.GetControlPoint(index)); | |||
float size = HandleUtility.GetHandleSize(point); | |||
if (index == 0) { | |||
size *= 2f; | |||
} | |||
Handles.color = modeColors[(int)spline.GetControlPointMode(index)]; | |||
if (Handles.Button(point, handleRotation, size * handleSize, size * pickSize, Handles.DotCap)) { | |||
selectedIndex = index; | |||
Repaint(); | |||
} | |||
if (selectedIndex == index) { | |||
EditorGUI.BeginChangeCheck(); | |||
point = Handles.DoPositionHandle(point, handleRotation); | |||
if (EditorGUI.EndChangeCheck()) { | |||
Undo.RecordObject(spline, "Move Point"); | |||
EditorUtility.SetDirty(spline); | |||
spline.SetControlPoint(index, handleTransform.InverseTransformPoint(point)); | |||
} | |||
} | |||
return point; | |||
} | |||
} |
@ -0,0 +1,11 @@ | |||
fileFormatVersion: 2 | |||
guid: 127eddf8173c549d9976751e82f3face | |||
timeCreated: 18446744011573954816 | |||
MonoImporter: | |||
serializedVersion: 2 | |||
defaultReferences: [] | |||
executionOrder: 0 | |||
icon: {instanceID: 0} | |||
userData: | |||
assetBundleName: | |||
assetBundleVariant: |
@ -0,0 +1,31 @@ | |||
using UnityEditor; | |||
using UnityEngine; | |||
[CustomEditor(typeof(Line))] | |||
public class LineInspector : Editor { | |||
private void OnSceneGUI () { | |||
Line line = target as Line; | |||
Transform handleTransform = line.transform; | |||
Quaternion handleRotation = Tools.pivotRotation == PivotRotation.Local ? handleTransform.rotation : Quaternion.identity; | |||
Vector3 p0 = handleTransform.TransformPoint(line.p0); | |||
Vector3 p1 = handleTransform.TransformPoint(line.p1); | |||
Handles.color = Color.white; | |||
Handles.DrawLine(p0, p1); | |||
EditorGUI.BeginChangeCheck(); | |||
p0 = Handles.DoPositionHandle(p0, handleRotation); | |||
if (EditorGUI.EndChangeCheck()) { | |||
Undo.RecordObject(line, "Move Point"); | |||
EditorUtility.SetDirty(line); | |||
line.p0 = handleTransform.InverseTransformPoint(p0); | |||
} | |||
EditorGUI.BeginChangeCheck(); | |||
p1 = Handles.DoPositionHandle(p1, handleRotation); | |||
if (EditorGUI.EndChangeCheck()) { | |||
Undo.RecordObject(line, "Move Point"); | |||
EditorUtility.SetDirty(line); | |||
line.p1 = handleTransform.InverseTransformPoint(p1); | |||
} | |||
} | |||
} |
@ -0,0 +1,11 @@ | |||
fileFormatVersion: 2 | |||
guid: 668731f6cd4a54b7cbeaea95414d6cec | |||
timeCreated: 18446744011573954816 | |||
MonoImporter: | |||
serializedVersion: 2 | |||
defaultReferences: [] | |||
executionOrder: 0 | |||
icon: {instanceID: 0} | |||
userData: | |||
assetBundleName: | |||
assetBundleVariant: |
@ -1,5 +1,5 @@ | |||
fileFormatVersion: 2 | |||
guid: 7da0e8d0a6415f944aa43dff57b38ae3 | |||
guid: bff42364d83460d42a9a47a1c163f7e5 | |||
folderAsset: yes | |||
DefaultImporter: | |||
externalObjects: {} |
@ -0,0 +1,6 @@ | |||
[{000214A0-0000-0000-C000-000000000046}] | |||
Prop3=19,11 | |||
[InternetShortcut] | |||
URL=https://www.dropbox.com/s/m9x1bs39kb9dsyg/Fog%20Volume%203.4%20Demo%20Content.unitypackage?dl=0 | |||
IDList= | |||
HotKey=0 |
@ -0,0 +1,8 @@ | |||
fileFormatVersion: 2 | |||
guid: ffcaf45475fe63b499df0948872a243a | |||
timeCreated: 1492441436 | |||
licenseType: Store | |||
DefaultImporter: | |||
userData: | |||
assetBundleName: | |||
assetBundleVariant: |
@ -0,0 +1,5 @@ | |||
[{000214A0-0000-0000-C000-000000000046}] | |||
Prop3=19,11 | |||
[InternetShortcut] | |||
URL=https://docs.google.com/presentation/d/1HQKB0rayEYGC8qU4LYPYdRu84D2qRJCRUcxpALkvUpo/present#slide=id.p | |||
IDList= |
@ -0,0 +1,8 @@ | |||
fileFormatVersion: 2 | |||
guid: dc8abe7b380e7e143bafc5ffa47ea27d | |||
timeCreated: 1489841050 | |||
licenseType: Store | |||
DefaultImporter: | |||
userData: | |||
assetBundleName: | |||
assetBundleVariant: |
@ -0,0 +1,2 @@ | |||
External packages used in the demo scenes: | |||
Post-Processing: https://docs.unity3d.com/Packages/com.unity.postprocessing@2.0-preview/manual/index.html |
@ -0,0 +1,8 @@ | |||
fileFormatVersion: 2 | |||
guid: 295602c26457e8f4ea072bb724b82a8c | |||
timeCreated: 1489699403 | |||
licenseType: Store | |||
TextScriptImporter: | |||
userData: | |||
assetBundleName: | |||
assetBundleVariant: |
@ -1,5 +1,5 @@ | |||
fileFormatVersion: 2 | |||
guid: c207356b78ec8e8499bb6047218dd104 | |||
guid: 67e479cda70247347b75a023b0955608 | |||
folderAsset: yes | |||
DefaultImporter: | |||
externalObjects: {} |
@ -0,0 +1,3 @@ | |||
version https://git-lfs.github.com/spec/v1 | |||
oid sha256:2dab8520d2b1e8fb214ed1a56e2b21107a59648e0e8eedfdd3bbd47db89cf6b9 | |||
size 16777760 |
@ -0,0 +1,6 @@ | |||
fileFormatVersion: 2 | |||
guid: ce515a5a715cb574eb40037cfb1ab766 | |||
NativeFormatImporter: | |||
userData: | |||
assetBundleName: | |||
assetBundleVariant: |
@ -0,0 +1,48 @@ | |||
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)' | |||
Shader "Hidden/Fog Volume/BlurEffectConeTap" | |||
{ | |||
Properties { _MainTex ("", any) = "" {} } | |||
CGINCLUDE | |||
#include "UnityCG.cginc" | |||
struct v2f { | |||
float4 pos : SV_POSITION; | |||
half2 uv : TEXCOORD0; | |||
half2 taps[4] : TEXCOORD1; | |||
}; | |||
sampler2D _MainTex; | |||
half4 _MainTex_TexelSize; | |||
half4 _BlurOffsets; | |||
half ShadowColor; | |||
v2f vert( appdata_img v ) { | |||
v2f o; | |||
o.pos = UnityObjectToClipPos(v.vertex); | |||
o.uv = v.texcoord - _BlurOffsets.xy * _MainTex_TexelSize.xy; // hack, see BlurEffect.cs for the reason for this. let's make a new blur effect soon | |||
o.taps[0] = o.uv + _MainTex_TexelSize * _BlurOffsets.xy; | |||
o.taps[1] = o.uv - _MainTex_TexelSize * _BlurOffsets.xy; | |||
o.taps[2] = o.uv + _MainTex_TexelSize * _BlurOffsets.xy * half2(1,-1); | |||
o.taps[3] = o.uv - _MainTex_TexelSize * _BlurOffsets.xy * half2(1,-1); | |||
return o; | |||
} | |||
half4 frag(v2f i) : SV_Target { | |||
half4 color = tex2D(_MainTex, i.taps[0]); | |||
color += tex2D(_MainTex, i.taps[1]); | |||
color += tex2D(_MainTex, i.taps[2]); | |||
color += tex2D(_MainTex, i.taps[3]); | |||
//color.gb *= 0; | |||
//color *= ShadowColor; | |||
return color*.25; | |||
} | |||
ENDCG | |||
SubShader { | |||
Pass { | |||
ZTest Always Cull Off ZWrite Off | |||
CGPROGRAM | |||
#pragma vertex vert | |||
#pragma fragment frag | |||
ENDCG | |||
} | |||
} | |||
Fallback off | |||
} |
@ -0,0 +1,9 @@ | |||
fileFormatVersion: 2 | |||
guid: 4af33ef55eb37cc48882a59ddce889b7 | |||
timeCreated: 1483594902 | |||
licenseType: Store | |||
ShaderImporter: | |||
defaultTextures: [] | |||
userData: | |||
assetBundleName: | |||
assetBundleVariant: |
@ -0,0 +1,227 @@ | |||
#ifndef FOG_VOLUME_COMMON_INPUTS_INCLUDED | |||
#define FOG_VOLUME_COMMON_INPUTS_INCLUDED | |||
uniform sampler2D | |||
_Gradient, | |||
_ValueNoise; | |||
#ifdef _FOG_VOLUME_NOISE | |||
uniform sampler3D _NoiseVolume, _NoiseVolume2; | |||
sampler2D CoverageTex; | |||
#endif | |||
float Collisions = 0; | |||
half4 _AmbientHeightAbsorption; | |||
#define _AmbientHeightAbsorptionMin _AmbientHeightAbsorption.x | |||
#define _AmbientHeightAbsorptionMax _AmbientHeightAbsorption.y | |||
#ifdef HEIGHT_GRAD | |||
half4 _VerticalGradientParams; | |||
#define GradMin _VerticalGradientParams.x | |||
#define GradMax _VerticalGradientParams.y | |||
#define GradMin2 _VerticalGradientParams.z | |||
#define GradMax2 _VerticalGradientParams.w | |||
#endif | |||
#ifdef DEBUG | |||
sampler2D _PerformanceLUT; | |||
#endif | |||
#ifdef _FOG_LOWRES_RENDERER | |||
sampler2D RT_Depth, RT_DepthR; | |||
#endif | |||
#ifdef VOLUME_SHADOWS | |||
sampler2D LightshaftTex; | |||
#endif | |||
#ifdef HALO | |||
sampler2D _LightHaloTexture; | |||
fixed _HaloOpticalDispersion, | |||
_HaloIntensity, | |||
_HaloWidth, | |||
_HaloRadius, | |||
_HaloAbsorption; | |||
#endif | |||
#ifdef ExternalDepth | |||
sampler2D _CustomCameraDepthTexture; | |||
#else | |||
sampler2D _CameraDepthTexture; | |||
#endif | |||
int STEP_COUNT = 200; | |||
int _ProxyVolume; | |||
int _AmbientAffectsFogColor; | |||
#ifdef DF | |||
uniform float4x4 _PrimitivesTransform[20]; | |||
uniform half _PrimitiveEdgeSoftener; | |||
uniform float4 _PrimitivePosition[20], | |||
_PrimitiveScale[20], _PrimitiveData[20]; | |||
int _PrimitiveCount = 0; | |||
// Smaller than 1.0f -> BoxCollider. | |||
// Larger than 1.0f and smaller than 2.0f -> SphereCollider. | |||
#define _PrimitiveShapeType(i) _PrimitiveData[i].x | |||
// Smaller than 1.0f -> Additive. | |||
// Larger than 1.0f and smaller than 2.0f -> Subtractive. | |||
#define _PrimitiveActionType(i) _PrimitiveData[i].y | |||
#endif | |||
const static int MaxVisibleLights = 64; | |||
#if SHADER_API_GLCORE || SHADER_API_D3D11 | SHADER_API_METAL | |||
#if ATTEN_METHOD_1 || ATTEN_METHOD_2 || ATTEN_METHOD_3 | |||
uniform float4 _LightData[MaxVisibleLights]; | |||
#define _LightIntensity(i) _LightData[i].x | |||
#define _LightRange(i) _LightData[i].y | |||
#define _LightSpotAngle(i) _LightData[i].z | |||
uniform float4 _LightPositions[MaxVisibleLights], _LightColors[MaxVisibleLights], _LightRotations[MaxVisibleLights]; | |||
half PointLightingDistance, | |||
PointLightingDistance2Camera; | |||
#endif | |||
#endif | |||
#ifdef _SHADE | |||
int _SelfShadowSteps; | |||
float4 _SelfShadowColor; | |||
#endif | |||
//uniform int STEP_COUNT = 50, | |||
int _LightsCount = 0, | |||
Octaves, | |||
_DebugMode, | |||
SamplingMethod, | |||
DirectLightingShadowSteps; | |||
#if DIRECTIONAL_LIGHTING | |||
half DirectLightingShadowDensity; | |||
float4 LightExtinctionColor; | |||
#endif | |||
uniform float4 _Color, | |||
_FogColor, | |||
_InscatteringColor, | |||
_BoxMin, | |||
_BoxMax, | |||
Stretch, | |||
_LightColor, | |||
_AmbientColor, | |||
VolumeSize, | |||
VolumeFogInscatteringColor, | |||
_VolumePosition; | |||
uniform float3 L = float3(0, 0, 1), | |||
_LightLocalDirection, | |||
//_CameraForward, | |||
_SliceNormal, | |||
Speed = 1; | |||
int VolumeFogInscatterColorAffectedWithFogColor = 1; | |||
uniform half DetailTiling, | |||
_PrimitiveCutout, | |||
HeightAbsorption, | |||
_LightExposure, | |||
VolumeFogInscatteringIntensity, | |||
VolumeFogInscatteringAnisotropy, | |||
VolumeFogInscatteringStartDistance, | |||
VolumeFogInscatteringTransitionWideness, | |||
_PushAlpha, | |||
_DetailMaskingThreshold, | |||
//_DetailSamplingBaseOpacityLimit, | |||
_OptimizationFactor, | |||
_BaseRelativeSpeed, | |||
_DetailRelativeSpeed, | |||
_NoiseDetailRange, | |||
_Curl, | |||
Absorption, | |||
BaseTiling, | |||
_Cutoff, | |||
Coverage, | |||
NoiseDensity, | |||
LambertianBias, | |||
DirectLightingAmount, | |||
NormalDistance, | |||
_Vortex = 1, | |||
_RotationSpeed, | |||
_Rotation, | |||
DirectLightingDistance, | |||
_FOV, | |||
_DirectionalLightingDistance, | |||
//GradMin, | |||
// GradMax, | |||
Constrain, | |||
SphericalFadeDistance, | |||
DetailDistance, | |||
_SceneIntersectionSoftness, | |||
_InscatteringIntensity = 1, | |||
InscatteringShape, | |||
_Visibility, | |||
InscatteringStartDistance = 100, | |||
IntersectionThreshold, | |||
InscatteringTransitionWideness = 500, | |||
_3DNoiseScale, | |||
_RayStep, | |||
gain = 1, | |||
threshold = 0, | |||
Shade, | |||
_SceneIntersectionThreshold, | |||
ShadowBrightness, | |||
_jitter, | |||
FadeDistance, | |||
Offset = 0, | |||
Gamma = 1, | |||
Exposure; | |||
struct v2f | |||
{ | |||
float4 pos : SV_POSITION; | |||
float3 Wpos : TEXCOORD0; | |||
float4 ScreenUVs : TEXCOORD1; | |||
float3 LocalPos : TEXCOORD2; | |||
float3 ViewPos : TEXCOORD3; | |||
float3 LocalEyePos : TEXCOORD4; | |||
float3 LightLocalDir : TEXCOORD5; | |||
float3 WorldEyeDir : TEXCOORD6; | |||
float2 uv0 : TEXCOORD7; | |||
float3 SliceNormal : TEXCOORD8; | |||
float3 worldNormal : TEXCOORD9; | |||
}; | |||
v2f vert(appdata_full i) | |||
{ | |||
v2f o; | |||
o.pos = UnityObjectToClipPos(i.vertex); | |||
o.Wpos = mul((float4x4)unity_ObjectToWorld, float4(i.vertex.xyz, 1)).xyz; | |||
o.ScreenUVs = ComputeScreenPos(o.pos); | |||
o.ViewPos = UnityObjectToViewPos( float4(i.vertex.xyz, 1)).xyz; | |||
o.LocalPos = i.vertex.xyz; | |||
o.LocalEyePos = mul((float4x4)unity_WorldToObject, (float4(_WorldSpaceCameraPos, 1))).xyz; | |||
o.LightLocalDir = mul((float4x4)unity_WorldToObject, (float4(L.xyz, 1))).xyz; | |||
o.WorldEyeDir = (o.Wpos.xyz - _WorldSpaceCameraPos.xyz); | |||
o.uv0 = i.texcoord; | |||
//WIN http://answers.unity3d.com/questions/192553/camera-forward-vector-in-shader.html | |||
o.SliceNormal = UNITY_MATRIX_IT_MV[2].xyz;// mul((float4x4)unity_WorldToObject, _SliceNormal).xyz; | |||
o.worldNormal = float3(0, -1, 0);//upwards | |||
//o.worldNormal = UnityObjectToWorldNormal(float3(0,0 , 1)); | |||
return o; | |||
} | |||
#endif |
@ -0,0 +1,9 @@ | |||
fileFormatVersion: 2 | |||
guid: 221471eda3fc26743b686132df3cab61 | |||
timeCreated: 1482840022 | |||
licenseType: Store | |||
ShaderImporter: | |||
defaultTextures: [] | |||
userData: | |||
assetBundleName: | |||
assetBundleVariant: |
@ -0,0 +1,142 @@ | |||
// Upgrade NOTE: removed variant '__' where variant LOD_FADE_PERCENTAGE is used. | |||
Shader "Hidden/Fog Volume/Depth" | |||
{ | |||
Properties | |||
{ | |||
_MainTex("Main Texture", 2D) = "white" {} | |||
_Cutoff("Alpha cutoff", Range(0,1)) = 0.5 | |||
_Color("Color", Color) = (1,1,1,1) | |||
[MaterialEnum(Off,0,Front,1,Back,2)] _Cull("Cull", Int) = 2 | |||
[MaterialEnum(None,0,Fastest,1,Fast,2,Better,3,Best,4,Palm,5)] _WindQuality("Wind Quality", Range(0,5)) = 0 | |||
} | |||
CGINCLUDE | |||
#pragma target 3.0 | |||
#include "UnityCG.cginc" | |||
sampler2D _CameraDepthTexture; | |||
uniform float _Cutoff; | |||
uniform sampler2D _MainTex; | |||
float4 _Color; | |||
int _Cull; | |||
struct v2f | |||
{ | |||
float4 vertex : SV_POSITION; | |||
float2 uv : TEXCOORD0; | |||
half depth:TEXCOORD1; | |||
UNITY_VERTEX_OUTPUT_STEREO | |||
}; | |||
v2f vert(appdata_full v) | |||
{ | |||
v2f o; | |||
UNITY_SETUP_INSTANCE_ID(v); | |||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o); | |||
o.vertex = UnityObjectToClipPos(v.vertex); | |||
o.uv = v.texcoord.xy; | |||
//o.depth = COMPUTE_DEPTH_01; | |||
//3.2.1 | |||
o.depth = -(UnityObjectToViewPos(v.vertex).z)/** _ProjectionParams.w*/; | |||
return o; | |||
} | |||
half4 fragOpaque(v2f i) : COLOR | |||
{ | |||
float d =1.0/(i.depth); | |||
//float d = Linear01Depth(i.depth); | |||
//float d= 1.0 / (_ZBufferParams.x * i.depth + _ZBufferParams.y); | |||
//#if defined(UNITY_REVERSED_Z) | |||
//d = 1.0f - d; | |||
//#endif | |||
return d; | |||
} | |||
half4 fragTransparentCutout(v2f i) : COLOR | |||
{ | |||
half4 c = tex2D(_MainTex, i.uv)*_Color; | |||
clip(c.a - _Cutoff); | |||
float d = 1.0/(i.depth); | |||
// #if defined(UNITY_REVERSED_Z) | |||
// i.depth = 1.0f - i.depth; | |||
// #endif | |||
return (d); | |||
} | |||
ENDCG | |||
SubShader | |||
{ | |||
Tags{ "RenderType" = "Opaque" } | |||
Pass | |||
{ | |||
Fog{ Mode Off } | |||
CGPROGRAM | |||
#pragma vertex vert | |||
#pragma fragment fragOpaque | |||
ENDCG | |||
} | |||
} | |||
SubShader | |||
{ | |||
Tags{ "RenderType" = "TransparentCutout" } | |||
Pass | |||
{ | |||
Fog{ Mode Off } | |||
CGPROGRAM | |||
#pragma vertex vert | |||
#pragma fragment fragTransparentCutout | |||
ENDCG | |||
} | |||
} | |||
SubShader | |||
{ | |||
Tags{ "RenderType" = "TreeLeaf" } | |||
Pass | |||
{ | |||
Fog{ Mode Off } | |||
CGPROGRAM | |||
#pragma vertex vert | |||
#pragma fragment fragTransparentCutout | |||
ENDCG | |||
} | |||
} | |||
SubShader | |||
{ | |||
Tags | |||
{ | |||
"Queue" = "Geometry" | |||
"IgnoreProjector" = "True" | |||
"RenderType" = "SpeedTree" | |||
"DisableBatching" = "LODFading" | |||
} | |||
//Pass{ | |||
Cull[_Cull] | |||
Fog{ Mode Off } | |||
CGPROGRAM | |||
#pragma surface surf Lambert vertex:SpeedTreeVert nolightmap | |||
#pragma target 3.0 | |||
#pragma multi_compile LOD_FADE_PERCENTAGE LOD_FADE_CROSSFADE | |||
#pragma shader_feature GEOM_TYPE_BRANCH GEOM_TYPE_BRANCH_DETAIL GEOM_TYPE_FROND GEOM_TYPE_LEAF GEOM_TYPE_MESH | |||
#define ENABLE_WIND | |||
#define SPEEDTREE_ALPHATEST | |||
#include "SpeedTreeCommonDepth.cginc" | |||
void surf(Input IN, inout SurfaceOutput OUT) | |||
{ | |||
float d= 1.0 / (IN.depth); | |||
// /*#if defined(UNITY_REVERSED_Z) | |||
// d = 1.0f - d; | |||
// #endif*/ | |||
OUT.Emission = d; | |||
SpeedTreeFragOut o; | |||
SpeedTreeFrag(IN, o); | |||
SPEEDTREE_COPY_FRAG(OUT, o) | |||
} | |||
ENDCG | |||
//} | |||
} | |||
} |
@ -0,0 +1,9 @@ | |||
fileFormatVersion: 2 | |||
guid: d0b391204631703488bbc7d5ca98a27e | |||
timeCreated: 1483594902 | |||
licenseType: Store | |||
ShaderImporter: | |||
defaultTextures: [] | |||
userData: | |||
assetBundleName: | |||
assetBundleVariant: |
@ -0,0 +1,51 @@ | |||
Shader "Hidden/DepthMapQuad" | |||
{ | |||
SubShader | |||
{ | |||
Tags { "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "buuuh" } | |||
LOD 100 | |||
ZWrite Off | |||
Blend SrcAlpha OneMinusSrcAlpha | |||
Pass | |||
{ | |||
CGPROGRAM | |||
#pragma vertex vert | |||
#pragma fragment frag | |||
#include "UnityCG.cginc" | |||
struct appdata | |||
{ | |||
float4 vertex : POSITION; | |||
}; | |||
struct v2f | |||
{ | |||
float4 vertex : SV_POSITION; | |||
}; | |||
v2f vert(appdata v) | |||
{ | |||
v2f o; | |||
o.vertex = UnityObjectToClipPos(v.vertex); | |||
return o; | |||
} | |||
fixed4 frag(v2f i) : SV_Target | |||
{ | |||
clip(-.1); | |||
return 1; | |||
} | |||
ENDCG | |||
} | |||
} | |||
SubShader | |||
{ | |||
Tags{ "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Opaque" } | |||
LOD 1 | |||
UsePass "Legacy Shaders/VertexLit/SHADOWCASTER" | |||
} | |||
} |
@ -0,0 +1,9 @@ | |||
fileFormatVersion: 2 | |||
guid: 2861e5c5d9ee53c4880db939fa31de53 | |||
timeCreated: 1499537961 | |||
licenseType: Store | |||
ShaderImporter: | |||
defaultTextures: [] | |||
userData: | |||
assetBundleName: | |||
assetBundleVariant: |
@ -0,0 +1,22 @@ | |||
%YAML 1.1 | |||
%TAG !u! tag:unity3d.com,2011: | |||
--- !u!21 &2100000 | |||
Material: | |||
serializedVersion: 6 | |||
m_ObjectHideFlags: 0 | |||
m_CorrespondingSourceObject: {fileID: 0} | |||
m_PrefabInternal: {fileID: 0} | |||
m_Name: Fog Volume Surrogate | |||
m_Shader: {fileID: 4800000, guid: 8363634d6593ec54ab321a7f0e84fd28, type: 3} | |||
m_ShaderKeywords: | |||
m_LightmapFlags: 5 | |||
m_EnableInstancingVariants: 0 | |||
m_DoubleSidedGI: 0 | |||
m_CustomRenderQueue: -1 | |||
stringTagMap: {} | |||
disabledShaderPasses: [] | |||
m_SavedProperties: | |||
serializedVersion: 3 | |||
m_TexEnvs: [] | |||
m_Floats: [] | |||
m_Colors: [] |
@ -0,0 +1,8 @@ | |||
fileFormatVersion: 2 | |||
guid: 40936b27caf58064f9aab675fe028844 | |||
timeCreated: 1487789215 | |||
licenseType: Store | |||
NativeFormatImporter: | |||
userData: | |||
assetBundleName: | |||
assetBundleVariant: |
@ -0,0 +1,142 @@ | |||
Shader "Hidden/FogVolume" | |||
{ | |||
Properties | |||
{ | |||
[hideininspector]_SrcBlend("__src", Float) = 1.0 | |||
[hideininspector]_NoiseVolume("_NoiseVolume", 3D)= "white" {} | |||
[hideininspector]_NoiseVolume2("_NoiseVolume2", 3D) = "white" {} | |||
[hideininspector]_Gradient("_Gradient", 2D) = "white" {} | |||
[hideininspector]CoverageTex("CoverageTex", 2D) = "grey" {} | |||
//[hideininspector]_ShadowTexture("_ShadowTexture", 2D) = "white" {} | |||
} | |||
CGINCLUDE | |||
//#define COVERAGE | |||
//#define EARTH_CLOUD_STYLE | |||
//#define VOLUMETRIC_SHADOWS _VolumetricShadowsEnabled | |||
//#define CONVOLVE_VOLUMETRIC_SHADOWS | |||
//custom depth input | |||
//#define ExternalDepth | |||
#define AMBIENT_AFFECTS_FOG_COLOR _AmbientAffectsFogColor | |||
//#define DEBUG_PRIMITIVES | |||
#define VOLUMETRIC_SHADOWS _VolumetricShadowsEnabled | |||
#define FOG_TINTS_INSCATTER VolumeFogInscatterColorAffectedWithFogColor | |||
#include "UnityCG.cginc" | |||
#include "CommonInputs.cginc" | |||
#include "Integrations.cginc" | |||
#define PROBES _ProxyVolume | |||
half NoiseAtten = 1; | |||
int _SrcBlend; | |||
int _ztest; | |||
#include "FogVolumeCommon.cginc" | |||
#define DEBUG_ITERATIONS 1 | |||
#define DEBUG_INSCATTERING 2 | |||
#define DEBUG_VOLUMETRIC_SHADOWS 3 | |||
#define DEBUG_VOLUME_FOG_INSCATTER_CLAMP 4 | |||
#define DEBUG_VOLUME_FOG_PHASE 5 | |||
#include "FogVolumeFragment.cginc" | |||
ENDCG | |||
//normal pass | |||
SubShader | |||
{ | |||
Tags{ "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "None" } | |||
LOD 600 | |||
//Blend SrcAlpha OneMinusSrcAlpha | |||
//Blend One OneMinusSrcAlpha | |||
Blend[_SrcBlend] OneMinusSrcAlpha | |||
Fog{ Mode Off } | |||
Cull Front | |||
Lighting Off | |||
ZWrite Off | |||
ZTest [_ztest] | |||
Pass | |||
{ | |||
CGPROGRAM | |||
//#pragma multi_compile _ ExternalDepth | |||
#pragma multi_compile _ _FOG_LOWRES_RENDERER | |||
#pragma shader_feature _INSCATTERING | |||
#pragma shader_feature VOLUME_FOG | |||
#pragma shader_feature _VOLUME_FOG_INSCATTERING | |||
#pragma shader_feature _FOG_GRADIENT | |||
#pragma shader_feature _FOG_VOLUME_NOISE | |||
// #pragma shader_feature _COLLISION | |||
//#pragma multi_compile _ DEBUG | |||
//#pragma shader_feature SAMPLING_METHOD_ViewAligned | |||
#pragma shader_feature HEIGHT_GRAD | |||
//#pragma shader_feature _TONEMAP | |||
#pragma shader_feature JITTER | |||
#pragma shader_feature ColorAdjust | |||
#pragma shader_feature ABSORPTION | |||
#pragma multi_compile _ Twirl_X Twirl_Y Twirl_Z | |||
#pragma shader_feature _SHADE | |||
#pragma shader_feature DF | |||
#pragma shader_feature DIRECTIONAL_LIGHTING | |||
#pragma multi_compile _ ATTEN_METHOD_1 ATTEN_METHOD_2 ATTEN_METHOD_3 | |||
#pragma shader_feature SPHERICAL_FADE | |||
//#pragma shader_feature _LAMBERT_SHADING | |||
#pragma multi_compile _ VOLUME_SHADOWS | |||
#pragma shader_feature LIGHT_ATTACHED | |||
#pragma shader_feature HALO | |||
//Unity define for stereo is not working. Had to do it manually | |||
#pragma multi_compile _ FOG_VOLUME_STEREO_ON | |||
#pragma exclude_renderers d3d9 | |||
//#pragma only_renderers d3d11 | |||
#pragma vertex vert | |||
#pragma fragment frag | |||
#pragma target 3.0 | |||
ENDCG | |||
} | |||
} | |||
//opacity pass . Only for shadow rt | |||
SubShader | |||
{ | |||
Tags{ "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "None" } | |||
LOD 100 | |||
Blend SrcAlpha OneMinusSrcAlpha | |||
Fog{ Mode Off } | |||
Cull Front | |||
Lighting Off | |||
ZWrite Off | |||
ZTest Always | |||
Pass | |||
{ | |||
Fog{ Mode Off } | |||
CGPROGRAM | |||
#define SHADOW_PASS | |||
#pragma shader_feature _FOG_GRADIENT | |||
#pragma shader_feature _FOG_VOLUME_NOISE | |||
// #pragma shader_feature _COLLISION | |||
#pragma shader_feature SAMPLING_METHOD_ViewAligned | |||
#pragma shader_feature HEIGHT_GRAD | |||
#pragma multi_compile Twirl_X Twirl_Y Twirl_Z | |||
#pragma shader_feature DF | |||
//#pragma multi_compile SHADOW_PASS | |||
#pragma shader_feature SPHERICAL_FADE | |||
#pragma exclude_renderers d3d9 | |||
//#pragma only_renderers d3d11 | |||
#pragma glsl | |||
#pragma vertex vert | |||
#pragma fragment frag | |||
#pragma target 3.0 | |||
ENDCG | |||
} | |||
} | |||
} |
@ -0,0 +1,7 @@ | |||
fileFormatVersion: 2 | |||
guid: 6040e6c91df9d9d47b7e5426d41a7471 | |||
ShaderImporter: | |||
defaultTextures: [] | |||
userData: | |||
assetBundleName: | |||
assetBundleVariant: |
@ -0,0 +1,330 @@ | |||
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)' | |||
Shader "Hidden/FogVolumeBloom" { | |||
Properties { | |||
_MainTex ("Base (RGB)", 2D) = "white" {} | |||
_Bloom ("Bloom (RGB)", 2D) = "black" {} | |||
} | |||
CGINCLUDE | |||
#include "UnityCG.cginc" | |||
#pragma shader_feature BLOOM | |||
sampler2D _MainTex; | |||
sampler2D _Bloom; | |||
sampler2D RT_FogVolumeConvolution, _source; | |||
uniform half4 _MainTex_TexelSize; | |||
half4 _MainTex_ST; | |||
uniform half _Saturation; | |||
uniform half4 _Parameter; | |||
uniform half4 _OffsetsA; | |||
uniform half4 _OffsetsB; | |||
half _Falloff; | |||
#define ONE_MINUS_THRESHHOLD_TIMES_INTENSITY _Parameter.w | |||
#define THRESHHOLD _Parameter.z | |||
struct v2f_simple | |||
{ | |||
float4 pos : SV_POSITION; | |||
half2 uv : TEXCOORD0; | |||
#if UNITY_UV_STARTS_AT_TOP | |||
half2 uv2 : TEXCOORD1; | |||
#endif | |||
}; | |||
v2f_simple vertBloom ( appdata_img v ) | |||
{ | |||
v2f_simple o; | |||
o.pos = UnityObjectToClipPos (v.vertex); | |||
o.uv = UnityStereoScreenSpaceUVAdjust(v.texcoord, _MainTex_ST); | |||
#if UNITY_UV_STARTS_AT_TOP | |||
o.uv2 = o.uv; | |||
if (_MainTex_TexelSize.y < 0.0) | |||
o.uv.y = 1.0 - o.uv.y; | |||
#endif | |||
return o; | |||
} | |||
struct v2f_tap | |||
{ | |||
float4 pos : SV_POSITION; | |||
half2 uv20 : TEXCOORD0; | |||
half2 uv21 : TEXCOORD1; | |||
half2 uv22 : TEXCOORD2; | |||
half2 uv23 : TEXCOORD3; | |||
}; | |||
v2f_tap vert4Tap ( appdata_img v ) | |||
{ | |||
v2f_tap o; | |||
o.pos = UnityObjectToClipPos (v.vertex); | |||
o.uv20 = UnityStereoScreenSpaceUVAdjust(v.texcoord + _MainTex_TexelSize.xy, _MainTex_ST); | |||
o.uv21 = UnityStereoScreenSpaceUVAdjust(v.texcoord + _MainTex_TexelSize.xy * half2(-0.5h,-0.5h), _MainTex_ST); | |||
o.uv22 = UnityStereoScreenSpaceUVAdjust(v.texcoord + _MainTex_TexelSize.xy * half2(0.5h,-0.5h), _MainTex_ST); | |||
o.uv23 = UnityStereoScreenSpaceUVAdjust(v.texcoord + _MainTex_TexelSize.xy * half2(-0.5h,0.5h), _MainTex_ST); | |||
return o; | |||
} | |||
fixed4 fragBloom ( v2f_simple i ) : SV_Target | |||
{ | |||
float2 uv = i.uv; | |||
#if UNITY_UV_STARTS_AT_TOP | |||
uv = i.uv2; | |||
#endif | |||
fixed4 BlurredFV = tex2D(_MainTex, uv); | |||
fixed Density = min(1, tex2D(RT_FogVolumeConvolution, uv).a * _Falloff); | |||
fixed4 Scene = tex2D(_source, uv); | |||
fixed4 Blended = lerp(Scene, BlurredFV, Density); | |||
#ifdef BLOOM | |||
fixed4 Bloom = tex2D(_Bloom, uv); | |||
Blended += Bloom*Density; | |||
#endif | |||
return Blended; | |||
} | |||
fixed4 fragBlend(v2f_simple i) : SV_Target | |||
{ | |||
return 1; | |||
} | |||
fixed4 fragDownsample ( v2f_tap i ) : SV_Target | |||
{ | |||
fixed4 color = tex2D (_MainTex, i.uv20); | |||
color += tex2D (_MainTex, i.uv21); | |||
color += tex2D (_MainTex, i.uv22); | |||
color += tex2D (_MainTex, i.uv23); | |||
return max(color/4 - THRESHHOLD, 0) * ONE_MINUS_THRESHHOLD_TIMES_INTENSITY; | |||
} | |||
// weight curves | |||
static const half curve[7] = { 0.0205, 0.0855, 0.232, 0.324, 0.232, 0.0855, 0.0205 }; // gauss'ish blur weights | |||
static const half4 curve4[7] = { half4(0.0205,0.0205,0.0205,0), half4(0.0855,0.0855,0.0855,0), half4(0.232,0.232,0.232,0), | |||
half4(0.324,0.324,0.324,1), half4(0.232,0.232,0.232,0), half4(0.0855,0.0855,0.0855,0), half4(0.0205,0.0205,0.0205,0) }; | |||
struct v2f_withBlurCoords8 | |||
{ | |||
float4 pos : SV_POSITION; | |||
half4 uv : TEXCOORD0; | |||
half2 offs : TEXCOORD1; | |||
}; | |||
struct v2f_withBlurCoordsSGX | |||
{ | |||
float4 pos : SV_POSITION; | |||
half2 uv : TEXCOORD0; | |||
half4 offs[3] : TEXCOORD1; | |||
}; | |||
v2f_withBlurCoords8 vertBlurHorizontal (appdata_img v) | |||
{ | |||
v2f_withBlurCoords8 o; | |||
o.pos = UnityObjectToClipPos (v.vertex); | |||
o.uv = half4(v.texcoord.xy,1,1); | |||
o.offs = _MainTex_TexelSize.xy * half2(1.0, 0.0) * _Parameter.x; | |||
return o; | |||
} | |||
v2f_withBlurCoords8 vertBlurVertical (appdata_img v) | |||
{ | |||
v2f_withBlurCoords8 o; | |||
o.pos = UnityObjectToClipPos (v.vertex); | |||
o.uv = half4(v.texcoord.xy,1,1); | |||
o.offs = _MainTex_TexelSize.xy * half2(0.0, 1.0) * _Parameter.x; | |||
return o; | |||
} | |||
half FOV_compensation; | |||
half4 fragBlur8 ( v2f_withBlurCoords8 i ) : SV_Target | |||
{ | |||
half2 uv = i.uv.xy; | |||
half2 netFilterWidth = i.offs*FOV_compensation; | |||
half2 coords = uv - netFilterWidth * 3.0; | |||
half4 color = 0; | |||
for( int l = 0; l < 7; l++ ) | |||
{ | |||
half4 tap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(coords, _MainTex_ST)); | |||
// added casting for ps4 | |||
tap.rgb = lerp((half)Luminance(tap.rgb), (half3)tap.rgb, (half3)_Saturation); | |||
color += tap * curve4[l]; | |||
coords += netFilterWidth; | |||
} | |||
return color; | |||
} | |||
v2f_withBlurCoordsSGX vertBlurHorizontalSGX (appdata_img v) | |||
{ | |||
v2f_withBlurCoordsSGX o; | |||
o.pos = UnityObjectToClipPos (v.vertex); | |||
o.uv = v.texcoord.xy; | |||
half offsetMagnitude = _MainTex_TexelSize.x * _Parameter.x; | |||
o.offs[0] = v.texcoord.xyxy + offsetMagnitude * half4(-3.0h, 0.0h, 3.0h, 0.0h); | |||
o.offs[1] = v.texcoord.xyxy + offsetMagnitude * half4(-2.0h, 0.0h, 2.0h, 0.0h); | |||
o.offs[2] = v.texcoord.xyxy + offsetMagnitude * half4(-1.0h, 0.0h, 1.0h, 0.0h); | |||
return o; | |||
} | |||
v2f_withBlurCoordsSGX vertBlurVerticalSGX (appdata_img v) | |||
{ | |||
v2f_withBlurCoordsSGX o; | |||
o.pos = UnityObjectToClipPos (v.vertex); | |||
o.uv = half4(v.texcoord.xy,1,1); | |||
half offsetMagnitude = _MainTex_TexelSize.y * _Parameter.x; | |||
o.offs[0] = v.texcoord.xyxy + offsetMagnitude * half4(0.0h, -3.0h, 0.0h, 3.0h); | |||
o.offs[1] = v.texcoord.xyxy + offsetMagnitude * half4(0.0h, -2.0h, 0.0h, 2.0h); | |||
o.offs[2] = v.texcoord.xyxy + offsetMagnitude * half4(0.0h, -1.0h, 0.0h, 1.0h); | |||
return o; | |||
} | |||
half4 fragBlurSGX ( v2f_withBlurCoordsSGX i ) : SV_Target | |||
{ | |||
half2 uv = i.uv.xy; | |||
half4 color = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv, _MainTex_ST)) * curve4[3]; | |||
for( int l = 0; l < 3; l++ ) | |||
{ | |||
half4 tapA = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.offs[l].xy, _MainTex_ST)); | |||
half4 tapB = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.offs[l].zw, _MainTex_ST)); | |||
color += (tapA + tapB) * curve4[l]; | |||
} | |||
return color; | |||
} | |||
ENDCG | |||
SubShader { | |||
/* Stencil | |||
{ | |||
Ref 2 | |||
Comp Equal | |||
}*/ | |||
ZTest Off Cull Off ZWrite Off Blend Off | |||
// 0 | |||
Pass { | |||
CGPROGRAM | |||
#pragma vertex vertBloom | |||
#pragma fragment fragBloom | |||
ENDCG | |||
} | |||
// 1 | |||
Pass { | |||
CGPROGRAM | |||
#pragma vertex vert4Tap | |||
#pragma fragment fragDownsample | |||
ENDCG | |||
} | |||
// 2 | |||
Pass { | |||
ZTest Always | |||
Cull Off | |||
CGPROGRAM | |||
#pragma vertex vertBlurVertical | |||
#pragma fragment fragBlur8 | |||
ENDCG | |||
} | |||
// 3 | |||
Pass { | |||
ZTest Always | |||
Cull Off | |||
CGPROGRAM | |||
#pragma vertex vertBlurHorizontal | |||
#pragma fragment fragBlur8 | |||
ENDCG | |||
} | |||
// alternate blur | |||
// 4 | |||
Pass { | |||
ZTest Always | |||
Cull Off | |||
CGPROGRAM | |||
#pragma vertex vertBlurVerticalSGX | |||
#pragma fragment fragBlurSGX | |||
ENDCG | |||
} | |||
// 5 | |||
Pass { | |||
ZTest Always | |||
Cull Off | |||
CGPROGRAM | |||
#pragma vertex vertBlurHorizontalSGX | |||
#pragma fragment fragBlurSGX | |||
ENDCG | |||
} | |||
// 6 | |||
Pass | |||
{ | |||
ZTest Always | |||
Cull Off | |||
CGPROGRAM | |||
#pragma vertex vertBloom | |||
#pragma fragment fragBlend | |||
ENDCG | |||
} | |||
} | |||
FallBack Off | |||
} |
@ -0,0 +1,9 @@ | |||
fileFormatVersion: 2 | |||
guid: 3d74984d5316b894bba859ecf9c1c2c7 | |||
timeCreated: 1493069151 | |||
licenseType: Store | |||
ShaderImporter: | |||
defaultTextures: [] | |||
userData: | |||
assetBundleName: | |||
assetBundleVariant: |
@ -0,0 +1,442 @@ | |||
#ifndef FOG_VOLUME_COMMON_INCLUDED | |||
#define FOG_VOLUME_COMMON_INCLUDED | |||
float3 VolumeSpaceCoords = 0; | |||
half VerticalGrad; | |||
half2 heightGradient; | |||
half HeightAtten; | |||
float3 VolumeSpaceCoordsWorldSpace; | |||
//#ifdef VOLUMETRIC_SHADOWS | |||
half3 VolumeShadow = 1; | |||
#define _GeneralShadowOffset 0.001f | |||
#define bias 0 | |||
//Shadow params | |||
uniform float4 _ShadowCameraPosition; | |||
uniform float4x4 _ShadowCameraProjection; | |||
uniform float _ShadowCameraSize; | |||
uniform sampler2D _ShadowTexture; | |||
//#define _VolumetricShadowsEnabled 0 | |||
uniform int _VolumetricShadowsEnabled = 0; | |||
float4 when_eq(float4 x, float4 y) { | |||
return 1.0 - abs(sign(x - y)); | |||
} | |||
float3 when_eq(float3 x, float3 y) { | |||
return 1.0 - abs(sign(x - y)); | |||
} | |||
float when_eq(float x, float y) { | |||
return 1.0 - abs(sign(x - y)); | |||
} | |||
float FrameShadow(in float2 shadowUVs, in float3 worldPos) { | |||
float FinalShadow = 1; | |||
float2 ShadowMap = tex2Dlod(_ShadowTexture, float4(shadowUVs, 0, 0)).rg; | |||
float d = ShadowMap.x; | |||
//if (d < .0001)FinalShadow = 1.0; | |||
//else | |||
//{ | |||
float theLength = distance(worldPos, _ShadowCameraPosition); | |||
FinalShadow = theLength < d + bias ? 1.0f : 0.0f; | |||
//} | |||
//fade before reaching the end | |||
half edges = ShadowMap.y; | |||
return lerp(1,FinalShadow, edges); | |||
} | |||
//#endif | |||
float sdSphere(float3 p, float s) | |||
{ | |||
return (length(p) - s); | |||
} | |||
float sdBox(float3 p, float3 b) | |||
{ | |||
float3 d = abs(p) - b; | |||
d = (min(max(d.x, max(d.y, d.z)), 0.0) + length(max(d, 0.0))); | |||
return d; | |||
} | |||
float udBox(float3 p, float3 b) | |||
{ | |||
return length(max(abs(p) - b, 0.0)); | |||
} | |||
float PrimitiveShape(fixed ShapeType, float3 p, float3 s) | |||
{ | |||
if (ShapeType <= 1.0f)//Box | |||
return sdBox(p, s); | |||
else | |||
if (ShapeType <= 2.0f)//Sphere | |||
return sdSphere(p, s); | |||
else return .0f; | |||
} | |||
float nrand(float2 ScreenUVs) | |||
{ | |||
return frac(sin(ScreenUVs.x * 12.9898 + ScreenUVs.y * 78.233) * 43758.5453); | |||
} | |||
float remap_tri(float v) | |||
{ | |||
float orig = v * 2.0 - 1.0; | |||
v = max(-1.0, orig / sqrt(abs(orig))); | |||
return v - sign(orig) + 0.5; | |||
} | |||
bool IntersectBox(float3 startpoint, float3 direction, float3 boxmin, float3 boxmax, out float tnear, out float tfar) | |||
{ | |||
// compute intersection of ray with all six bbox planes | |||
float3 invR = 1.0 / direction; | |||
float3 tbot = invR * (boxmin.xyz - startpoint); | |||
float3 ttop = invR * (boxmax.xyz - startpoint); | |||
// re-order intersections to find smallest and largest on each axis | |||
float3 tmin = min(ttop, tbot); | |||
float3 tmax = max(ttop, tbot); | |||
// find the largest tmin and the smallest tmax | |||
float2 t0 = max(tmin.xx, tmin.yz); | |||
tnear = max(t0.x, t0.y); | |||
t0 = min(tmax.xx, tmax.yz); | |||
tfar = min(t0.x, t0.y); | |||
// check for hit | |||
bool hit; | |||
if ((tnear > tfar)) | |||
hit = false; | |||
else | |||
hit = true; | |||
return hit; | |||
} | |||
half3 ToneMap(half3 x, half exposure) | |||
{ | |||
//Photographic | |||
return 1 - exp2(-x * exposure); | |||
} | |||
#define PI 3.1416 | |||
//http://zurich.disneyresearch.com/~wjarosz/publications/dissertation/chapter4.pdf | |||
float Henyey(float3 E, float3 L, float mieDirectionalG) | |||
{ | |||
float theta = saturate(dot(E, L)); | |||
return (1.0 / (4.0 * PI)) * ((1.0 - mieDirectionalG * mieDirectionalG) / pow(1.0 - 2.0 * mieDirectionalG * theta + mieDirectionalG * mieDirectionalG, 1.5)); | |||
} | |||
half3 ContrastF(half3 pixelColor, fixed contrast) | |||
{ | |||
return saturate(((pixelColor.rgb - 0.5f) * max(contrast, 0)) + 0.5f); | |||
} | |||
float3 rotate(float3 p, float rot) | |||
{ | |||
float3 r = 0; | |||
#ifdef Twirl_X | |||
float3x3 rx = float3x3(1.0, 0.0, 0.0, 0.0, cos(rot), sin(rot), 0.0, -sin(rot), cos(rot)); | |||
r = mul(p, rx); | |||
#endif | |||
#ifdef Twirl_Y | |||
float3x3 ry = float3x3(cos(rot), 0.0, -sin(rot), 0.0, 1.0, 0.0, sin(rot), 0.0, cos(rot)); | |||
r = mul(p, ry); | |||
#endif | |||
#ifdef Twirl_Z | |||
float3x3 rz = float3x3(cos(rot), -sin(rot), 0.0, sin(rot), cos(rot), 0.0, 0.0, 0.0, 1.0); | |||
r = mul(p, rz); | |||
#endif | |||
return r; | |||
} | |||
half HeightGradient(float H, half H0, half Hmax) | |||
{ | |||
return saturate((H - H0) / (Hmax - H0)); | |||
} | |||
half Threshold(float a, float Gain, float Contrast) | |||
{ | |||
float input = a * Gain; | |||
//float thresh = input - Contrast; | |||
float thresh = ContrastF(input, Contrast); | |||
return saturate(lerp(0.0f, input, thresh)); | |||
} | |||
half PrimitiveAccum = 1; | |||
#ifdef _FOG_VOLUME_NOISE | |||
float NoiseSamplerLoop(float3 p) | |||
{ | |||
float n = 0, iter = 1; | |||
for (int i = 0; i < Octaves; i++) | |||
{ | |||
p /= 1 + i*.06; | |||
p += Speed.rgb *_BaseRelativeSpeed * (i*.15 + 1); | |||
#ifdef EARTH_CLOUD_STYLE | |||
n += tex3Dlod(_NoiseVolume, float4(p * float3(.5, 1, .5), 0)); | |||
n += tex3Dlod(_NoiseVolume, float4(p*.3, 0))*2+ (heightGradient.x); | |||
n = (n-1); //n *= n*.57; | |||
#else | |||
n += tex3Dlod(_NoiseVolume, float4(p, 0)); | |||
#endif | |||
} | |||
n = n / Octaves; | |||
/*if (Octaves > 1) | |||
{ | |||
n++; | |||
n *= tex3Dlod(_NoiseVolume, float4(p *.75, 0)); | |||
}*/ | |||
return n; | |||
} | |||
float noise(in float3 p, half DistanceFade) | |||
{ | |||
float Volume = 0; | |||
float lowFreqScale = BaseTiling; | |||
half NoiseBaseLayers = 0; | |||
if (Coverage > 0.01) | |||
NoiseBaseLayers = NoiseSamplerLoop(p * lowFreqScale); | |||
#ifdef DF | |||
NoiseBaseLayers = Threshold(NoiseBaseLayers, Coverage * NoiseAtten*PrimitiveAccum, threshold); | |||
#else | |||
NoiseBaseLayers = Threshold(NoiseBaseLayers, Coverage * NoiseAtten, threshold); | |||
#endif | |||
half NoiseDetail = 0; | |||
half BaseMask = saturate((1 - NoiseBaseLayers * _DetailMaskingThreshold)); | |||
if (DistanceFade > 0 && NoiseBaseLayers>0 && BaseMask>0)//no me samplees donde ya es opaco del tó | |||
{ | |||
NoiseDetail += BaseMask*DistanceFade*(tex3Dlod(_NoiseVolume, float4(p*DetailTiling + Speed * _DetailRelativeSpeed, 0)).r); | |||
if (Octaves > 1 ) | |||
NoiseDetail += DistanceFade*(tex3Dlod(_NoiseVolume, | |||
//size and offset | |||
float4(p * .5 * DetailTiling + .5 | |||
//distortion | |||
+ NoiseDetail * _Curl * BaseMask * 2.0 - 1.0 | |||
//animation | |||
+ Speed * _DetailRelativeSpeed, 0)).r) * 1.5 * BaseMask; | |||
NoiseDetail = Threshold(NoiseDetail, 1, 0); | |||
} | |||
//base layer (coverage) | |||
Volume += NoiseBaseLayers; | |||
//add detail layer | |||
Volume -= NoiseDetail * _NoiseDetailRange; | |||
Volume *= 1 + _NoiseDetailRange; | |||
Volume *= NoiseDensity; | |||
return saturate(Volume); | |||
} | |||
//http://flafla2.github.io/2016/10/01/raymarching.html | |||
float3 calcNormal(in float3 pos, half DistanceFade) | |||
{ | |||
// epsilon - used to approximate dx when taking the derivative | |||
const float2 eps = float2(NormalDistance, 0.0); | |||
// The idea here is to find the "gradient" of the distance field at pos | |||
// Remember, the distance field is not boolean - even if you are inside an object | |||
// the number is negative, so this calculation still works. | |||
// Essentially you are approximating the derivative of the distance field at this point. | |||
float3 nor = float3( | |||
noise(pos + eps.xyy, DistanceFade).x - noise(pos - eps.xyy, DistanceFade).x, | |||
noise(pos + eps.yxy, DistanceFade).x - noise(pos - eps.yxy, DistanceFade).x, | |||
noise(pos + eps.yyx, DistanceFade).x - noise(pos - eps.yyx, DistanceFade).x); | |||
return normalize(nor); | |||
} | |||
#endif | |||
#if _FOG_VOLUME_NOISE && _SHADE | |||
half ShadowGrad(half ShadowThreshold, half SampleDiff) | |||
{ | |||
return saturate(ShadowThreshold / (ShadowThreshold - SampleDiff)); | |||
} | |||
half ShadowShift = .05; | |||
//#define _SelfShadowSteps 20 | |||
float Shadow(float3 ShadowCoords, v2f i, half detailDist, half3 LightVector, half NoiseAtten) | |||
{ | |||
float ShadowThreshold = noise(ShadowCoords, detailDist); | |||
float3 LightStep = /*_LightLocalDirection*/LightVector / (float)_SelfShadowSteps; | |||
float accum = 0; | |||
float3 ShadowCoordsStep = ShadowCoords; | |||
for (int k = 0; k <= _SelfShadowSteps && NoiseAtten>0; k++, ShadowCoordsStep += LightStep) | |||
{ | |||
float NoiseSample = 0; | |||
float SampleDiff = 0; | |||
if (ShadowThreshold > 0 && accum < 1) | |||
{ | |||
NoiseSample = noise(ShadowCoordsStep, detailDist); | |||
SampleDiff = ShadowThreshold - NoiseSample; | |||
if (SampleDiff <= 0) | |||
{ | |||
if (ShadowThreshold > 0) | |||
{ | |||
accum += 1 - ShadowGrad(ShadowThreshold, SampleDiff); | |||
} | |||
else | |||
{ | |||
accum += 1; | |||
} | |||
} | |||
else | |||
if (ShadowThreshold <= 0) | |||
{ | |||
accum += ShadowGrad(ShadowThreshold, SampleDiff); | |||
} | |||
} | |||
} | |||
//return accum; | |||
return saturate(1 - accum); | |||
} | |||
#endif | |||
float4 PointLight(float3 LightPosition, float3 VolumePosition, | |||
half size, half3 color, half LightAttenuation, v2f i) | |||
{ | |||
//#define ATTEN_METHOD_2 | |||
half d = distance(LightPosition, VolumePosition) / size; | |||
float Attenuation = 0; | |||
half UnityScaleMatch = 5; | |||
//https://en.wikipedia.org/wiki/Optical_depth | |||
#ifdef ATTEN_METHOD_1 | |||
Attenuation = exp(-d)*UnityScaleMatch; | |||
#endif | |||
#ifdef ATTEN_METHOD_2 | |||
Attenuation = UnityScaleMatch / (4 * PI*d*d); | |||
#endif | |||
//Linear | |||
#ifdef ATTEN_METHOD_3 | |||
Attenuation = saturate(1 - d / UnityScaleMatch); | |||
#endif | |||
return float4(Attenuation * LightAttenuation * color, Attenuation* LightAttenuation); | |||
} | |||
float4 SpotLight(float3 LightPosition, float3 VolumePosition, | |||
half size, half3 color, half LightAttenuation, float4 Direction, half Angle, half fallof, v2f i) | |||
{ | |||
float3 spotDir = normalize(Direction.xyz); | |||
Angle *= .5;//Unity match | |||
float coneAngle = Angle;//inner angle | |||
float coneDelta = Angle + fallof;//outer angle | |||
float3 lray = normalize(LightPosition - VolumePosition); | |||
float SpotCone = (dot(lray, -spotDir) - cos(radians(coneDelta))) / (cos(radians(coneAngle)) - cos(radians(coneDelta))); | |||
SpotCone = max(0, SpotCone); | |||
float4 _PointLight = PointLight(LightPosition, VolumePosition, | |||
size, color, LightAttenuation, i); | |||
return SpotCone * _PointLight; | |||
// half d = distance(LightPosition, VolumePosition) / size; | |||
// float Attenuation = 0; | |||
// half UnityScaleMatch = 5; | |||
// //https://en.wikipedia.org/wiki/Optical_depth | |||
//#ifdef ATTEN_METHOD_1 | |||
// Attenuation = exp(-d)*UnityScaleMatch; | |||
//#endif | |||
// | |||
//#ifdef ATTEN_METHOD_2 | |||
// Attenuation = UnityScaleMatch / (4 * PI*d*d); | |||
//#endif | |||
// | |||
// //Linear | |||
//#ifdef ATTEN_METHOD_3 | |||
// Attenuation = saturate(1 - d / UnityScaleMatch); | |||
// | |||
// | |||
//#endif | |||
// return float4(Attenuation * SpotCone * LightAttenuation * color, Attenuation* LightAttenuation); | |||
} | |||
#if UNITY_LIGHT_PROBE_PROXY_VOLUME | |||
// normal should be normalized, w=1.0 | |||
half3 FVSHEvalLinearL0L1_SampleProbeVolume(half4 normal, float3 worldPos) | |||
{ | |||
const float transformToLocal = unity_ProbeVolumeParams.y; | |||
const float texelSizeX = unity_ProbeVolumeParams.z; | |||
//The SH coefficients textures and probe occlusion are packed into 1 atlas. | |||
//------------------------- | |||
//| ShR | ShG | ShB | Occ | | |||
//------------------------- | |||
float3 position = (transformToLocal == 1.0f) ? mul(unity_ProbeVolumeWorldToObject, float4(worldPos, 1.0)).xyz : worldPos; | |||
float3 texCoord = (position - unity_ProbeVolumeMin.xyz) * unity_ProbeVolumeSizeInv.xyz; | |||
texCoord.x = texCoord.x * 0.25f; | |||
// We need to compute proper X coordinate to sample. | |||
// Clamp the coordinate otherwize we'll have leaking between RGB coefficients | |||
float texCoordX = clamp(texCoord.x, 0.5f * texelSizeX, 0.25f - 0.5f * texelSizeX); | |||
// sampler state comes from SHr (all SH textures share the same sampler) | |||
texCoord.x = texCoordX; | |||
half4 SHAr = UNITY_SAMPLE_TEX3D_SAMPLER_LOD(unity_ProbeVolumeSH, unity_ProbeVolumeSH, texCoord, 0); | |||
texCoord.x = texCoordX + 0.25f; | |||
half4 SHAg = UNITY_SAMPLE_TEX3D_SAMPLER_LOD(unity_ProbeVolumeSH, unity_ProbeVolumeSH, texCoord, 0); | |||
texCoord.x = texCoordX + 0.5f; | |||
half4 SHAb = UNITY_SAMPLE_TEX3D_SAMPLER_LOD(unity_ProbeVolumeSH, unity_ProbeVolumeSH, texCoord, 0); | |||
// Linear + constant polynomial terms | |||
half3 x1; | |||
x1.r = dot(SHAr, normal); | |||
x1.g = dot(SHAg, normal); | |||
x1.b = dot(SHAb, normal); | |||
return x1; | |||
} | |||
#endif | |||
half3 ShadeSHPerPixel(half3 normal, half3 ambient, float3 worldPos) | |||
{ | |||
half3 ambient_contrib = 0.0; | |||
// L2 per-vertex, L0..L1 & gamma-correction per-pixel | |||
// Ambient in this case is expected to be always Linear, see ShadeSHPerVertex() | |||
#if UNITY_LIGHT_PROBE_PROXY_VOLUME | |||
if (unity_ProbeVolumeParams.x == 1.0) | |||
ambient_contrib = FVSHEvalLinearL0L1_SampleProbeVolume(half4(normal, 1.0), worldPos); | |||
else | |||
ambient_contrib = SHEvalLinearL0L1(half4(normal, 1.0)); | |||
#else | |||
ambient_contrib = 1;// SHEvalLinearL0L1(half4(normal, 1.0)); | |||
#endif | |||
ambient = max(half3(0, 0, 0), ambient + ambient_contrib); // include L2 contribution in vertex shader before clamp. | |||
#ifdef UNITY_COLORSPACE_GAMMA | |||
ambient = LinearToGammaSpace(ambient); | |||
#endif | |||
return ambient; | |||
} | |||
#endif |
@ -0,0 +1,9 @@ | |||
fileFormatVersion: 2 | |||
guid: f5b748ddd58b58f41bb2a7f49c34ed17 | |||
timeCreated: 1482735144 | |||
licenseType: Store | |||
ShaderImporter: | |||
defaultTextures: [] | |||
userData: | |||
assetBundleName: | |||
assetBundleVariant: |
@ -0,0 +1,61 @@ | |||
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)' | |||
Shader "Hidden/FogVolumeDensityFilter" { | |||
Properties{ _MainTex("", any) = "" {} } | |||
CGINCLUDE | |||
#include "UnityCG.cginc" | |||
struct v2f { | |||
float4 pos : SV_POSITION; | |||
half2 uv : TEXCOORD0; | |||
half2 taps[4] : TEXCOORD1; | |||
}; | |||
sampler2D _MainTex; | |||
half4 _MainTex_TexelSize; | |||
half4 _BlurOffsets; | |||
half FOV_compensation; | |||
//half _Distortion = -0.01; | |||
sampler2D RT_FogVolumeConvolution, RT_FogVolume, _source; | |||
v2f vert(appdata_img v) { | |||
v2f o; | |||
o.pos = UnityObjectToClipPos(v.vertex); | |||
o.uv = v.texcoord - _BlurOffsets.xy * _MainTex_TexelSize.xy; // hack, see BlurEffect.cs for the reason for this. let's make a new blur effect soon | |||
o.taps[0] = o.uv + _MainTex_TexelSize * _BlurOffsets.xy*FOV_compensation; | |||
o.taps[1] = o.uv - _MainTex_TexelSize * _BlurOffsets.xy*FOV_compensation; | |||
o.taps[2] = o.uv + _MainTex_TexelSize * _BlurOffsets.xy * half2(1, -1)*FOV_compensation; | |||
o.taps[3] = o.uv - _MainTex_TexelSize * _BlurOffsets.xy * half2(1, -1)*FOV_compensation; | |||
return o; | |||
} | |||
half4 frag(v2f i) : SV_Target{ | |||
//distortion experiment | |||
/*half4 FV = tex2D(RT_FogVolumeConvolution, i.uv); | |||
half4 TexturedFogVolumes = tex2D(RT_FogVolume, i.uv); | |||
half Distortion = FV.a * _Distortion * TexturedFogVolumes.a + 1; | |||
half4 color = tex2D(_MainTex, (i.taps[0]-0.5)* Distortion + 0.5); | |||
color += tex2D(_MainTex, (i.taps[1] - 0.5)* Distortion + 0.5); | |||
color += tex2D(_MainTex, (i.taps[2] - 0.5)* Distortion + 0.5); | |||
color += tex2D(_MainTex, (i.taps[3] - 0.5)* Distortion + 0.5);*/ | |||
half4 color = tex2D(_MainTex, i.taps[0]); | |||
color += tex2D(_MainTex, i.taps[1]); | |||
color += tex2D(_MainTex, i.taps[2]); | |||
color += tex2D(_MainTex, i.taps[3]); | |||
return color *.25; | |||
} | |||
ENDCG | |||
SubShader { | |||
Pass{ | |||
ZTest Always Cull Off ZWrite Off | |||
CGPROGRAM | |||
#pragma vertex vert | |||
#pragma fragment frag | |||
ENDCG | |||
} | |||
} | |||
Fallback off | |||
} |
@ -0,0 +1,4 @@ | |||
fileFormatVersion: 2 | |||
guid: 41bd7c126b62f0f43bf23f03983cf29c | |||
ShaderImporter: | |||
userData: |
@ -0,0 +1,164 @@ | |||
// Upgrade NOTE: removed variant '__' where variant LOD_FADE_PERCENTAGE is used. | |||
Shader "Hidden/FogVolumeDirectionalLight" | |||
{ | |||
Properties | |||
{ | |||
_Cutoff("Alpha cutoff", Range(0,1)) = 0.5 | |||
_MainTex("Base (RGB)", 2D) = "white" {} | |||
_Color("Color", Color) = (1,1,1,1) | |||
//_FogVolumeShadowMapEdgeSoftness("Edge size", Range(1, 100))=100 | |||
} | |||
SubShader | |||
{ | |||
Tags{ "RenderType" = "Opaque" } | |||
Pass | |||
{ | |||
CGPROGRAM | |||
#define EDGE_FIX | |||
#pragma vertex vert | |||
#pragma fragment frag | |||
#include "UnityCG.cginc" | |||
uniform sampler2D _MainTex; | |||
float4 _ShadowCameraPosition; | |||
uniform float _Cutoff = 1, _FogVolumeShadowMapEdgeSoftness; | |||
struct v2f | |||
{ | |||
float4 pos : SV_POSITION; | |||
float depth : DEPTH; | |||
float2 uv : TEXCOORD0; | |||
float4 screenUV : TEXCOORD1; | |||
}; | |||
v2f vert(appdata_base v) | |||
{ | |||
v2f o; | |||
o.pos = UnityObjectToClipPos(v.vertex); | |||
o.depth = length(mul(unity_ObjectToWorld, v.vertex).xyz - _ShadowCameraPosition.xyz); | |||
o.uv = v.texcoord.xy; | |||
o.screenUV = ComputeScreenPos(o.pos); | |||
return o; | |||
} | |||
float4 frag(v2f i) : COLOR | |||
{ | |||
float2 uv = i.screenUV.xy / i.screenUV.w; | |||
float d = i.depth; | |||
#ifdef EDGE_FIX | |||
half edges = saturate(dot(1-uv.r, 1-uv.g) * dot(uv.r, uv.g)*600); | |||
d = lerp(10000, d, edges); | |||
#endif | |||
half fade = saturate(dot(1 - uv.r, 1 - uv.g) * dot(uv.r, uv.g)*_FogVolumeShadowMapEdgeSoftness); | |||
fade *= fade*fade; | |||
return float4(d, fade, 0.0f, 1); | |||
} | |||
ENDCG | |||
} | |||
} | |||
SubShader | |||
{ | |||
Tags{ "RenderType" = "TransparentCutout" } | |||
Pass | |||
{ | |||
CGPROGRAM | |||
#define EDGE_FIX | |||
#pragma vertex vert | |||
#pragma fragment frag | |||
#include "UnityCG.cginc" | |||
uniform sampler2D _MainTex; | |||
float4 _ShadowCameraPosition; | |||
uniform float _Cutoff = 1, _FogVolumeShadowMapEdgeSoftness; | |||
float4 _Color; | |||
struct v2f | |||
{ | |||
float4 pos : SV_POSITION; | |||
float depth : DEPTH; | |||
float2 uv : TEXCOORD0; | |||
float4 screenUV : TEXCOORD1; | |||
}; | |||
v2f vert(appdata_base v) | |||
{ | |||
v2f o; | |||
o.pos = UnityObjectToClipPos(v.vertex); | |||
o.depth = length(mul(unity_ObjectToWorld, v.vertex).xyz - _ShadowCameraPosition.xyz); | |||
o.uv = v.texcoord.xy; | |||
o.screenUV = ComputeScreenPos(o.pos); | |||
return o; | |||
} | |||
float4 frag(v2f i) : COLOR | |||
{ | |||
half4 c = tex2D(_MainTex, i.uv)*_Color; | |||
float2 uv = i.screenUV.xy / i.screenUV.w; | |||
clip(c.a - _Cutoff); | |||
float d = i.depth; | |||
#ifdef EDGE_FIX | |||
half edges = saturate(dot(1 - uv.r, 1 - uv.g) * dot(uv.r, uv.g) * 600); | |||
d = lerp(10000, d, edges); | |||
#endif | |||
half fade = saturate(dot(1 - uv.r, 1 - uv.g) * dot(uv.r, uv.g)*_FogVolumeShadowMapEdgeSoftness); | |||
fade *= fade*fade; | |||
return float4(d, fade, 0.0f, 1); | |||
} | |||
ENDCG | |||
} | |||
} | |||
SubShader | |||
{ | |||
Tags | |||
{ | |||
"Queue" = "Geometry" | |||
"IgnoreProjector" = "True" | |||
"RenderType" = "SpeedTree" | |||
"DisableBatching" = "LODFading" | |||
} | |||
Cull[_Cull] | |||
Fog{ Mode Off } | |||
CGPROGRAM | |||
uniform sampler2D _MainTex; | |||
float4 /*_ShadowCameraPosition,*/ _Color; | |||
uniform float _Cutoff = 1, _FogVolumeShadowMapEdgeSoftness; | |||
#pragma surface surf Lambert vertex:SpeedTreeVert nolightmap | |||
#pragma target 3.0 | |||
#pragma multi_compile LOD_FADE_PERCENTAGE LOD_FADE_CROSSFADE | |||
#pragma shader_feature GEOM_TYPE_BRANCH GEOM_TYPE_BRANCH_DETAIL GEOM_TYPE_FROND GEOM_TYPE_LEAF GEOM_TYPE_MESH | |||
#define ENABLE_WIND | |||
#define SPEEDTREE_ALPHATEST | |||
#define EDGE_FIX | |||
#include "SpeedTreeCommonDepth.cginc" | |||
void surf(Input i, inout SurfaceOutput OUT) | |||
{ | |||
float2 uv = i.screenUV.xy / i.screenUV.w; | |||
float d = i.ShadowDepth; | |||
#ifdef EDGE_FIX | |||
half edges = saturate(dot(1 - uv.r, 1 - uv.g) * dot(uv.r, uv.g) * 600); | |||
d = lerp(10000, d, edges); | |||
#endif | |||
half fade = saturate(dot(1 - uv.r, 1 - uv.g) * dot(uv.r, uv.g)*_FogVolumeShadowMapEdgeSoftness); | |||
fade *= fade*fade; | |||
OUT.Emission = float3(d, fade, 0.0f); | |||
SpeedTreeFragOut o; | |||
SpeedTreeFrag(i, o); | |||
SPEEDTREE_COPY_FRAG(OUT, o) | |||
} | |||
ENDCG | |||
} | |||
} |
@ -0,0 +1,9 @@ | |||
fileFormatVersion: 2 | |||
guid: 4fc2932190d974a4887533f0e52baf6c | |||
timeCreated: 1496863314 | |||
licenseType: Store | |||
ShaderImporter: | |||
defaultTextures: [] | |||
userData: | |||
assetBundleName: | |||
assetBundleVariant: |
@ -0,0 +1,820 @@ | |||
// Upgrade NOTE: replaced '_Object2World' with 'unity_ObjectToWorld' | |||
#ifndef FOG_VOLUME_FRAGMENT_INCLUDED | |||
#define FOG_VOLUME_FRAGMENT_INCLUDED | |||
#define HALF_MAX 65504.0 | |||
// Clamp HDR value within a safe range | |||
inline half SafeHDR(half c) { return min(c, HALF_MAX); } | |||
inline half2 SafeHDR(half2 c) { return min(c, HALF_MAX); } | |||
inline half3 SafeHDR(half3 c) { return min(c, HALF_MAX); } | |||
inline half4 SafeHDR(half4 c) { return min(c, HALF_MAX); } | |||
float4 frag(v2f i) : SV_Target | |||
{ | |||
float3 ViewDir = normalize(i.LocalPos - i.LocalEyePos); | |||
float tmin = 0.0, tmax = 0.0; | |||
bool hit = IntersectBox(i.LocalEyePos, ViewDir, _BoxMin.xyz, _BoxMax.xyz, tmin, tmax); | |||
if (!hit) | |||
discard; | |||
//likely to resolve to a free modifier | |||
if (tmin < 0) | |||
tmin = 0; | |||
float4 ScreenUVs = UNITY_PROJ_COORD(i.ScreenUVs); | |||
float2 screenUV = ScreenUVs.xy / ScreenUVs.w; | |||
float Depth = 0; | |||
#if _FOG_LOWRES_RENDERER && !ExternalDepth | |||
//low res | |||
#ifdef FOG_VOLUME_STEREO_ON | |||
//left eye | |||
if (unity_CameraProjection[0][2] < 0)//lo estaba haciendo con unity_StereoEyeIndex, pero por algún motivo, no se entera | |||
{ | |||
Depth = tex2D(RT_Depth, screenUV); | |||
} | |||
//right eye | |||
else //if (unity_CameraProjection[0][2] > 0) | |||
{ | |||
Depth = tex2Dlod(RT_DepthR, float4(screenUV, 0, 0)); | |||
} | |||
#else | |||
Depth = tex2Dlod(RT_Depth, float4(screenUV, 0, 0)); | |||
#endif | |||
Depth = 1.0 / Depth; | |||
//#else | |||
//#ifdef ExternalDepth | |||
// //injected from water asset | |||
// float Depth = tex2D(_CustomCameraDepthTexture, screenUV).r; | |||
// Depth = 1.0 / Depth; | |||
// | |||
//#else | |||
//full res or Scene view | |||
// float Depth = tex2D(_CameraDepthTexture, screenUV).r; | |||
// Depth = LinearEyeDepth(Depth); | |||
//#endif | |||
#endif | |||
#ifdef ExternalDepth | |||
//injected from water asset | |||
Depth = tex2D(_CustomCameraDepthTexture, screenUV).r; | |||
Depth = 1.0 / Depth; | |||
#else | |||
#if !_FOG_LOWRES_RENDERER | |||
//full res or Scene view | |||
Depth = tex2D(_CameraDepthTexture, screenUV).r; | |||
Depth = LinearEyeDepth(Depth); | |||
#endif | |||
#endif | |||
//probando | |||
//Depth = tex2D(_CameraDepthTexture, screenUV).r; | |||
//Depth = LinearEyeDepth(Depth); | |||
//return float4( Depth.xxx, 1); | |||
Depth = length(Depth / normalize(i.ViewPos).z); | |||
float thickness = min(max(tmin, tmax), Depth) - min(min(tmin, tmax), Depth); | |||
float Fog = thickness / _Visibility; | |||
Fog = 1.0 - exp(-Fog); | |||
//return Fog; | |||
float4 Final = 0; | |||
float3 Normalized_CameraWorldDir = normalize(i.Wpos - _WorldSpaceCameraPos); | |||
float3 CameraLocalDir = (i.LocalPos - i.LocalEyePos); | |||
half InscatteringDistanceClamp = saturate(Depth / InscatteringTransitionWideness - InscatteringStartDistance); | |||
// half InscatteringDistanceClamp = saturate((InscatteringTransitionWideness -Depth) / (InscatteringTransitionWideness- InscatteringStartDistance)); | |||
half4 PointLightAccum = 0; | |||
float4 PointLightsFinal = 0; | |||
#if _FOG_VOLUME_NOISE || _FOG_GRADIENT | |||
half jitter = 1; | |||
#ifdef JITTER | |||
jitter = remap_tri(nrand(ScreenUVs + frac(_Time.x))); | |||
jitter = lerp(1, jitter, _jitter); | |||
#endif | |||
float4 Noise = 1; | |||
float3 ShadowColor = 0; | |||
float3 rayStart = i.LocalEyePos + ViewDir * tmin; | |||
float3 rayStop = i.LocalEyePos + ViewDir * tmax; | |||
float3 rayDir = rayStop - rayStart; | |||
float RayLength = length(rayDir); | |||
Speed *= _Time.x; | |||
float4 FinalNoise = 0; | |||
float4 Gradient = 1; | |||
half Contact = 1; | |||
half3 AmbientColor = 1; | |||
half DistanceFade = 0; | |||
half SphereDistance = 0; | |||
half DetailCascade0 = 0; | |||
half DetailCascade1 = 0; | |||
half DetailCascade2 = 0; | |||
half3 Phase = 0; | |||
/*half*/ PrimitiveAccum = 1; | |||
float3 normal = float3(0, 0, 1); | |||
half LambertTerm = 1; | |||
float3 LightTerms = 0; | |||
half SelfShadows = 1; | |||
float OpacityTerms = 0; | |||
half4 debugOutput = 1; | |||
float DirectLightingShadowStepSize = (1.0 / (float)DirectLightingShadowSteps)*_DirectionalLightingDistance; | |||
float3 LightVector = _LightLocalDirection; | |||
//LightVector.xz = LightVector.zx; | |||
//LightVector.z = -LightVector.z; | |||
//LightVector *= DirectLightingShadowStepSize; | |||
float DirectionalLightingAccum = 1; | |||
float3 DirectionalLighting = 1; | |||
half3 AmbientTerm = 1; | |||
half Lambert = 1; | |||
half absorption = 1; | |||
half LightShafts = 1; | |||
half4 VolumeFog = 0; | |||
half LighsShaftsLightVectorConstrain = VolumeSize.y / VolumeSize.x; | |||
float3 LightShaftsDir = L; | |||
LightShaftsDir.xz = LighsShaftsLightVectorConstrain * LightShaftsDir.zx; | |||
float4 debugIterations = float4(0,0,0,1); | |||
float t = 0, dt = _RayStep; | |||
float3 r0 = rayStart; | |||
float3 rd = normalize(rayDir); | |||
#ifdef SAMPLING_METHOD_ViewAligned | |||
float PlaneNdotRay = dot(rd, i.SliceNormal); | |||
dt = _RayStep / abs(PlaneNdotRay); | |||
t = dt - fmod(dot(r0, i.SliceNormal), _RayStep) / PlaneNdotRay; | |||
#endif | |||
#ifdef JITTER | |||
t *= jitter; | |||
dt *= jitter; | |||
#endif | |||
half VolumeRayDistanceTraveled = 0; | |||
for (int s = 1; s < STEP_COUNT && RayLength>0; s += 1, t += dt, RayLength -= dt) | |||
{ | |||
dt *= 1 + s * s * s * _OptimizationFactor;//live fast and die young | |||
float3 pos = r0 + rd * t; | |||
VolumeSpaceCoords = pos; | |||
// added casting for ps4 | |||
VolumeSpaceCoordsWorldSpace = mul((float3x3)unity_ObjectToWorld, (float3)VolumeSpaceCoords) + _VolumePosition; | |||
float3 NoiseCoordinates = VolumeSpaceCoords * (_3DNoiseScale * Stretch.rgb); | |||
//DistanceFade = distance(VolumeSpaceCoords, i.LocalEyePos); | |||
DistanceFade = distance(VolumeSpaceCoordsWorldSpace, _WorldSpaceCameraPos);//3.2.1 | |||
DetailCascade0 = 1 - saturate(DistanceFade / DetailDistance); | |||
DetailCascade1 = 1 - saturate(DistanceFade / DirectLightingDistance); | |||
#if SHADER_API_GLCORE || SHADER_API_D3D11 || SHADER_API_METAL | |||
#if ATTEN_METHOD_1 || ATTEN_METHOD_2 || ATTEN_METHOD_3 | |||
DetailCascade2 = 1 - saturate(DistanceFade * PointLightingDistance2Camera); | |||
#endif | |||
#endif | |||
DistanceFade = saturate(DistanceFade / FadeDistance); | |||
DistanceFade = 1 - DistanceFade; | |||
if (DistanceFade < .001) break; | |||
//#ifdef _COLLISION | |||
if (Collisions != 0) | |||
{ | |||
Contact = saturate((Depth - distance(VolumeSpaceCoords, i.LocalEyePos))*_SceneIntersectionSoftness); | |||
if (Contact < .01) | |||
break; | |||
//#endif | |||
} | |||
#ifdef DF | |||
PrimitiveAccum = 0; | |||
half3 p = 0; | |||
//Additive primitives | |||
for (int k = 0; k < _PrimitiveCount; k++) | |||
{ | |||
if (_PrimitiveActionType(k) <= 1.0f) | |||
{ | |||
p = mul(_PrimitivesTransform[k], VolumeSpaceCoords - _PrimitivePosition[k]); | |||
PrimitiveAccum = max(PrimitiveAccum, 1 - (PrimitiveShape(_PrimitiveShapeType(k), p, _PrimitiveScale[k] * .5) + Constrain)); | |||
} | |||
} | |||
//Subtractive primitives | |||
for (int n = 0; n < _PrimitiveCount; n++) | |||
{ | |||
if (_PrimitiveActionType(k) > 1.0f) | |||
{ | |||
p = mul(_PrimitivesTransform[n], VolumeSpaceCoords - _PrimitivePosition[n]); | |||
PrimitiveAccum = min(PrimitiveAccum, (PrimitiveShape(_PrimitiveShapeType(n), p, _PrimitiveScale[n] * .5) + Constrain)); | |||
} | |||
} | |||
//Final adjustments | |||
PrimitiveAccum = ContrastF(PrimitiveAccum * _PrimitiveEdgeSoftener, 1); | |||
#endif | |||
#if defined(_FOG_GRADIENT) | |||
half2 GradientCoords = VolumeSpaceCoords.xy / (_BoxMax.xy - _BoxMin.xy) - .5f; | |||
GradientCoords.y *= 0.95;//correct bottom. must check in the future what's wrong with the uv at the edges | |||
GradientCoords.y -= 0.04;//3.1.1 | |||
//if(PrimitiveAccum>.99) | |||
if (gain>0) | |||
Gradient = tex2Dlod(_Gradient, half4(GradientCoords, 0, 0)); | |||
#endif | |||
VerticalGrad = (VolumeSpaceCoords.y / (_BoxMax.y - _BoxMin.y) + 0.5); | |||
#ifdef VOLUME_FOG | |||
if (OpacityTerms <1) | |||
VolumeRayDistanceTraveled++; | |||
float VolumeDepth01 = (float)VolumeRayDistanceTraveled / STEP_COUNT; | |||
float DistanceCamera2VolumeWalls = length(CameraLocalDir); | |||
float DistanceCamera2Center = distance(_WorldSpaceCameraPos, _VolumePosition); | |||
float DistanceCamera2VolumePoints = distance(_WorldSpaceCameraPos, VolumeSpaceCoordsWorldSpace); | |||
float VolumeDepth = min(max(tmin, tmax), DistanceCamera2VolumePoints) - min(min(tmin, tmax), DistanceCamera2VolumePoints); | |||
float VolumeDensity = DistanceCamera2VolumePoints - DistanceCamera2VolumeWalls; | |||
VolumeFog = saturate(1 - exp(-VolumeDepth / _Visibility * 5)); | |||
//VolumeFog= saturate(1 - exp(-VolumeRayDistanceTraveled / _Visibility)); | |||
VolumeFog.a *= Contact/**Gradient.a*/;// aquí hay que decidir si el gradiente se lo come o no | |||
#endif | |||
NoiseAtten = gain; | |||
NoiseAtten *= DistanceFade; | |||
NoiseAtten *= Contact; | |||
#ifdef HEIGHT_GRAD | |||
heightGradient = half2(HeightGradient(VerticalGrad, GradMin, GradMax), | |||
/*3.1.10: Adding secondary gradient*/HeightGradient(VerticalGrad, GradMin2, GradMax2)); | |||
NoiseAtten *= heightGradient.x*heightGradient.y; | |||
#endif | |||
#if SPHERICAL_FADE | |||
SphereDistance = 1 - saturate(length(VolumeSpaceCoords) / SphericalFadeDistance); | |||
NoiseAtten *= SphereDistance; | |||
#endif | |||
//TEXTURE SAMPLERS////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |||
#if _FOG_VOLUME_NOISE || _FOG_GRADIENT | |||
#if Twirl_X || Twirl_Y || Twirl_Z | |||
float3 rotationDegree = length(NoiseCoordinates) * _Vortex + _Rotation + _RotationSpeed * _Time.x; | |||
NoiseCoordinates = rotate(NoiseCoordinates , rotationDegree); | |||
#endif | |||
half4 VerticalCoords = float4(VolumeSpaceCoords.zx / (_BoxMax.zx - _BoxMin.zx) - .5f, 0, 0); | |||
#ifdef COVERAGE | |||
half CoverageTile = 1; | |||
half4 CoverageCoords = CoverageTile * float4(VolumeSpaceCoords.xz / (_BoxMax.xz - _BoxMin.xz) - .5f, 0, 0); | |||
half4 CoverageRGB = tex2Dlod(CoverageTex, CoverageCoords); | |||
#ifdef HEIGHT_GRAD | |||
//CoverageRGB.r *=heightGradient.y * (1+heightGradient.x * heightGradient.x); | |||
CoverageRGB.r *= heightGradient.y; | |||
#endif | |||
half CumulonimbusTop = HeightGradient(VerticalGrad, 1.0, .5); | |||
half Cresta = HeightGradient(VerticalGrad, 0.7, 1)*CumulonimbusTop; | |||
Cresta *= 10 * CoverageRGB.r; | |||
NoiseAtten *= CoverageRGB.r; | |||
NoiseAtten += CoverageRGB.r * 4 * CumulonimbusTop + Cresta; | |||
#endif | |||
if (Contact > 0 && NoiseAtten > 0 && PrimitiveAccum > _PrimitiveCutout) | |||
{ | |||
#if _FOG_VOLUME_NOISE && !_FOG_GRADIENT | |||
Noise = noise(NoiseCoordinates, DetailCascade0); | |||
#endif | |||
#if !_FOG_VOLUME_NOISE && _FOG_GRADIENT | |||
Gradient.a *= gain; | |||
Noise = Gradient; | |||
#endif | |||
#if _FOG_VOLUME_NOISE && _FOG_GRADIENT | |||
Noise = noise(NoiseCoordinates, DetailCascade0) * Gradient; | |||
#endif | |||
if (Noise.a>0) | |||
Noise *= DistanceFade; | |||
} | |||
else | |||
{ | |||
Noise = 0; | |||
Gradient.a = 0; | |||
} | |||
half absorptionFactor = lerp(1, 200, Absorption); | |||
#ifdef ABSORPTION | |||
half d = Noise.a;//si se multiplica aquí añade cotraste | |||
//half absorptionFactor = lerp(1, 20, Absorption); | |||
half Beers = exp(-d* absorptionFactor)* absorptionFactor;//la última multiplicación da contraste | |||
half Powder = 1 - exp(-d * 2); | |||
absorption = lerp(1, saturate(Beers*Powder), Absorption); | |||
#ifdef HEIGHT_GRAD | |||
half HeightGradientAtten = 1 - heightGradient.x; | |||
HeightGradientAtten = 1.0 - exp(-HeightGradientAtten); | |||
absorption *= lerp(1,HeightGradientAtten, HeightAbsorption); | |||
#endif | |||
// AmbientTerm = absorption;3.2 | |||
#else | |||
//AmbientTerm = 1;3.2 | |||
#endif | |||
#if _LAMBERT_SHADING | |||
if (LightShafts > 0.1)//si estamos en sombra, pos no hagas ná | |||
{ | |||
//Lambert lighting | |||
if (Noise.a > 0 && NoiseAtten > 0 && DetailCascade1 > 0) | |||
{ | |||
normal = calcNormal(NoiseCoordinates, DetailCascade0); | |||
//normal = normalize(VolumeSpaceCoordsWorldSpace- _VolumePosition);//sphere normals | |||
LambertTerm = max(0, dot(normal, normalize(-L))); | |||
//kind of half lambert | |||
LambertTerm = LambertTerm*0.5 + LambertianBias; | |||
LambertTerm *= LambertTerm; | |||
Lambert = lerp(1, LambertTerm, Noise.a*DirectLightingAmount*ContrastF(DetailCascade1 * 3, 2)); | |||
Lambert = max(0.0, Lambert); | |||
} | |||
} | |||
#endif | |||
AmbientColor = _AmbientColor.rgb; | |||
#ifndef SHADOW_PASS | |||
AmbientTerm.rgb = _AmbientColor.rgb; | |||
#endif | |||
half3 ProxyAmbient = 1; | |||
UNITY_BRANCH | |||
if (PROBES == 1) { | |||
//#ifdef PROBES | |||
ProxyAmbient = ShadeSHPerPixel(i.worldNormal, 0, VolumeSpaceCoordsWorldSpace); | |||
AmbientTerm.rgb *= ProxyAmbient/* * _AmbientColor.rgb*/; | |||
AmbientColor *= ProxyAmbient; | |||
} | |||
//#endif | |||
AmbientTerm *= absorption;//3.2 | |||
#endif | |||
#if _SHADE | |||
if (Noise.a > 0) | |||
SelfShadows = Shadow(NoiseCoordinates, i, DetailCascade0, LightVector* ShadowShift, NoiseAtten); | |||
#endif | |||
//3.1.10 | |||
HeightAtten = HeightGradient(VerticalGrad, _AmbientHeightAbsorptionMin, _AmbientHeightAbsorptionMax); | |||
HeightAtten = saturate(1.0 - exp(-HeightAtten)); | |||
if (_AmbientHeightAbsorptionMin == -1 && _AmbientHeightAbsorptionMax == -1)//just to avoid adding one more shader variant | |||
HeightAtten = 1; | |||
//AmbientTerm *= HeightAtten;3.2 ambient shouldn't be affected by this | |||
SelfShadows *= HeightAtten; | |||
// | |||
#if DIRECTIONAL_LIGHTING | |||
float DirectionalLightingSample = 0; | |||
//TODO if (LightShafts > 0.1) | |||
if (NoiseAtten>0 && Noise.a>0) | |||
{ | |||
float3 DirectionalLightingSamplingPosition = NoiseCoordinates; | |||
for (int s = 0; s < DirectLightingShadowSteps; s++) | |||
{ | |||
DirectionalLightingSamplingPosition += LightVector*DirectLightingShadowStepSize; | |||
DirectionalLightingSample = noise(DirectionalLightingSamplingPosition, DetailCascade0).r; | |||
DirectionalLightingAccum += DirectionalLightingSample/* / DirectLightingShadowSteps*/; | |||
} | |||
DirectionalLighting = DirectionalLightingAccum; | |||
} | |||
DirectionalLighting *= Noise.a; | |||
#endif | |||
#if defined (_INSCATTERING) | |||
#if ABSORPTION | |||
//lets diffuse LambertTerm according to density/absorption | |||
//remap absorption greyscale to -1 1 range to affect anisotropy according to media density | |||
//////// multiply ranges of [0, 1] | |||
half t = (1 - Noise.a) * (InscatteringShape*0.5 + 0.5); | |||
//get back to [-1, 1] | |||
t = t * 2 - 1; | |||
InscatteringShape = lerp(InscatteringShape, (t), Absorption); | |||
// #if ABSORPTION && VOLUME_FOG | |||
// InscatteringShape = lerp(InscatteringShape*absorption, InscatteringShape, Noise.a); | |||
// #endif | |||
#endif | |||
half HG = Henyey(Normalized_CameraWorldDir, L, InscatteringShape); | |||
HG *= InscatteringDistanceClamp * Contact; | |||
Phase = _InscatteringColor.rgb * _InscatteringIntensity * HG * Gradient.xyz * _LightColor.rgb;//3.2; | |||
Phase *= absorption; | |||
#endif | |||
#ifdef HALO | |||
half LdotV = saturate(dot(L, Normalized_CameraWorldDir)); | |||
LdotV = pow(LdotV, _HaloRadius); | |||
LdotV = 1 - exp(-LdotV); | |||
LdotV = ContrastF(LdotV, _HaloWidth);//franja | |||
LdotV = saturate(LdotV); | |||
LdotV -= .5; | |||
//#ifdef ABSORPTION | |||
// half HaloDensityTerm = absorption; | |||
//#else | |||
half HaloDensityTerm = Noise.a; | |||
//#endif | |||
half mip = saturate(Noise.a * 12) * _HaloAbsorption * (1 - HaloDensityTerm); | |||
half4 Halo = 0; | |||
if (LdotV >0) | |||
{ | |||
Halo = tex2Dlod(_LightHaloTexture, float4(0, LdotV, 0, mip)); | |||
Halo.g = tex2Dlod(_LightHaloTexture, float4(0, LdotV * 1.1, 0, mip)/**_HaloOpticalDispersion*/).r; | |||
Halo.b = tex2Dlod(_LightHaloTexture, float4(0, LdotV * 1.2, 0, mip)/**_HaloOpticalDispersion*/).r; | |||
Halo.rgb *= _HaloIntensity; | |||
Halo.rgb *= Halo.a; | |||
Halo.rgb *= HaloDensityTerm * (1.0 - HaloDensityTerm); | |||
Halo.rgb *= 1 - mip / 12; | |||
Halo.rgb *= LdotV; | |||
} | |||
else | |||
Halo = 0; | |||
#endif | |||
OpacityTerms = Noise.a*Contact; | |||
#if DIRECTIONAL_LIGHTING | |||
//Shadow Color | |||
DirectionalLighting /= LightExtinctionColor.rgb; | |||
DirectionalLighting = DirectionalLighting* DirectLightingShadowDensity; | |||
DirectionalLighting = exp(-DirectionalLighting); | |||
Phase *= DirectionalLighting; | |||
#endif | |||
//half3 LightTerms = exp(-DirectionalLighting) * OpacityTerms; | |||
half3 LightTerms = OpacityTerms * AmbientTerm.rgb * DirectionalLighting;//3.2 | |||
//#ifdef VOLUMETRIC_SHADOWS | |||
UNITY_BRANCH | |||
if (VOLUMETRIC_SHADOWS == 1) { | |||
// added casting for ps4 | |||
half2 shadowUVs = (mul((float3x3)_ShadowCameraProjection, (float3)(VolumeSpaceCoordsWorldSpace - _ShadowCameraPosition)).xy + _ShadowCameraSize) / (_ShadowCameraSize*2.0f); | |||
#ifdef CONVOLVE_VOLUMETRIC_SHADOWS | |||
#define _GeneralShadowOffset 0.003f | |||
float pointDepth = length(_ShadowCameraPosition - VolumeSpaceCoordsWorldSpace); | |||
// | |||
half4 shadows; | |||
shadows.x = step(pointDepth, tex2Dlod(_ShadowTexture, float4(shadowUVs + float2(-_GeneralShadowOffset, -_GeneralShadowOffset), 0, 0)).r); | |||
shadows.y = step(pointDepth, tex2Dlod(_ShadowTexture, float4(shadowUVs + float2(_GeneralShadowOffset, _GeneralShadowOffset), 0, 0)).r); | |||
shadows.z = step(pointDepth, tex2Dlod(_ShadowTexture, float4(shadowUVs + float2(-_GeneralShadowOffset, _GeneralShadowOffset), 0, 0)).r); | |||
shadows.w = step(pointDepth, tex2Dlod(_ShadowTexture, float4(shadowUVs + float2(_GeneralShadowOffset, -_GeneralShadowOffset), 0, 0)).r); | |||
VolumeShadow = max(dot(shadows, 0.25f), 0.0f); | |||
#else | |||
VolumeShadow = FrameShadow(shadowUVs, VolumeSpaceCoordsWorldSpace); | |||
#endif | |||
//3.2 | |||
#if defined (_INSCATTERING) | |||
Phase *= VolumeShadow; | |||
#endif | |||
#ifdef HALO | |||
Halo.rgb *= VolumeShadow; | |||
#endif | |||
//3.2 | |||
//LightTerms *= lerp(_AmbientColor.rgb, 1, VolumeShadow);//previous 3.2 | |||
//LightTerms *= lerp(AmbientTerm.rgb, 1, VolumeShadow);//3.2 test | |||
} | |||
//#endif | |||
//Phase *= LightTerms;//atten with shadowing//3.2 comment | |||
Phase *= OpacityTerms;//3.2 | |||
//LightTerms *= lerp(_AmbientColor.rgb, 1, absorption);//previous 3.2 | |||
//LightTerms *= lerp(AmbientTerm.rgb, 1, absorption);//3.2 test | |||
#ifdef VOLUME_SHADOWS | |||
half4 LightMapCoords = VerticalCoords; | |||
LightMapCoords.xy = LightMapCoords.yx; | |||
#ifndef LIGHT_ATTACHED | |||
LightMapCoords.xy += LightShaftsDir.zx*(1 - VerticalGrad); | |||
#endif | |||
LightMapCoords.x = clamp(LightMapCoords.x, -1, 0); | |||
LightMapCoords.y = clamp(LightMapCoords.y, -1, 0); | |||
LightShafts = tex2Dlod(LightshaftTex, LightMapCoords).r; | |||
LightShafts = LightShafts*lerp(50,1,_Cutoff); | |||
LightShafts = 1 - saturate(LightShafts); | |||
//LightShafts *= _LightColor.rgb;3.2 | |||
#if defined (_INSCATTERING) | |||
Phase *= LightShafts; | |||
#endif | |||
#ifdef HALO | |||
Halo.rgb *= LightShafts; // changed to rgb for ps4 | |||
#endif | |||
#endif | |||
#ifdef VOLUME_SHADOWS | |||
LightTerms *= LightShafts; | |||
#endif | |||
LightTerms *= Lambert; | |||
#ifdef _SHADE | |||
float3 SelfShadowsColor = lerp(_SelfShadowColor.rgb * AmbientTerm.rgb, 1.0, SelfShadows);//3.2 replaced ambient color with AmbientTerm | |||
LightTerms *= SelfShadowsColor; | |||
Phase *= SelfShadowsColor; | |||
#endif | |||
//3.1.10 | |||
LightTerms *= HeightAtten; | |||
Phase *= HeightAtten; | |||
// | |||
#ifdef VOLUME_FOG | |||
half3 VolumetricFogVolor = _FogColor.rgb; | |||
//#ifdef AMBIENT_AFFECTS_FOG_COLOR | |||
if (AMBIENT_AFFECTS_FOG_COLOR) VolumetricFogVolor *= AmbientColor; | |||
//#endif | |||
#ifdef VOLUME_SHADOWS | |||
LightTerms = lerp(LightTerms, VolumetricFogVolor * Gradient.rgb * (LightShafts + _AmbientColor.a), VolumeFog.a); | |||
#else | |||
LightTerms = lerp(LightTerms, VolumetricFogVolor * Gradient.rgb, VolumeFog.a); | |||
#endif | |||
#if defined (_VOLUME_FOG_INSCATTERING) | |||
half VolumeFogInscatteringDistanceClamp = saturate((VolumeRayDistanceTraveled - VolumeFogInscatteringStartDistance) / VolumeFogInscatteringTransitionWideness); | |||
half3 VolumeFogPhase = Henyey(Normalized_CameraWorldDir, L, VolumeFogInscatteringAnisotropy); | |||
VolumeFogPhase *= Contact; | |||
VolumeFogPhase *= VolumeFogInscatteringDistanceClamp; | |||
VolumeFogPhase *= VolumeFogInscatteringColor.rgb * VolumeFogInscatteringIntensity * Gradient.xyz; | |||
VolumeFogPhase *= saturate(1 - Noise.a * VolumeFogInscatteringIntensity/*pushin' proportionaly to intensity*/); | |||
half3 FogInscatter = 0; | |||
UNITY_BRANCH | |||
if (FOG_TINTS_INSCATTER == 1) | |||
FogInscatter = VolumeFog.a *VolumetricFogVolor * VolumeFogPhase * _LightColor.rgb; | |||
//3.2 | |||
else | |||
FogInscatter = VolumeFog.a *VolumetricFogVolor * VolumeFogPhase * _LightColor.rgb + VolumeFog.a * VolumeFogPhase * _LightColor.rgb; | |||
#ifdef VOLUME_SHADOWS | |||
FogInscatter *= LightShafts; | |||
#endif | |||
UNITY_BRANCH | |||
if (VOLUMETRIC_SHADOWS == 1) | |||
FogInscatter *= VolumeShadow; | |||
LightTerms += FogInscatter; | |||
#endif | |||
OpacityTerms = min(OpacityTerms + VolumeFog.a, 1); | |||
#endif | |||
#if defined(_FOG_GRADIENT) | |||
LightTerms *= Gradient.rgb; | |||
#endif | |||
//#ifdef PROBES | |||
//LightTerms *= ProxyAmbient*5;//maybe not | |||
//#endif | |||
LightTerms += Phase; | |||
//Multiply by LambertTerm and color before additive stuff | |||
LightTerms *= _Color.rgb; | |||
LightTerms *= _LightExposure;//new in 3.1.1 | |||
LightTerms += AmbientTerm*Noise.a;//multiplicando para no afectar a la niebla | |||
#if SHADER_API_GLCORE || SHADER_API_D3D11 || SHADER_API_METAL | |||
#if ATTEN_METHOD_1 || ATTEN_METHOD_2 || ATTEN_METHOD_3 | |||
if (DetailCascade2>0) | |||
{ | |||
for (int k = 0; k < _LightsCount; k++) | |||
{ | |||
half PointLightRange = 1 - (length(_LightPositions[k].xyz - VolumeSpaceCoords) * PointLightingDistance);//range clamp | |||
if (PointLightRange > .99) { | |||
if (_LightData[k].z >= 0.0) | |||
{ | |||
PointLightAccum += | |||
(Noise.a + VolumeFog.a)*SpotLight( | |||
_LightPositions[k].xyz, | |||
VolumeSpaceCoords, | |||
_LightRange(k), | |||
_LightColors[k], | |||
_LightIntensity(k), | |||
_LightRotations[k], | |||
_LightSpotAngle(k), | |||
_LightColors[k].w, i) * Contact; | |||
} | |||
else | |||
{ | |||
PointLightAccum += | |||
(Noise.a + VolumeFog.a)*PointLight( | |||
_LightPositions[k].xyz, | |||
VolumeSpaceCoords, | |||
_LightRange(k), | |||
_LightColors[k], | |||
_LightIntensity(k), | |||
//1, | |||
i) * Contact; | |||
} | |||
} | |||
} | |||
half atten = saturate(PointLightAccum.a); | |||
if (atten > 0) | |||
{ | |||
PointLightsFinal = PointLightAccum; | |||
} | |||
} | |||
#endif | |||
#endif | |||
#ifdef HALO | |||
//LightTerms += Halo.rgb; | |||
//3.1.10 | |||
LightTerms *= (1 + Halo.rgb); | |||
#endif | |||
#ifdef DEBUG | |||
if (_DebugMode == DEBUG_ITERATIONS) | |||
{ | |||
debugOutput.rgb = tex2Dlod(_PerformanceLUT, float4(0, (float)s / STEP_COUNT, 0, 0)).rgb; | |||
} | |||
if (_DebugMode == DEBUG_INSCATTERING) | |||
{ | |||
LightTerms = Phase; | |||
} | |||
if (_DebugMode == DEBUG_VOLUMETRIC_SHADOWS) | |||
{ | |||
LightTerms = LightShafts * .05; | |||
} | |||
#if VOLUME_FOG && _VOLUME_FOG_INSCATTERING | |||
if (_DebugMode == DEBUG_VOLUME_FOG_INSCATTER_CLAMP) | |||
{ | |||
LightTerms = OpacityTerms * VolumeFogInscatteringDistanceClamp; | |||
} | |||
if (_DebugMode == DEBUG_VOLUME_FOG_PHASE) | |||
{ | |||
LightTerms = OpacityTerms * FogInscatter; | |||
} | |||
#endif | |||
#endif | |||
OpacityTerms *= _PushAlpha; | |||
//FinalNoise.a = saturate(FinalNoise.a); | |||
FinalNoise = FinalNoise + float4(LightTerms, OpacityTerms) * (1.0 - FinalNoise.a); | |||
if (FinalNoise.a > .999)break;//KILL'EM ALL if its already opaque, don't do anything else | |||
} | |||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////LOOP END | |||
#ifdef DEBUG | |||
if (_DebugMode == DEBUG_INSCATTERING | |||
|| _DebugMode == DEBUG_VOLUMETRIC_SHADOWS | |||
|| _DebugMode == DEBUG_VOLUME_FOG_INSCATTER_CLAMP | |||
|| _DebugMode == DEBUG_VOLUME_FOG_PHASE) | |||
{ | |||
debugOutput = FinalNoise; | |||
} | |||
return debugOutput; | |||
#endif | |||
//return FinalNoise; | |||
//return float4(Contact, Contact, Contact,1); | |||
//return float4(NoiseAtten, NoiseAtten, NoiseAtten, 1); ; | |||
//FinalNoise.rgb *= _Color.rgb; | |||
_Color = FinalNoise; | |||
_InscatteringColor *= FinalNoise; | |||
#endif | |||
#if _INSCATTERING && !_FOG_VOLUME_NOISE && !_FOG_GRADIENT | |||
float Inscattering = Henyey(Normalized_CameraWorldDir, L, InscatteringShape); | |||
//_InscatteringIntensity *= .05; | |||
Inscattering *= InscatteringDistanceClamp; | |||
Final = float4(_Color.rgb + _InscatteringColor.rgb * _InscatteringIntensity * Inscattering, _Color.a); | |||
#else | |||
Final = _Color; | |||
#endif | |||
#if ATTEN_METHOD_1 || ATTEN_METHOD_2 || ATTEN_METHOD_3 | |||
Final.rgb += PointLightsFinal.rgb; | |||
#endif | |||
#ifdef ColorAdjust | |||
Final.rgb = lerp(Final.rgb, pow(max((Final.rgb + Offset), 0), 1 / Gamma), Final.a); | |||
#if _TONEMAP | |||
Final.rgb = ToneMap(Final.rgb, Exposure); | |||
#endif | |||
#endif | |||
#if !_FOG_VOLUME_NOISE && !_FOG_GRADIENT | |||
Final.a *= (Fog * _Color.a); | |||
#endif | |||
if (IsGammaSpace()) | |||
Final.rgb = pow(Final.rgb, 1 / 2.2); | |||
Final.a = saturate(Final.a); | |||
Final.rgb = SafeHDR(Final.rgb); | |||
#ifdef Enviro_Integration | |||
float4 EnviroFog = TransparentFog(Final, i.Wpos, screenUV, Depth); | |||
EnviroFog.a = EnviroFog.a * Final.a; | |||
Final = EnviroFog; | |||
#endif | |||
//Debug the build problem | |||
#if DF && defined(DEBUG_PRIMITIVES) | |||
//Final.rgb = _PrimitiveCount/1.5; | |||
//Final.a = 0; | |||
Final.rgb = float3(0,.5, .5); | |||
#endif | |||
return Final; | |||
} | |||
#endif |
@ -0,0 +1,9 @@ | |||
fileFormatVersion: 2 | |||
guid: afa56309886d8d94191be84bc51a056e | |||
timeCreated: 1484003826 | |||
licenseType: Store | |||
ShaderImporter: | |||
defaultTextures: [] | |||
userData: | |||
assetBundleName: | |||
assetBundleVariant: |
@ -0,0 +1,3 @@ | |||
version https://git-lfs.github.com/spec/v1 | |||
oid sha256:370f399cfed63c5021e519eebc8004f4a0eb7defeeccc42b980f935eb5023e0a | |||
size 22653 |
@ -0,0 +1,84 @@ | |||
fileFormatVersion: 2 | |||
guid: 228d0518a8dc08f47847b61368a37c5f | |||
timeCreated: 1488739538 | |||
licenseType: Store | |||
TextureImporter: | |||
fileIDToRecycleName: {} | |||
serializedVersion: 4 | |||
mipmaps: | |||
mipMapMode: 0 | |||
enableMipMap: 1 | |||
sRGBTexture: 0 | |||
linearTexture: 0 | |||
fadeOut: 0 | |||
borderMipMap: 0 | |||
mipMapFadeDistanceStart: 1 | |||
mipMapFadeDistanceEnd: 3 | |||
bumpmap: | |||
convertToNormalMap: 0 | |||
externalNormalMap: 0 | |||
heightScale: 0.25 | |||
normalMapFilter: 0 | |||
isReadable: 0 | |||
grayScaleToAlpha: 0 | |||
generateCubemap: 6 | |||
cubemapConvolution: 0 | |||
seamlessCubemap: 0 | |||
textureFormat: 1 | |||
maxTextureSize: 2048 | |||
textureSettings: | |||
filterMode: -1 | |||
aniso: -1 | |||
mipBias: -1 | |||
wrapMode: -1 | |||
nPOTScale: 1 | |||
lightmap: 0 | |||
compressionQuality: 50 | |||
spriteMode: 0 | |||
spriteExtrude: 1 | |||
spriteMeshType: 1 | |||
alignment: 0 | |||
spritePivot: {x: 0.5, y: 0.5} | |||
spriteBorder: {x: 0, y: 0, z: 0, w: 0} | |||
spritePixelsToUnits: 100 | |||
alphaUsage: 1 | |||
alphaIsTransparency: 1 | |||
spriteTessellationDetail: -1 | |||
textureType: 0 | |||
textureShape: 1 | |||
maxTextureSizeSet: 0 | |||
compressionQualitySet: 0 | |||
textureFormatSet: 0 | |||
platformSettings: | |||
- buildTarget: DefaultTexturePlatform | |||
maxTextureSize: 2048 | |||
textureFormat: -1 | |||
textureCompression: 0 | |||
compressionQuality: 50 | |||
crunchedCompression: 0 | |||
allowsAlphaSplitting: 0 | |||
overridden: 0 | |||
- buildTarget: Standalone | |||
maxTextureSize: 2048 | |||
textureFormat: -1 | |||
textureCompression: 0 | |||
compressionQuality: 50 | |||
crunchedCompression: 0 | |||
allowsAlphaSplitting: 0 | |||
overridden: 0 | |||
- buildTarget: Android | |||
maxTextureSize: 2048 | |||
textureFormat: -1 | |||
textureCompression: 0 | |||
compressionQuality: 50 | |||
crunchedCompression: 0 | |||
allowsAlphaSplitting: 0 | |||
overridden: 0 | |||
spriteSheet: | |||
serializedVersion: 2 | |||
sprites: [] | |||
outline: [] | |||
spritePackingTag: | |||
userData: | |||
assetBundleName: | |||
assetBundleVariant: |
@ -0,0 +1,3 @@ | |||
version https://git-lfs.github.com/spec/v1 | |||
oid sha256:370f399cfed63c5021e519eebc8004f4a0eb7defeeccc42b980f935eb5023e0a | |||
size 22653 |
@ -0,0 +1,84 @@ | |||
fileFormatVersion: 2 | |||
guid: 925eb9f7b0e73dd438a616124964bba8 | |||
timeCreated: 1488739538 | |||
licenseType: Store | |||
TextureImporter: | |||
fileIDToRecycleName: {} | |||
serializedVersion: 4 | |||
mipmaps: | |||
mipMapMode: 0 | |||
enableMipMap: 1 | |||
sRGBTexture: 0 | |||
linearTexture: 0 | |||
fadeOut: 0 | |||
borderMipMap: 0 | |||
mipMapFadeDistanceStart: 1 | |||
mipMapFadeDistanceEnd: 3 | |||
bumpmap: | |||
convertToNormalMap: 0 | |||
externalNormalMap: 0 | |||
heightScale: 0.25 | |||
normalMapFilter: 0 | |||
isReadable: 0 | |||
grayScaleToAlpha: 0 | |||
generateCubemap: 6 | |||
cubemapConvolution: 0 | |||
seamlessCubemap: 0 | |||
textureFormat: 1 | |||
maxTextureSize: 2048 | |||
textureSettings: | |||
filterMode: -1 | |||
aniso: -1 | |||
mipBias: -1 | |||
wrapMode: -1 | |||
nPOTScale: 1 | |||
lightmap: 0 | |||
compressionQuality: 50 | |||
spriteMode: 0 | |||
spriteExtrude: 1 | |||
spriteMeshType: 1 | |||
alignment: 0 | |||
spritePivot: {x: 0.5, y: 0.5} | |||
spriteBorder: {x: 0, y: 0, z: 0, w: 0} | |||
spritePixelsToUnits: 100 | |||
alphaUsage: 1 | |||
alphaIsTransparency: 1 | |||
spriteTessellationDetail: -1 | |||
textureType: 0 | |||
textureShape: 1 | |||
maxTextureSizeSet: 0 | |||
compressionQualitySet: 0 | |||
textureFormatSet: 0 | |||
platformSettings: | |||
- buildTarget: DefaultTexturePlatform | |||
maxTextureSize: 2048 | |||
textureFormat: -1 | |||
textureCompression: 0 | |||
compressionQuality: 50 | |||
crunchedCompression: 0 | |||
allowsAlphaSplitting: 0 | |||
overridden: 0 | |||
- buildTarget: Standalone | |||
maxTextureSize: 2048 | |||
textureFormat: -1 | |||
textureCompression: 0 | |||
compressionQuality: 50 | |||
crunchedCompression: 0 | |||
allowsAlphaSplitting: 0 | |||
overridden: 0 | |||
- buildTarget: Android | |||
maxTextureSize: 2048 | |||
textureFormat: -1 | |||
textureCompression: 0 | |||
compressionQuality: 50 | |||
crunchedCompression: 0 | |||
allowsAlphaSplitting: 0 | |||
overridden: 0 | |||
spriteSheet: | |||
serializedVersion: 2 | |||
sprites: [] | |||
outline: [] | |||
spritePackingTag: | |||
userData: | |||
assetBundleName: | |||
assetBundleVariant: |
@ -0,0 +1,3 @@ | |||
version https://git-lfs.github.com/spec/v1 | |||
oid sha256:e9a70fcd7af92becfcd3b8f83178460c104d8af6f7909e61fda245023e481cba | |||
size 50381 |
@ -0,0 +1,84 @@ | |||
fileFormatVersion: 2 | |||
guid: 5aac178e436d68546ae151ed5ba76b94 | |||
timeCreated: 1493126559 | |||
licenseType: Store | |||
TextureImporter: | |||
fileIDToRecycleName: {} | |||
serializedVersion: 4 | |||
mipmaps: | |||
mipMapMode: 0 | |||
enableMipMap: 1 | |||
sRGBTexture: 1 | |||
linearTexture: 0 | |||
fadeOut: 0 | |||
borderMipMap: 0 | |||
mipMapFadeDistanceStart: 1 | |||
mipMapFadeDistanceEnd: 3 | |||
bumpmap: | |||
convertToNormalMap: 0 | |||
externalNormalMap: 0 | |||
heightScale: 0.25 | |||
normalMapFilter: 0 | |||
isReadable: 0 | |||
grayScaleToAlpha: 0 | |||
generateCubemap: 6 | |||
cubemapConvolution: 0 | |||
seamlessCubemap: 0 | |||
textureFormat: 1 | |||
maxTextureSize: 2048 | |||
textureSettings: | |||
filterMode: -1 | |||
aniso: -1 | |||
mipBias: -1 | |||
wrapMode: -1 | |||
nPOTScale: 1 | |||
lightmap: 0 | |||
compressionQuality: 50 | |||
spriteMode: 0 | |||
spriteExtrude: 1 | |||
spriteMeshType: 1 | |||
alignment: 0 | |||
spritePivot: {x: 0.5, y: 0.5} | |||
spriteBorder: {x: 0, y: 0, z: 0, w: 0} | |||
spritePixelsToUnits: 100 | |||
alphaUsage: 1 | |||
alphaIsTransparency: 1 | |||
spriteTessellationDetail: -1 | |||
textureType: 0 | |||
textureShape: 1 | |||
maxTextureSizeSet: 0 | |||
compressionQualitySet: 0 | |||
textureFormatSet: 0 | |||
platformSettings: | |||
- buildTarget: DefaultTexturePlatform | |||
maxTextureSize: 2048 | |||
textureFormat: -1 | |||
textureCompression: 1 | |||
compressionQuality: 50 | |||
crunchedCompression: 0 | |||
allowsAlphaSplitting: 0 | |||
overridden: 0 | |||
- buildTarget: Standalone | |||
maxTextureSize: 2048 | |||
textureFormat: -1 | |||
textureCompression: 1 | |||
compressionQuality: 50 | |||
crunchedCompression: 0 | |||
allowsAlphaSplitting: 0 | |||
overridden: 0 | |||
- buildTarget: Android | |||
maxTextureSize: 2048 | |||
textureFormat: -1 | |||
textureCompression: 1 | |||
compressionQuality: 50 | |||
crunchedCompression: 0 | |||
allowsAlphaSplitting: 0 | |||
overridden: 0 | |||
spriteSheet: | |||
serializedVersion: 2 | |||
sprites: [] | |||
outline: [] | |||
spritePackingTag: | |||
userData: | |||
assetBundleName: | |||
assetBundleVariant: |
@ -0,0 +1,3 @@ | |||
version https://git-lfs.github.com/spec/v1 | |||
oid sha256:f24bcc7d80a9b738c7c33ef05c19feb0eeed94047940366d82cca89f602f371e | |||
size 41987 |
@ -0,0 +1,119 @@ | |||
fileFormatVersion: 2 | |||
guid: bcc14a1519976cf4d9c5e8289bc32897 | |||
TextureImporter: | |||
fileIDToRecycleName: {} | |||
externalObjects: {} | |||
serializedVersion: 6 | |||
mipmaps: | |||
mipMapMode: 0 | |||
enableMipMap: 0 | |||
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: 2 | |||
aniso: 1 | |||
mipBias: -100 | |||
wrapU: 1 | |||
wrapV: 1 | |||
wrapW: -1 | |||
nPOTScale: 0 | |||
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: 0 | |||
alphaIsTransparency: 1 | |||
spriteTessellationDetail: -1 | |||
textureType: 2 | |||
textureShape: 1 | |||
singleChannelComponent: 0 | |||
maxTextureSizeSet: 0 | |||
compressionQualitySet: 0 | |||
textureFormatSet: 0 | |||
platformSettings: | |||
- serializedVersion: 2 | |||
buildTarget: DefaultTexturePlatform | |||
maxTextureSize: 2048 | |||
resizeAlgorithm: 0 | |||
textureFormat: -1 | |||
textureCompression: 3 | |||
compressionQuality: 50 | |||
crunchedCompression: 0 | |||
allowsAlphaSplitting: 0 | |||
overridden: 0 | |||
androidETC2FallbackOverride: 0 | |||
- serializedVersion: 2 | |||
buildTarget: Standalone | |||
maxTextureSize: 2048 | |||
resizeAlgorithm: 0 | |||
textureFormat: -1 | |||
textureCompression: 3 | |||
compressionQuality: 50 | |||
crunchedCompression: 0 | |||
allowsAlphaSplitting: 0 | |||
overridden: 0 | |||
androidETC2FallbackOverride: 0 | |||
- serializedVersion: 2 | |||
buildTarget: Android | |||
maxTextureSize: 2048 | |||
resizeAlgorithm: 0 | |||
textureFormat: -1 | |||
textureCompression: 3 | |||
compressionQuality: 50 | |||
crunchedCompression: 0 | |||
allowsAlphaSplitting: 0 | |||
overridden: 0 | |||
androidETC2FallbackOverride: 0 | |||
- serializedVersion: 2 | |||
buildTarget: WebGL | |||
maxTextureSize: 2048 | |||
resizeAlgorithm: 0 | |||
textureFormat: -1 | |||
textureCompression: 3 | |||
compressionQuality: 50 | |||
crunchedCompression: 0 | |||
allowsAlphaSplitting: 0 | |||
overridden: 0 | |||
androidETC2FallbackOverride: 0 | |||
spriteSheet: | |||
serializedVersion: 2 | |||
sprites: [] | |||
outline: [] | |||
physicsShape: [] | |||
bones: [] | |||
spriteID: | |||
vertices: [] | |||
indices: | |||
edges: [] | |||
weights: [] | |||
spritePackingTag: | |||
userData: | |||
assetBundleName: | |||
assetBundleVariant: |
@ -0,0 +1,8 @@ | |||
#ifndef FOG_VOLUME_INTEGRATIONS | |||
#define FOG_VOLUME_INTEGRATIONS | |||
//Uncomment to enable Enviro integration | |||
//#include "Assets/Enviro - Dynamic Environment/Resources/Shaders/Core/EnviroFogCore.cginc" | |||
//#define Enviro_Integration | |||
#endif |
@ -0,0 +1,9 @@ | |||
fileFormatVersion: 2 | |||
guid: 3798f437c853dc74ca4110898c20e503 | |||
timeCreated: 1510228128 | |||
licenseType: Store | |||
ShaderImporter: | |||
defaultTextures: [] | |||
userData: | |||
assetBundleName: | |||
assetBundleVariant: |
@ -0,0 +1,8 @@ | |||
fileFormatVersion: 2 | |||
guid: e7a4e82d8aa1bfe45960ea83d8deaaa3 | |||
folderAsset: yes | |||
DefaultImporter: | |||
externalObjects: {} | |||
userData: | |||
assetBundleName: | |||
assetBundleVariant: |
@ -0,0 +1,76 @@ | |||
%YAML 1.1 | |||
%TAG !u! tag:unity3d.com,2011: | |||
--- !u!21 &2100000 | |||
Material: | |||
serializedVersion: 6 | |||
m_ObjectHideFlags: 0 | |||
m_CorrespondingSourceObject: {fileID: 0} | |||
m_PrefabInternal: {fileID: 0} | |||
m_Name: No Name | |||
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} | |||
m_ShaderKeywords: | |||
m_LightmapFlags: 4 | |||
m_EnableInstancingVariants: 0 | |||
m_DoubleSidedGI: 0 | |||
m_CustomRenderQueue: -1 | |||
stringTagMap: {} | |||
disabledShaderPasses: [] | |||
m_SavedProperties: | |||
serializedVersion: 3 | |||
m_TexEnvs: | |||
- _BumpMap: | |||
m_Texture: {fileID: 0} | |||
m_Scale: {x: 1, y: 1} | |||
m_Offset: {x: 0, y: 0} | |||
- _DetailAlbedoMap: | |||
m_Texture: {fileID: 0} | |||
m_Scale: {x: 1, y: 1} | |||
m_Offset: {x: 0, y: 0} | |||
- _DetailMask: | |||
m_Texture: {fileID: 0} | |||
m_Scale: {x: 1, y: 1} | |||
m_Offset: {x: 0, y: 0} | |||
- _DetailNormalMap: | |||
m_Texture: {fileID: 0} | |||
m_Scale: {x: 1, y: 1} | |||
m_Offset: {x: 0, y: 0} | |||
- _EmissionMap: | |||
m_Texture: {fileID: 0} | |||
m_Scale: {x: 1, y: 1} | |||
m_Offset: {x: 0, y: 0} | |||
- _MainTex: | |||
m_Texture: {fileID: 0} | |||
m_Scale: {x: 1, y: 1} | |||
m_Offset: {x: 0, y: 0} | |||
- _MetallicGlossMap: | |||
m_Texture: {fileID: 0} | |||
m_Scale: {x: 1, y: 1} | |||
m_Offset: {x: 0, y: 0} | |||
- _OcclusionMap: | |||
m_Texture: {fileID: 0} | |||
m_Scale: {x: 1, y: 1} | |||
m_Offset: {x: 0, y: 0} | |||
- _ParallaxMap: | |||
m_Texture: {fileID: 0} | |||
m_Scale: {x: 1, y: 1} | |||
m_Offset: {x: 0, y: 0} | |||
m_Floats: | |||
- _BumpScale: 1 | |||
- _Cutoff: 0.5 | |||
- _DetailNormalMapScale: 1 | |||
- _DstBlend: 0 | |||
- _GlossMapScale: 1 | |||
- _Glossiness: 0 | |||
- _GlossyReflections: 1 | |||
- _Metallic: 0 | |||
- _Mode: 0 | |||
- _OcclusionStrength: 1 | |||
- _Parallax: 0.02 | |||
- _SmoothnessTextureChannel: 0 | |||
- _SpecularHighlights: 1 | |||
- _SrcBlend: 1 | |||
- _UVSec: 0 | |||
- _ZWrite: 1 | |||
m_Colors: | |||
- _Color: {r: 1, g: 1, b: 1, a: 1} | |||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 0} |
@ -0,0 +1,8 @@ | |||
fileFormatVersion: 2 | |||
guid: a6226413f1434634086af62c28f8cce6 | |||
NativeFormatImporter: | |||
externalObjects: {} | |||
mainObjectFileID: 2100000 | |||
userData: | |||
assetBundleName: | |||
assetBundleVariant: |
@ -0,0 +1,3 @@ | |||
version https://git-lfs.github.com/spec/v1 | |||
oid sha256:3d1a1320d75a666ce746677cd81a3d3eada05308d62099b0e1462caa3ef012a7 | |||
size 25508 |
@ -0,0 +1,76 @@ | |||
fileFormatVersion: 2 | |||
guid: f651c771afb96204b85e925622f5e2b9 | |||
timeCreated: 1483987450 | |||
licenseType: Store | |||
TextureImporter: | |||
fileIDToRecycleName: {} | |||
serializedVersion: 4 | |||
mipmaps: | |||
mipMapMode: 0 | |||
enableMipMap: 1 | |||
sRGBTexture: 1 | |||
linearTexture: 0 | |||
fadeOut: 0 | |||
borderMipMap: 0 | |||
mipMapFadeDistanceStart: 1 | |||
mipMapFadeDistanceEnd: 3 | |||
bumpmap: | |||
convertToNormalMap: 0 | |||
externalNormalMap: 0 | |||
heightScale: 0.25 | |||
normalMapFilter: 0 | |||
isReadable: 0 | |||
grayScaleToAlpha: 0 | |||
generateCubemap: 6 | |||
cubemapConvolution: 0 | |||
seamlessCubemap: 0 | |||
textureFormat: 1 | |||
maxTextureSize: 2048 | |||
textureSettings: | |||
filterMode: -1 | |||
aniso: -1 | |||
mipBias: -1 | |||
wrapMode: 0 | |||
nPOTScale: 1 | |||
lightmap: 0 | |||
compressionQuality: 50 | |||
spriteMode: 0 | |||
spriteExtrude: 1 | |||
spriteMeshType: 1 | |||
alignment: 0 | |||
spritePivot: {x: 0.5, y: 0.5} | |||
spriteBorder: {x: 0, y: 0, z: 0, w: 0} | |||
spritePixelsToUnits: 100 | |||
alphaUsage: 1 | |||
alphaIsTransparency: 0 | |||
spriteTessellationDetail: -1 | |||
textureType: 0 | |||
textureShape: 1 | |||
maxTextureSizeSet: 0 | |||
compressionQualitySet: 0 | |||
textureFormatSet: 0 | |||
platformSettings: | |||
- buildTarget: DefaultTexturePlatform | |||
maxTextureSize: 2048 | |||
textureFormat: -1 | |||
textureCompression: 1 | |||
compressionQuality: 50 | |||
crunchedCompression: 0 | |||
allowsAlphaSplitting: 0 | |||
overridden: 0 | |||
- buildTarget: Standalone | |||
maxTextureSize: 2048 | |||
textureFormat: -1 | |||
textureCompression: 1 | |||
compressionQuality: 50 | |||
crunchedCompression: 0 | |||
allowsAlphaSplitting: 0 | |||
overridden: 0 | |||
spriteSheet: | |||
serializedVersion: 2 | |||
sprites: [] | |||
outline: [] | |||
spritePackingTag: | |||
userData: | |||
assetBundleName: | |||
assetBundleVariant: |
@ -0,0 +1,59 @@ | |||
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)' | |||
// Shader created with Shader Forge v1.33 | |||
// Shader Forge (c) Neat Corporation / Joachim Holmer - http://www.acegikmo.com/shaderforge/ | |||
// Note: Manually altering this data may prevent you from opening it in Shader Forge | |||
/*SF_DATA;ver:1.33;sub:START;pass:START;ps:flbk:,iptp:0,cusa:False,bamd:0,lico:1,lgpr:1,limd:0,spmd:1,trmd:0,grmd:0,uamb:True,mssp:True,bkdf:False,hqlp:False,rprd:False,enco:False,rmgx:True,rpth:0,vtps:0,hqsc:True,nrmq:1,nrsp:0,vomd:0,spxs:False,tesm:0,olmd:1,culm:0,bsrc:3,bdst:7,dpts:2,wrdp:False,dith:0,atcv:False,rfrpo:True,rfrpn:Refraction,coma:15,ufog:False,aust:True,igpj:True,qofs:0,qpre:3,rntp:2,fgom:False,fgoc:False,fgod:False,fgor:False,fgmd:0,fgcr:0.5,fgcg:0.5,fgcb:0.5,fgca:1,fgde:0.01,fgrn:0,fgrf:300,stcl:False,stva:128,stmr:255,stmw:255,stcp:6,stps:0,stfa:0,stfz:0,ofsf:0,ofsu:0,f2p0:False,fnsp:False,fnfb:False;n:type:ShaderForge.SFN_Final,id:3138,x:33057,y:32649,varname:node_3138,prsc:2|emission-7241-RGB,alpha-7241-A;n:type:ShaderForge.SFN_Color,id:7241,x:32471,y:32812,ptovrint:False,ptlb:Color,ptin:_Color,varname:_Color,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,c1:0.07843138,c2:0.3921569,c3:0.7843137,c4:1;proporder:7241;pass:END;sub:END;*/ | |||
Shader "Fog Volume/Primitive" { | |||
Properties { | |||
_Color ("Color", Color) = (0.07843138,0.3921569,0.7843137,1) | |||
[HideInInspector]_Cutoff ("Alpha cutoff", Range(0,1)) = 0.5 | |||
} | |||
SubShader { | |||
Tags { | |||
"IgnoreProjector"="True" | |||
"Queue"="Transparent" | |||
"RenderType"="Transparent" | |||
} | |||
Pass { | |||
Name "FORWARD" | |||
Tags { | |||
"LightMode"="ForwardBase" | |||
} | |||
Blend SrcAlpha OneMinusSrcAlpha | |||
ZWrite Off | |||
Cull off | |||
CGPROGRAM | |||
#pragma vertex vert | |||
#pragma fragment frag | |||
//#define UNITY_PASS_FORWARDBASE | |||
#include "UnityCG.cginc" | |||
#pragma multi_compile_fwdbase | |||
#pragma only_renderers d3d9 d3d11 glcore gles gles3 metal | |||
#pragma target 3.0 | |||
uniform float4 _Color; | |||
struct VertexInput { | |||
float4 vertex : POSITION; | |||
}; | |||
struct VertexOutput { | |||
float4 pos : SV_POSITION; | |||
}; | |||
VertexOutput vert (VertexInput v) { | |||
VertexOutput o = (VertexOutput)0; | |||
o.pos = UnityObjectToClipPos(v.vertex ); | |||
return o; | |||
} | |||
float4 frag(VertexOutput i) : COLOR { | |||
////// Lighting: | |||
////// Emissive: | |||
float3 emissive = _Color.rgb; | |||
float3 finalColor = emissive; | |||
return fixed4(finalColor,_Color.a); | |||
} | |||
ENDCG | |||
} | |||
} | |||
FallBack "Diffuse" | |||
// CustomEditor "ShaderForgeMaterialInspector" | |||
} |
@ -0,0 +1,9 @@ | |||
fileFormatVersion: 2 | |||
guid: 972bc62358fe0b74390929ddcc7f76cc | |||
timeCreated: 1487241739 | |||
licenseType: Store | |||
ShaderImporter: | |||
defaultTextures: [] | |||
userData: | |||
assetBundleName: | |||
assetBundleVariant: |
@ -0,0 +1,136 @@ | |||
%YAML 1.1 | |||
%TAG !u! tag:unity3d.com,2011: | |||
--- !u!21 &2100000 | |||
Material: | |||
serializedVersion: 6 | |||
m_ObjectHideFlags: 0 | |||
m_PrefabParentObject: {fileID: 0} | |||
m_PrefabInternal: {fileID: 0} | |||
m_Name: PrimitiveMaterial | |||
m_Shader: {fileID: 4800000, guid: 972bc62358fe0b74390929ddcc7f76cc, type: 3} | |||
m_ShaderKeywords: _EMISSION | |||
m_LightmapFlags: 1 | |||
m_CustomRenderQueue: -1 | |||
stringTagMap: {} | |||
m_SavedProperties: | |||
serializedVersion: 2 | |||
m_TexEnvs: | |||
- first: | |||
name: _BumpMap | |||
second: | |||
m_Texture: {fileID: 0} | |||
m_Scale: {x: 1, y: 1} | |||
m_Offset: {x: 0, y: 0} | |||
- first: | |||
name: _DetailAlbedoMap | |||
second: | |||
m_Texture: {fileID: 0} | |||
m_Scale: {x: 1, y: 1} | |||
m_Offset: {x: 0, y: 0} | |||
- first: | |||
name: _DetailMask | |||
second: | |||
m_Texture: {fileID: 0} | |||
m_Scale: {x: 1, y: 1} | |||
m_Offset: {x: 0, y: 0} | |||
- first: | |||
name: _DetailNormalMap | |||
second: | |||
m_Texture: {fileID: 0} | |||
m_Scale: {x: 1, y: 1} | |||
m_Offset: {x: 0, y: 0} | |||
- first: | |||
name: _EmissionMap | |||
second: | |||
m_Texture: {fileID: 0} | |||
m_Scale: {x: 1, y: 1} | |||
m_Offset: {x: 0, y: 0} | |||
- first: | |||
name: _MainTex | |||
second: | |||
m_Texture: {fileID: 0} | |||
m_Scale: {x: 1, y: 1} | |||
m_Offset: {x: 0, y: 0} | |||
- first: | |||
name: _MetallicGlossMap | |||
second: | |||
m_Texture: {fileID: 0} | |||
m_Scale: {x: 1, y: 1} | |||
m_Offset: {x: 0, y: 0} | |||
- first: | |||
name: _OcclusionMap | |||
second: | |||
m_Texture: {fileID: 0} | |||
m_Scale: {x: 1, y: 1} | |||
m_Offset: {x: 0, y: 0} | |||
- first: | |||
name: _ParallaxMap | |||
second: | |||
m_Texture: {fileID: 0} | |||
m_Scale: {x: 1, y: 1} | |||
m_Offset: {x: 0, y: 0} | |||
m_Floats: | |||
- first: | |||
name: _BumpScale | |||
second: 1 | |||
- first: | |||
name: _Cutoff | |||
second: 0.5 | |||
- first: | |||
name: _DetailNormalMapScale | |||
second: 1 | |||
- first: | |||
name: _DstBlend | |||
second: 0 | |||
- first: | |||
name: _GlossMapScale | |||
second: 1 | |||
- first: | |||
name: _Glossiness | |||
second: 0.5 | |||
- first: | |||
name: _GlossyReflections | |||
second: 1 | |||
- first: | |||
name: _Metallic | |||
second: 0 | |||
- first: | |||
name: _Mode | |||
second: 0 | |||
- first: | |||
name: _OcclusionStrength | |||
second: 1 | |||
- first: | |||
name: _Parallax | |||
second: 0.02 | |||
- first: | |||
name: _Shininess | |||
second: 0.1 | |||
- first: | |||
name: _SmoothnessTextureChannel | |||
second: 0 | |||
- first: | |||
name: _SpecularHighlights | |||
second: 1 | |||
- first: | |||
name: _SrcBlend | |||
second: 1 | |||
- first: | |||
name: _UVSec | |||
second: 0 | |||
- first: | |||
name: _ZWrite | |||
second: 1 | |||
m_Colors: | |||
- first: | |||
name: _Color | |||
second: {r: 1, g: 0, b: 0, a: 0.134} | |||
- first: | |||
name: _Emission | |||
second: {r: 0, g: 0, b: 0, a: 0} | |||
- first: | |||
name: _EmissionColor | |||
second: {r: 0, g: 0, b: 0, a: 1} | |||
- first: | |||
name: _SpecColor | |||
second: {r: 1, g: 1, b: 1, a: 0} |
@ -0,0 +1,8 @@ | |||
fileFormatVersion: 2 | |||
guid: 0429485e63d913a438bd171228fce857 | |||
timeCreated: 1486134877 | |||
licenseType: Store | |||
NativeFormatImporter: | |||
userData: | |||
assetBundleName: | |||
assetBundleVariant: |
@ -0,0 +1,3 @@ | |||
version https://git-lfs.github.com/spec/v1 | |||
oid sha256:11f9764b533c28c9e22b6e67f1d71093133b8e827c1b1486856a920fbb40d633 | |||
size 15477 |
@ -0,0 +1,84 @@ | |||
fileFormatVersion: 2 | |||
guid: 3298446a06229a94794c43bcca9c789e | |||
timeCreated: 1488731317 | |||
licenseType: Store | |||
TextureImporter: | |||
fileIDToRecycleName: {} | |||
serializedVersion: 4 | |||
mipmaps: | |||
mipMapMode: 0 | |||
enableMipMap: 1 | |||
sRGBTexture: 0 | |||
linearTexture: 0 | |||
fadeOut: 0 | |||
borderMipMap: 0 | |||
mipMapFadeDistanceStart: 1 | |||
mipMapFadeDistanceEnd: 3 | |||
bumpmap: | |||
convertToNormalMap: 0 | |||
externalNormalMap: 0 | |||
heightScale: 0.25 | |||
normalMapFilter: 0 | |||
isReadable: 0 | |||
grayScaleToAlpha: 0 | |||
generateCubemap: 6 | |||
cubemapConvolution: 0 | |||
seamlessCubemap: 0 | |||
textureFormat: 1 | |||
maxTextureSize: 2048 | |||
textureSettings: | |||
filterMode: -1 | |||
aniso: -1 | |||
mipBias: -1 | |||
wrapMode: -1 | |||
nPOTScale: 1 | |||
lightmap: 0 | |||
compressionQuality: 50 | |||
spriteMode: 0 | |||
spriteExtrude: 1 | |||
spriteMeshType: 1 | |||
alignment: 0 | |||
spritePivot: {x: 0.5, y: 0.5} | |||
spriteBorder: {x: 0, y: 0, z: 0, w: 0} | |||
spritePixelsToUnits: 100 | |||
alphaUsage: 1 | |||
alphaIsTransparency: 0 | |||
spriteTessellationDetail: -1 | |||
textureType: 0 | |||
textureShape: 1 | |||
maxTextureSizeSet: 0 | |||
compressionQualitySet: 0 | |||
textureFormatSet: 0 | |||
platformSettings: | |||
- buildTarget: DefaultTexturePlatform | |||
maxTextureSize: 2048 | |||
textureFormat: -1 | |||
textureCompression: 1 | |||
compressionQuality: 50 | |||
crunchedCompression: 0 | |||
allowsAlphaSplitting: 0 | |||
overridden: 0 | |||
- buildTarget: Standalone | |||
maxTextureSize: 2048 | |||
textureFormat: -1 | |||
textureCompression: 1 | |||
compressionQuality: 50 | |||
crunchedCompression: 0 | |||
allowsAlphaSplitting: 0 | |||
overridden: 0 | |||
- buildTarget: Android | |||
maxTextureSize: 2048 | |||
textureFormat: -1 | |||
textureCompression: 1 | |||
compressionQuality: 50 | |||
crunchedCompression: 0 | |||
allowsAlphaSplitting: 0 | |||
overridden: 0 | |||
spriteSheet: | |||
serializedVersion: 2 | |||
sprites: [] | |||
outline: [] | |||
spritePackingTag: | |||
userData: | |||
assetBundleName: | |||
assetBundleVariant: |
@ -0,0 +1,3 @@ | |||
version https://git-lfs.github.com/spec/v1 | |||
oid sha256:33499fa244a4508babb8f8e7240a1379f7954534edd9a91211330ff976817841 | |||
size 17036 |
@ -0,0 +1,84 @@ | |||
fileFormatVersion: 2 | |||
guid: b3cbd19ea200f8f4eabe95b0c7b2ac88 | |||
timeCreated: 1489168403 | |||
licenseType: Store | |||
TextureImporter: | |||
fileIDToRecycleName: {} | |||
serializedVersion: 4 | |||
mipmaps: | |||
mipMapMode: 0 | |||
enableMipMap: 1 | |||
sRGBTexture: 1 | |||
linearTexture: 0 | |||
fadeOut: 0 | |||
borderMipMap: 0 | |||
mipMapFadeDistanceStart: 1 | |||
mipMapFadeDistanceEnd: 3 | |||
bumpmap: | |||
convertToNormalMap: 0 | |||
externalNormalMap: 0 | |||
heightScale: 0.25 | |||
normalMapFilter: 0 | |||
isReadable: 0 | |||
grayScaleToAlpha: 0 | |||
generateCubemap: 6 | |||
cubemapConvolution: 0 | |||
seamlessCubemap: 0 | |||
textureFormat: 1 | |||
maxTextureSize: 2048 | |||
textureSettings: | |||
filterMode: -1 | |||
aniso: -1 | |||
mipBias: -1 | |||
wrapMode: -1 | |||
nPOTScale: 1 | |||
lightmap: 0 | |||
compressionQuality: 50 | |||
spriteMode: 0 | |||
spriteExtrude: 1 | |||
spriteMeshType: 1 | |||
alignment: 0 | |||
spritePivot: {x: 0.5, y: 0.5} | |||
spriteBorder: {x: 0, y: 0, z: 0, w: 0} | |||
spritePixelsToUnits: 100 | |||
alphaUsage: 1 | |||
alphaIsTransparency: 1 | |||
spriteTessellationDetail: -1 | |||
textureType: 0 | |||
textureShape: 1 | |||
maxTextureSizeSet: 0 | |||
compressionQualitySet: 0 | |||
textureFormatSet: 0 | |||
platformSettings: | |||
- buildTarget: DefaultTexturePlatform | |||
maxTextureSize: 2048 | |||
textureFormat: -1 | |||
textureCompression: 0 | |||
compressionQuality: 50 | |||
crunchedCompression: 0 | |||
allowsAlphaSplitting: 0 | |||
overridden: 0 | |||
- buildTarget: Standalone | |||
maxTextureSize: 2048 | |||
textureFormat: -1 | |||
textureCompression: 0 | |||
compressionQuality: 50 | |||
crunchedCompression: 0 | |||
allowsAlphaSplitting: 0 | |||
overridden: 0 | |||
- buildTarget: Android | |||
maxTextureSize: 2048 | |||
textureFormat: -1 | |||
textureCompression: 0 | |||
compressionQuality: 50 | |||
crunchedCompression: 0 | |||
allowsAlphaSplitting: 0 | |||
overridden: 0 | |||
spriteSheet: | |||
serializedVersion: 2 | |||
sprites: [] | |||
outline: [] | |||
spritePackingTag: | |||
userData: | |||
assetBundleName: | |||
assetBundleVariant: |
@ -0,0 +1,3 @@ | |||
version https://git-lfs.github.com/spec/v1 | |||
oid sha256:e93c9963905a9a268061f3be3b1930382b508df9298ea0dd79462e8ff619723e | |||
size 20708 |
@ -0,0 +1,68 @@ | |||
fileFormatVersion: 2 | |||
guid: b5f42876d5d9f774192a15469e85640c | |||
timeCreated: 1489168403 | |||
licenseType: Store | |||
TextureImporter: | |||
fileIDToRecycleName: {} | |||
serializedVersion: 4 | |||
mipmaps: | |||
mipMapMode: 0 | |||
enableMipMap: 1 | |||
sRGBTexture: 1 | |||
linearTexture: 0 | |||
fadeOut: 0 | |||
borderMipMap: 0 | |||
mipMapFadeDistanceStart: 1 | |||
mipMapFadeDistanceEnd: 3 | |||
bumpmap: | |||
convertToNormalMap: 0 | |||
externalNormalMap: 0 | |||
heightScale: 0.25 | |||
normalMapFilter: 0 | |||
isReadable: 0 | |||
grayScaleToAlpha: 0 | |||
generateCubemap: 6 | |||
cubemapConvolution: 0 | |||
seamlessCubemap: 0 | |||
textureFormat: 1 | |||
maxTextureSize: 2048 | |||
textureSettings: | |||
filterMode: -1 | |||
aniso: -1 | |||
mipBias: -1 | |||
wrapMode: -1 | |||
nPOTScale: 1 | |||
lightmap: 0 | |||
compressionQuality: 50 | |||
spriteMode: 0 | |||
spriteExtrude: 1 | |||
spriteMeshType: 1 | |||
alignment: 0 | |||
spritePivot: {x: 0.5, y: 0.5} | |||
spriteBorder: {x: 0, y: 0, z: 0, w: 0} | |||
spritePixelsToUnits: 100 | |||
alphaUsage: 1 | |||
alphaIsTransparency: 0 | |||
spriteTessellationDetail: -1 | |||
textureType: 0 | |||
textureShape: 1 | |||
maxTextureSizeSet: 0 | |||
compressionQualitySet: 0 | |||
textureFormatSet: 0 | |||
platformSettings: | |||
- buildTarget: DefaultTexturePlatform | |||
maxTextureSize: 2048 | |||
textureFormat: -1 | |||
textureCompression: 1 | |||
compressionQuality: 50 | |||
crunchedCompression: 0 | |||
allowsAlphaSplitting: 0 | |||
overridden: 0 | |||
spriteSheet: | |||
serializedVersion: 2 | |||
sprites: [] | |||
outline: [] | |||
spritePackingTag: | |||
userData: | |||
assetBundleName: | |||
assetBundleVariant: |
@ -0,0 +1,3 @@ | |||
version https://git-lfs.github.com/spec/v1 | |||
oid sha256:3c0f57a80774e651aaec1601e6556f338df70048fb6a413b0eefd2dd6ecc5429 | |||
size 16844 |
@ -0,0 +1,84 @@ | |||
fileFormatVersion: 2 | |||
guid: 4ccdf6e7c7957f943b22d8a587a290f7 | |||
timeCreated: 1488729710 | |||
licenseType: Store | |||
TextureImporter: | |||
fileIDToRecycleName: {} | |||
serializedVersion: 4 | |||
mipmaps: | |||
mipMapMode: 0 | |||
enableMipMap: 1 | |||
sRGBTexture: 0 | |||
linearTexture: 0 | |||
fadeOut: 0 | |||
borderMipMap: 0 | |||
mipMapFadeDistanceStart: 1 | |||
mipMapFadeDistanceEnd: 3 | |||
bumpmap: | |||
convertToNormalMap: 0 | |||
externalNormalMap: 0 | |||
heightScale: 0.25 | |||
normalMapFilter: 0 | |||
isReadable: 0 | |||
grayScaleToAlpha: 0 | |||
generateCubemap: 6 | |||
cubemapConvolution: 0 | |||
seamlessCubemap: 0 | |||
textureFormat: 1 | |||
maxTextureSize: 2048 | |||
textureSettings: | |||
filterMode: -1 | |||
aniso: -1 | |||
mipBias: -1 | |||
wrapMode: 1 | |||
nPOTScale: 1 | |||
lightmap: 0 | |||
compressionQuality: 50 | |||
spriteMode: 0 | |||
spriteExtrude: 1 | |||
spriteMeshType: 1 | |||
alignment: 0 | |||
spritePivot: {x: 0.5, y: 0.5} | |||
spriteBorder: {x: 0, y: 0, z: 0, w: 0} | |||
spritePixelsToUnits: 100 | |||
alphaUsage: 1 | |||
alphaIsTransparency: 0 | |||
spriteTessellationDetail: -1 | |||
textureType: 0 | |||
textureShape: 1 | |||
maxTextureSizeSet: 0 | |||
compressionQualitySet: 0 | |||
textureFormatSet: 0 | |||
platformSettings: | |||
- buildTarget: DefaultTexturePlatform | |||
maxTextureSize: 2048 | |||
textureFormat: -1 | |||
textureCompression: 0 | |||
compressionQuality: 50 | |||
crunchedCompression: 0 | |||
allowsAlphaSplitting: 0 | |||
overridden: 0 | |||
- buildTarget: Standalone | |||
maxTextureSize: 2048 | |||
textureFormat: -1 | |||
textureCompression: 0 | |||
compressionQuality: 50 | |||
crunchedCompression: 0 | |||
allowsAlphaSplitting: 0 | |||
overridden: 0 | |||
- buildTarget: Android | |||
maxTextureSize: 2048 | |||
textureFormat: -1 | |||
textureCompression: 0 | |||
compressionQuality: 50 | |||
crunchedCompression: 0 | |||
allowsAlphaSplitting: 0 | |||
overridden: 0 | |||
spriteSheet: | |||
serializedVersion: 2 | |||
sprites: [] | |||
outline: [] | |||
spritePackingTag: | |||
userData: | |||
assetBundleName: | |||
assetBundleVariant: |
@ -0,0 +1,3 @@ | |||
version https://git-lfs.github.com/spec/v1 | |||
oid sha256:d4646f50168e5089a157f283a4f067892fdf13c108615ab26ab740095fdd08a3 | |||
size 23816 |
@ -0,0 +1,84 @@ | |||
fileFormatVersion: 2 | |||
guid: dd3619a9238e485498bd8ad89a1d0a1e | |||
timeCreated: 1488729710 | |||
licenseType: Store | |||
TextureImporter: | |||
fileIDToRecycleName: {} | |||
serializedVersion: 4 | |||
mipmaps: | |||
mipMapMode: 0 | |||
enableMipMap: 0 | |||
sRGBTexture: 1 | |||
linearTexture: 0 | |||
fadeOut: 0 | |||
borderMipMap: 0 | |||
mipMapFadeDistanceStart: 1 | |||
mipMapFadeDistanceEnd: 3 | |||
bumpmap: | |||
convertToNormalMap: 0 | |||
externalNormalMap: 0 | |||
heightScale: 0.25 | |||
normalMapFilter: 0 | |||
isReadable: 0 | |||
grayScaleToAlpha: 0 | |||
generateCubemap: 6 | |||
cubemapConvolution: 0 | |||
seamlessCubemap: 0 | |||
textureFormat: 1 | |||
maxTextureSize: 2048 | |||
textureSettings: | |||
filterMode: 0 | |||
aniso: -1 | |||
mipBias: -1 | |||
wrapMode: 1 | |||
nPOTScale: 1 | |||
lightmap: 0 | |||
compressionQuality: 50 | |||
spriteMode: 0 | |||
spriteExtrude: 1 | |||
spriteMeshType: 1 | |||
alignment: 0 | |||
spritePivot: {x: 0.5, y: 0.5} | |||
spriteBorder: {x: 0, y: 0, z: 0, w: 0} | |||
spritePixelsToUnits: 100 | |||
alphaUsage: 1 | |||
alphaIsTransparency: 0 | |||
spriteTessellationDetail: -1 | |||
textureType: 0 | |||
textureShape: 1 | |||
maxTextureSizeSet: 0 | |||
compressionQualitySet: 0 | |||
textureFormatSet: 0 | |||
platformSettings: | |||
- buildTarget: DefaultTexturePlatform | |||
maxTextureSize: 2048 | |||
textureFormat: -1 | |||
textureCompression: 1 | |||
compressionQuality: 50 | |||
crunchedCompression: 0 | |||
allowsAlphaSplitting: 0 | |||
overridden: 0 | |||
- buildTarget: Standalone | |||
maxTextureSize: 2048 | |||
textureFormat: -1 | |||
textureCompression: 1 | |||
compressionQuality: 50 | |||
crunchedCompression: 0 | |||
allowsAlphaSplitting: 0 | |||
overridden: 0 | |||
- buildTarget: Android | |||
maxTextureSize: 2048 | |||
textureFormat: -1 | |||
textureCompression: 1 | |||
compressionQuality: 50 | |||
crunchedCompression: 0 | |||
allowsAlphaSplitting: 0 | |||
overridden: 0 | |||
spriteSheet: | |||
serializedVersion: 2 | |||
sprites: [] | |||
outline: [] | |||
spritePackingTag: | |||
userData: | |||
assetBundleName: | |||
assetBundleVariant: |
@ -0,0 +1,90 @@ | |||
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)' | |||
Shader "Fog Volume/Shadow Projector" | |||
{ | |||
Properties | |||
{ | |||
[NoScaleOffset]_MainTex("ShadowMap", 2D) = "white" {} | |||
displacePower("light Displace intensity", range(.01,.3)) = 0.079 | |||
_ShadowColor("ShadowColor", Color)=(0,0,0,0) | |||
_Cutoff("Alpha cutoff", Range(0,1)) = 0.01//TODO: Publish | |||
} | |||
SubShader | |||
{ Tags{ | |||
"Queue" = "AlphaTest" | |||
"IgnoreProjector" = "True" | |||
"RenderType" = "NeverRenderMe" | |||
} | |||
Pass | |||
{ | |||
Fog{ Mode Off } | |||
Blend DstColor OneMinusSrcAlpha | |||
Cull front | |||
ZWrite Off | |||
ZTest Always | |||
Lighting Off | |||
CGPROGRAM | |||
#pragma target 3.0 | |||
#pragma vertex vert | |||
#pragma fragment frag | |||
#include "UnityCG.cginc" | |||
struct v2f | |||
{ | |||
float4 pos : SV_POSITION; | |||
half2 uv : TEXCOORD0; | |||
float4 screenUV : TEXCOORD1; | |||
float3 ray : TEXCOORD2; | |||
half3 orientation : TEXCOORD3; | |||
}; | |||
v2f vert(float3 v : POSITION) | |||
{ | |||
v2f o; | |||
o.pos = UnityObjectToClipPos(float4(v,1)); | |||
o.uv = v.xz + 0.5; | |||
o.screenUV = ComputeScreenPos(o.pos); | |||
//o.ray = mul(UNITY_MATRIX_MV, float4(v,1)).xyz * float3(-1,-1,1); | |||
//5.6: | |||
o.ray = UnityObjectToViewPos(float4(v, 1) ).xyz* float3(-1, -1, 1); | |||
o.orientation = mul((float3x3)unity_ObjectToWorld, float3(0,1,0)); | |||
return o; | |||
} | |||
uniform float3 L; | |||
sampler2D _MainTex, RT_OpacityBlur; | |||
sampler2D_float _CameraDepthTexture; | |||
half displacePower; | |||
half _Cutoff; | |||
half4 _ShadowColor; | |||
fixed4 frag(v2f i) : COLOR0 | |||
{ | |||
i.ray = i.ray * (_ProjectionParams.z / i.ray.z); | |||
float2 uv = i.screenUV.xy / i.screenUV.w; | |||
// read depth and reconstruct world position | |||
float depth = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, uv); | |||
depth = Linear01Depth(depth); | |||
float4 vpos = float4(i.ray * depth,1); | |||
float3 wpos = mul(unity_CameraToWorld, vpos).xyz; | |||
float3 opos = mul(unity_WorldToObject, float4(wpos,1)).xyz; | |||
clip(float3(0.5,0.5,0.5) - abs(opos.xyz)); | |||
i.uv = opos.xz + 0.5; | |||
i.uv = i.uv + displacePower*L.xz; | |||
fixed4 col = tex2D(RT_OpacityBlur, i.uv).r; | |||
clip(col.a - _Cutoff); | |||
col.rgb = _ShadowColor*( col.a); | |||
//return float4(0,0,0,1); | |||
return float4(col.rgb, col.a); | |||
} | |||
ENDCG | |||
} | |||
} | |||
Fallback Off | |||
} |
@ -0,0 +1,9 @@ | |||
fileFormatVersion: 2 | |||
guid: 9ce744ea82afbbf4db94c6c3cea51a55 | |||
timeCreated: 1483545112 | |||
licenseType: Store | |||
ShaderImporter: | |||
defaultTextures: [] | |||
userData: | |||
assetBundleName: | |||
assetBundleVariant: |
@ -0,0 +1,53 @@ | |||
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)' | |||
Shader "Hidden/Fog Volume/Shadow Postprocess" | |||
{ | |||
Properties { _MainTex ("", any) = "" {} } | |||
CGINCLUDE | |||
#include "UnityCG.cginc" | |||
struct v2f { | |||
float4 pos : SV_POSITION; | |||
half2 uv : TEXCOORD0; | |||
}; | |||
sampler2D _MainTex; | |||
half4 _MainTex_TexelSize; | |||
half3 ContrastF(half3 pixelColor, fixed contrast) | |||
{ | |||
return saturate(((pixelColor.rgb - 0.5f) * max(contrast, 0)) + 0.5f); | |||
} | |||
half ShadowColor; | |||
v2f vert( appdata_img v ) { | |||
v2f o; | |||
o.pos = UnityObjectToClipPos(v.vertex); | |||
o.uv = v.texcoord ; | |||
return o; | |||
} | |||
half4 frag(v2f i) : SV_Target { | |||
half4 color = tex2D(_MainTex, i.uv); | |||
//color.a *= 0; | |||
//color.a = ContrastF(color.a, ShadowColor+1); | |||
//color.a = ContrastF(color.a ,ShadowColor*5); | |||
half edges = saturate(dot(1 - i.uv.r, 1 - i.uv.g) * dot(i.uv.r, i.uv.g) * 600); | |||
edges *= edges*edges; | |||
color.r = color.r + color.r*ShadowColor*50* edges; | |||
color.r = lerp(0, color.r,edges); | |||
return min(color.r,1); | |||
} | |||
ENDCG | |||
SubShader { | |||
Pass { | |||
ZTest Always Cull Off ZWrite Off | |||
CGPROGRAM | |||
#pragma vertex vert | |||
#pragma fragment frag | |||
ENDCG | |||
} | |||
} | |||
Fallback off | |||
} |
@ -0,0 +1,9 @@ | |||
fileFormatVersion: 2 | |||
guid: 842731f1956de61489d5e464632cccb5 | |||
timeCreated: 1483594902 | |||
licenseType: Store | |||
ShaderImporter: | |||
defaultTextures: [] | |||
userData: | |||
assetBundleName: | |||
assetBundleVariant: |
@ -0,0 +1,3 @@ | |||
version https://git-lfs.github.com/spec/v1 | |||
oid sha256:1525c850449ce2125b833e87b65844779a0be310c1a141a0296815948ac7a880 | |||
size 12225 |
@ -0,0 +1,81 @@ | |||
fileFormatVersion: 2 | |||
guid: ad833311bc03b5347b5d73b503b9902e | |||
timeCreated: 1483557622 | |||
licenseType: Store | |||
ModelImporter: | |||
serializedVersion: 19 | |||
fileIDToRecycleName: | |||
100000: //RootNode | |||
400000: //RootNode | |||
2300000: //RootNode | |||
3300000: //RootNode | |||
4300000: Box001 | |||
4300002: ShadowVolume | |||
materials: | |||
importMaterials: 1 | |||
materialName: 0 | |||
materialSearch: 1 | |||
animations: | |||
legacyGenerateAnimations: 4 | |||
bakeSimulation: 0 | |||
resampleCurves: 1 | |||
optimizeGameObjects: 0 | |||
motionNodeName: | |||
animationImportErrors: | |||
animationImportWarnings: | |||
animationRetargetingWarnings: | |||
animationDoRetargetingWarnings: 0 | |||
animationCompression: 1 | |||
animationRotationError: 0.5 | |||
animationPositionError: 0.5 | |||
animationScaleError: 0.5 | |||
animationWrapMode: 0 | |||
extraExposedTransformPaths: [] | |||
clipAnimations: [] | |||
isReadable: 1 | |||
meshes: | |||
lODScreenPercentages: [] | |||
globalScale: 1 | |||
meshCompression: 0 | |||
addColliders: 0 | |||
importBlendShapes: 1 | |||
swapUVChannels: 0 | |||
generateSecondaryUV: 1 | |||
useFileUnits: 1 | |||
optimizeMeshForGPU: 1 | |||
keepQuads: 0 | |||
weldVertices: 1 | |||
secondaryUVAngleDistortion: 8 | |||
secondaryUVAreaDistortion: 15.000001 | |||
secondaryUVHardAngle: 88 | |||
secondaryUVPackMargin: 4 | |||
useFileScale: 1 | |||
tangentSpace: | |||
normalSmoothAngle: 60 | |||
normalImportMode: 0 | |||
tangentImportMode: 3 | |||
importAnimation: 1 | |||
copyAvatar: 0 | |||
humanDescription: | |||
serializedVersion: 2 | |||
human: [] | |||
skeleton: [] | |||
armTwist: 0.5 | |||
foreArmTwist: 0.5 | |||
upperLegTwist: 0.5 | |||
legTwist: 0.5 | |||
armStretch: 0.05 | |||
legStretch: 0.05 | |||
feetSpacing: 0 | |||
rootMotionBoneName: | |||
rootMotionBoneRotation: {x: 0, y: 0, z: 0, w: 1} | |||
hasTranslationDoF: 0 | |||
hasExtraRoot: 0 | |||
skeletonHasParents: 1 | |||
lastHumanDescriptionAvatarSource: {instanceID: 0} | |||
animationType: 0 | |||
humanoidOversampling: 1 | |||
additionalBone: 0 | |||
userData: | |||
assetBundleName: | |||
assetBundleVariant: |
@ -0,0 +1,130 @@ | |||
// Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt) | |||
#ifndef SPEEDTREE_COMMON_INCLUDED | |||
#define SPEEDTREE_COMMON_INCLUDED | |||
#include "UnityCG.cginc" | |||
#define SPEEDTREE_Y_UP | |||
#ifdef GEOM_TYPE_BRANCH_DETAIL | |||
#define GEOM_TYPE_BRANCH | |||
#endif | |||
#include "SpeedTreeVertexDepth.cginc" | |||
// Define Input structure | |||
struct Input | |||
{ | |||
fixed4 color; | |||
half3 interpolator1; | |||
#ifdef GEOM_TYPE_BRANCH_DETAIL | |||
half3 interpolator2; | |||
#endif | |||
UNITY_DITHER_CROSSFADE_COORDS | |||
half depth; | |||
half ShadowDepth; | |||
float4 screenUV; | |||
}; | |||
// Define uniforms | |||
float4 _ShadowCameraPosition; | |||
#define mainTexUV interpolator1.xy | |||
//sampler2D _MainTex; | |||
#ifdef GEOM_TYPE_BRANCH_DETAIL | |||
#define Detail interpolator2 | |||
sampler2D _DetailTex; | |||
#endif | |||
//#if defined(GEOM_TYPE_FROND) || defined(GEOM_TYPE_LEAF) || defined(GEOM_TYPE_FACING_LEAF) | |||
// #define SPEEDTREE_ALPHATEST | |||
// fixed _Cutoff; | |||
//#endif | |||
#ifdef EFFECT_HUE_VARIATION | |||
#define HueVariationAmount interpolator1.z | |||
half4 _HueVariation; | |||
#endif | |||
#if defined(EFFECT_BUMP) && !defined(LIGHTMAP_ON) | |||
sampler2D _BumpMap; | |||
#endif | |||
//fixed4 _Color; | |||
// Vertex processing | |||
void SpeedTreeVert(inout SpeedTreeVB IN, out Input OUT) | |||
{ | |||
UNITY_INITIALIZE_OUTPUT(Input, OUT); | |||
OUT.depth = -(UnityObjectToViewPos(IN.vertex).z/* * _ProjectionParams.w*/); | |||
float4 pos = UnityObjectToClipPos(IN.vertex); | |||
OUT.screenUV = ComputeScreenPos(pos); | |||
OUT.ShadowDepth = length(mul(unity_ObjectToWorld, IN.vertex).xyz - _ShadowCameraPosition.xyz); | |||
OUT.mainTexUV = IN.texcoord.xy; | |||
//OUT.color = _Color; | |||
// OUT.color.rgb *= IN.color.r; // ambient occlusion factor | |||
#ifdef EFFECT_HUE_VARIATION | |||
float hueVariationAmount = frac(unity_ObjectToWorld[0].w + unity_ObjectToWorld[1].w + unity_ObjectToWorld[2].w); | |||
hueVariationAmount += frac(IN.vertex.x + IN.normal.y + IN.normal.x) * 0.5 - 0.3; | |||
OUT.HueVariationAmount = saturate(hueVariationAmount * _HueVariation.a); | |||
#endif | |||
#ifdef GEOM_TYPE_BRANCH_DETAIL | |||
// The two types are always in different sub-range of the mesh so no interpolation (between detail and blend) problem. | |||
OUT.Detail.xy = IN.texcoord2.xy; | |||
if (IN.color.a == 0) // Blend | |||
OUT.Detail.z = IN.texcoord2.z; | |||
else // Detail texture | |||
OUT.Detail.z = 2.5f; // stay out of Blend's .z range | |||
#endif | |||
OffsetSpeedTreeVertex(IN, unity_LODFade.x); | |||
UNITY_TRANSFER_DITHER_CROSSFADE(OUT, IN.vertex) | |||
} | |||
// Fragment processing | |||
#if defined(EFFECT_BUMP) && !defined(LIGHTMAP_ON) | |||
#define SPEEDTREE_DATA_NORMAL fixed3 Normal; | |||
#define SPEEDTREE_COPY_NORMAL(to, from) to.Normal = from.Normal; | |||
#else | |||
#define SPEEDTREE_DATA_NORMAL | |||
#define SPEEDTREE_COPY_NORMAL(to, from) | |||
#endif | |||
#define SPEEDTREE_COPY_FRAG(to, from) \ | |||
to.Alpha = from.Alpha; \ | |||
SPEEDTREE_COPY_NORMAL(to, from) | |||
struct SpeedTreeFragOut | |||
{ | |||
// fixed3 Albedo; | |||
fixed Alpha; | |||
SPEEDTREE_DATA_NORMAL | |||
}; | |||
void SpeedTreeFrag(Input IN, out SpeedTreeFragOut OUT) | |||
{ | |||
half4 diffuseColor = tex2D(_MainTex, IN.mainTexUV); | |||
OUT.Alpha = diffuseColor.a * _Color.a; | |||
#ifdef SPEEDTREE_ALPHATEST | |||
clip(OUT.Alpha - _Cutoff); | |||
#endif | |||
// UNITY_APPLY_DITHER_CROSSFADE(IN) | |||
//OUT.Normal = float3(0, 0, 1); | |||
// OUT.Albedo = 0; | |||
} | |||
#endif // SPEEDTREE_COMMON_INCLUDED |
@ -0,0 +1,9 @@ | |||
fileFormatVersion: 2 | |||
guid: 0124b21de35226948a325a3e57c10c6f | |||
timeCreated: 1500756186 | |||
licenseType: Store | |||
ShaderImporter: | |||
defaultTextures: [] | |||
userData: | |||
assetBundleName: | |||
assetBundleVariant: |
@ -0,0 +1,148 @@ | |||
#ifndef SPEEDTREE_VERTEX_INCLUDED | |||
#define SPEEDTREE_VERTEX_INCLUDED | |||
/////////////////////////////////////////////////////////////////////// | |||
// SpeedTree v6 Vertex Processing | |||
/////////////////////////////////////////////////////////////////////// | |||
// struct SpeedTreeVB | |||
// texcoord setup | |||
// | |||
// BRANCHES FRONDS LEAVES | |||
// 0 diffuse uv, branch wind xy " " | |||
// 1 lod xyz, 0 lod xyz, 0 anchor xyz, lod scalar | |||
// 2 detail/seam uv, seam amount, 0 frond wind xyz, 0 leaf wind xyz, leaf group | |||
struct SpeedTreeVB | |||
{ | |||
float4 vertex : POSITION; | |||
float4 tangent : TANGENT; | |||
float3 normal : NORMAL; | |||
float4 texcoord : TEXCOORD0; | |||
float4 texcoord1 : TEXCOORD1; | |||
float4 texcoord2 : TEXCOORD2; | |||
float2 texcoord3 : TEXCOORD3; | |||
half4 color : COLOR; | |||
UNITY_VERTEX_INPUT_INSTANCE_ID | |||
}; | |||
/////////////////////////////////////////////////////////////////////// | |||
// SpeedTree winds | |||
#ifdef ENABLE_WIND | |||
#define WIND_QUALITY_NONE 0 | |||
#define WIND_QUALITY_FASTEST 1 | |||
#define WIND_QUALITY_FAST 2 | |||
#define WIND_QUALITY_BETTER 3 | |||
#define WIND_QUALITY_BEST 4 | |||
#define WIND_QUALITY_PALM 5 | |||
uniform half _WindQuality; | |||
uniform half _WindEnabled; | |||
#include "SpeedTreeWind.cginc" | |||
#endif | |||
/////////////////////////////////////////////////////////////////////// | |||
// OffsetSpeedTreeVertex | |||
void OffsetSpeedTreeVertex(inout SpeedTreeVB data, float lodValue) | |||
{ | |||
float3 finalPosition = data.vertex.xyz; | |||
#ifdef ENABLE_WIND | |||
half windQuality = _WindQuality * _WindEnabled; | |||
float3 rotatedWindVector, rotatedBranchAnchor; | |||
if (windQuality <= WIND_QUALITY_NONE) | |||
{ | |||
rotatedWindVector = float3(0.0f, 0.0f, 0.0f); | |||
rotatedBranchAnchor = float3(0.0f, 0.0f, 0.0f); | |||
} | |||
else | |||
{ | |||
// compute rotated wind parameters | |||
rotatedWindVector = normalize(mul(_ST_WindVector.xyz, (float3x3)unity_ObjectToWorld)); | |||
rotatedBranchAnchor = normalize(mul(_ST_WindBranchAnchor.xyz, (float3x3)unity_ObjectToWorld)) * _ST_WindBranchAnchor.w; | |||
} | |||
#endif | |||
#if defined(GEOM_TYPE_BRANCH) || defined(GEOM_TYPE_FROND) | |||
// smooth LOD | |||
#ifdef LOD_FADE_PERCENTAGE | |||
finalPosition = lerp(finalPosition, data.texcoord1.xyz, lodValue); | |||
#endif | |||
// frond wind, if needed | |||
#if defined(ENABLE_WIND) && defined(GEOM_TYPE_FROND) | |||
if (windQuality == WIND_QUALITY_PALM) | |||
finalPosition = RippleFrond(finalPosition, data.normal, data.texcoord.x, data.texcoord.y, data.texcoord2.x, data.texcoord2.y, data.texcoord2.z); | |||
#endif | |||
#elif defined(GEOM_TYPE_LEAF) | |||
// remove anchor position | |||
finalPosition -= data.texcoord1.xyz; | |||
bool isFacingLeaf = data.color.a == 0; | |||
if (isFacingLeaf) | |||
{ | |||
#ifdef LOD_FADE_PERCENTAGE | |||
finalPosition *= lerp(1.0, data.texcoord1.w, lodValue); | |||
#endif | |||
// face camera-facing leaf to camera | |||
float offsetLen = length(finalPosition); | |||
finalPosition = mul(finalPosition.xyz, (float3x3)UNITY_MATRIX_IT_MV); // inv(MV) * finalPosition | |||
finalPosition = normalize(finalPosition) * offsetLen; // make sure the offset vector is still scaled | |||
} | |||
else | |||
{ | |||
#ifdef LOD_FADE_PERCENTAGE | |||
float3 lodPosition = float3(data.texcoord1.w, data.texcoord3.x, data.texcoord3.y); | |||
finalPosition = lerp(finalPosition, lodPosition, lodValue); | |||
#endif | |||
} | |||
#ifdef ENABLE_WIND | |||
// leaf wind | |||
if (windQuality > WIND_QUALITY_FASTEST && windQuality < WIND_QUALITY_PALM) | |||
{ | |||
float leafWindTrigOffset = data.texcoord1.x + data.texcoord1.y; | |||
finalPosition = LeafWind(windQuality == WIND_QUALITY_BEST, data.texcoord2.w > 0.0, finalPosition, data.normal, data.texcoord2.x, float3(0,0,0), data.texcoord2.y, data.texcoord2.z, leafWindTrigOffset, rotatedWindVector); | |||
} | |||
#endif | |||
// move back out to anchor | |||
finalPosition += data.texcoord1.xyz; | |||
#endif | |||
#ifdef ENABLE_WIND | |||
float3 treePos = float3(unity_ObjectToWorld[0].w, unity_ObjectToWorld[1].w, unity_ObjectToWorld[2].w); | |||
#ifndef GEOM_TYPE_MESH | |||
if (windQuality >= WIND_QUALITY_BETTER) | |||
{ | |||
// branch wind (applies to all 3D geometry) | |||
finalPosition = BranchWind(windQuality == WIND_QUALITY_PALM, finalPosition, treePos, float4(data.texcoord.zw, 0, 0), rotatedWindVector, rotatedBranchAnchor); | |||
} | |||
#endif | |||
if (windQuality > WIND_QUALITY_NONE) | |||
{ | |||
// global wind | |||
finalPosition = GlobalWind(finalPosition, treePos, true, rotatedWindVector, _ST_WindGlobal.x); | |||
} | |||
#endif | |||
data.vertex.xyz = finalPosition; | |||
} | |||
#endif // SPEEDTREE_VERTEX_INCLUDED |
@ -0,0 +1,9 @@ | |||
fileFormatVersion: 2 | |||
guid: d1859f20293386b4586d3ac9b0a623a7 | |||
timeCreated: 1500758463 | |||
licenseType: Store | |||
ShaderImporter: | |||
defaultTextures: [] | |||
userData: | |||
assetBundleName: | |||
assetBundleVariant: |
@ -0,0 +1,87 @@ | |||
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)' | |||
//Shader "Hidden/LowResReplace" | |||
Shader "Hidden/Fog Volume/Surrogate" | |||
{ | |||
SubShader{ | |||
Tags{ | |||
"Queue" = "Transparent" "IgnoreProjector" = "True" | |||
// "RenderType" = "Opaque" | |||
} | |||
LOD 100 | |||
//Blend One OneMinusSrcAlpha | |||
// Blend SrcAlpha OneMinusSrcAlpha | |||
Blend[_SrcBlend] OneMinusSrcAlpha //One OneMinusSrcAlpha works best with noise | |||
Fog{ Mode Off } | |||
Cull Front | |||
Lighting Off | |||
ZWrite Off | |||
ZTest [_ztest] | |||
//ZTest LEqual | |||
Pass | |||
{ | |||
CGPROGRAM | |||
#pragma vertex vert | |||
#pragma fragment frag | |||
#include "UnityCG.cginc" | |||
#pragma shader_feature _EDITOR_WINDOW | |||
#define red float4(1, 0,0,1) | |||
#define green float4(0, 1,0,1) | |||
int _SrcBlend, _ztest; | |||
sampler2D RT_FogVolume, RT_FogVolumeR; | |||
struct appdata_t { | |||
float4 vertex : POSITION; | |||
float2 texcoord: TEXCOORD0; | |||
}; | |||
struct v2f { | |||
float4 vertex : SV_POSITION; | |||
float4 projPos : TEXCOORD0; | |||
//float2 uv : TEXCOORD1; | |||
}; | |||
v2f vert(appdata_t v) | |||
{ | |||
#if UNITY_UV_STARTS_AT_TOP | |||
float scale = -1.0; | |||
#else | |||
float scale = 1.0; | |||
#endif | |||
v2f o; | |||
o.vertex = UnityObjectToClipPos(v.vertex); | |||
o.projPos = ComputeScreenPos(o.vertex); | |||
return o; | |||
} | |||
half4 frag(v2f i) : SV_Target | |||
{ | |||
float4 coords = 0, FV; | |||
coords = UNITY_PROJ_COORD(i.projPos); | |||
float2 screenUV = coords.xy / coords.w; | |||
#if UNITY_SINGLE_PASS_STEREO | |||
float4 scaleOffset = unity_StereoScaleOffset[unity_StereoEyeIndex]; | |||
screenUV = (screenUV - scaleOffset.zw) / scaleOffset.xy; | |||
#endif | |||
if (unity_StereoEyeIndex == 0) | |||
{ | |||
FV = tex2D(RT_FogVolume, screenUV)/**red*/; | |||
} | |||
else | |||
{ | |||
FV = tex2D(RT_FogVolumeR, screenUV)/**green*/; | |||
} | |||
#ifdef _EDITOR_WINDOW | |||
FV = 0; | |||
// FV= float4(1, 0, 0, 1)*FV; | |||
#endif | |||
return FV; | |||
return float4(1, 0, 0, 1)*FV; | |||
} | |||
ENDCG | |||
} | |||
} | |||
} |
@ -0,0 +1,9 @@ | |||
fileFormatVersion: 2 | |||
guid: 8363634d6593ec54ab321a7f0e84fd28 | |||
timeCreated: 1487628103 | |||
licenseType: Store | |||
ShaderImporter: | |||
defaultTextures: [] | |||
userData: | |||
assetBundleName: | |||
assetBundleVariant: |
@ -0,0 +1,306 @@ | |||
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)' | |||
// Copyright(c) 2016, Michal Skalsky | |||
// All rights reserved. | |||
// | |||
// Redistribution and use in source and binary forms, with or without modification, | |||
// are permitted provided that the following conditions are met: | |||
// | |||
// 1. Redistributions of source code must retain the above copyright notice, | |||
// this list of conditions and the following disclaimer. | |||
// | |||
// 2. Redistributions in binary form must reproduce the above copyright notice, | |||
// this list of conditions and the following disclaimer in the documentation | |||
// and/or other materials provided with the distribution. | |||
// | |||
// 3. Neither the name of the copyright holder nor the names of its contributors | |||
// may be used to endorse or promote products derived from this software without | |||
// specific prior written permission. | |||
// | |||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY | |||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||
// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.IN NO EVENT | |||
// SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT | |||
// OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |||
// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR | |||
// TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, | |||
// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||
//Modified by Carlos Macarrón & David Miranda | |||
Shader "Hidden/Upsample" | |||
{ | |||
Properties | |||
{ | |||
_UpsampleDepthThreshold("Upsample Depth Threshold", Range(0, 2)) = .05 | |||
[HideInInspector] _LowResColor("", 2D) = "white"{} | |||
} | |||
SubShader | |||
{ | |||
// No culling or depth | |||
Cull Off ZWrite Off ZTest Always | |||
CGINCLUDE | |||
// #define UPSAMPLE_DEPTH_THRESHOLD 0.05f | |||
uniform half _UpsampleDepthThreshold = .05; | |||
int RightSide; | |||
#define PI 3.1415927f | |||
#include "UnityCG.cginc" | |||
float4 _TexelSize = 1; | |||
sampler2D _HiResDepthBufferR; | |||
sampler2D _HiResDepthBuffer; | |||
sampler2D _LowResDepthBuffer; | |||
sampler2D _LowResDepthBufferR; | |||
sampler2D _LowResColor; | |||
sampler2D _LowResColorR; | |||
struct appdata | |||
{ | |||
float4 vertex : POSITION; | |||
float2 uv : TEXCOORD0; | |||
}; | |||
struct v2fDownsample | |||
{ | |||
float4 vertex : SV_POSITION0; | |||
float2 uv : TEXCOORD0; | |||
float2 uv00 : TEXCOORD1; | |||
float2 uv01 : TEXCOORD2; | |||
float2 uv10 : TEXCOORD3; | |||
float2 uv11 : TEXCOORD4; | |||
}; | |||
struct v2fUpsample | |||
{ | |||
float4 vertex : SV_POSITION; | |||
float2 uv : TEXCOORD0; | |||
float2 uv00 : TEXCOORD1; | |||
float2 uv01 : TEXCOORD2; | |||
float2 uv10 : TEXCOORD3; | |||
float2 uv11 : TEXCOORD4; | |||
}; | |||
//----------------------------------------------------------------------------------------- | |||
// vertDownsampleDepth | |||
//----------------------------------------------------------------------------------------- | |||
v2fDownsample vertDownsampleDepth(appdata v, float2 texelSize) | |||
{ | |||
v2fDownsample o; | |||
UNITY_INITIALIZE_OUTPUT(v2fDownsample, o); | |||
o.vertex = UnityObjectToClipPos(v.vertex); | |||
#if UNITY_SINGLE_PASS_STEREO | |||
o.uv = UnityStereoTransformScreenSpaceTex(v.uv); | |||
#else | |||
o.uv = v.uv; | |||
#endif | |||
o.uv00 = v.uv - 0.5 * texelSize.xy; | |||
o.uv10 = o.uv00 + float2(texelSize.x, 0); | |||
o.uv01 = o.uv00 + float2(0, texelSize.y); | |||
o.uv11 = o.uv00 + texelSize.xy; | |||
return o; | |||
} | |||
//----------------------------------------------------------------------------------------- | |||
// vertUpsample | |||
//----------------------------------------------------------------------------------------- | |||
v2fUpsample vertUpsample(appdata v, float2 texelSize) | |||
{ | |||
v2fUpsample o; | |||
UNITY_INITIALIZE_OUTPUT(v2fUpsample, o); | |||
o.vertex = UnityObjectToClipPos(v.vertex); | |||
#if UNITY_SINGLE_PASS_STEREO | |||
o.uv = UnityStereoTransformScreenSpaceTex(v.uv); | |||
#else | |||
o.uv = v.uv; | |||
#endif | |||
o.uv00 = v.uv - 0.5 * texelSize.xy; | |||
o.uv10 = o.uv00 + float2(texelSize.x, 0); | |||
o.uv01 = o.uv00 + float2(0, texelSize.y); | |||
o.uv11 = o.uv00 + texelSize.xy; | |||
return o; | |||
} | |||
#undef SAMPLE_DEPTH_TEXTURE | |||
#define SAMPLE_DEPTH_TEXTURE(sampler, uv) ( tex2D(sampler, uv).r ) | |||
//----------------------------------------------------------------------------------------- | |||
// BilateralUpsample | |||
//----------------------------------------------------------------------------------------- | |||
float4 BilateralUpsample(v2fUpsample input, sampler2D hiDepth, sampler2D loDepth, sampler2D loColor) | |||
{ | |||
float4 highResDepth = (SAMPLE_DEPTH_TEXTURE(hiDepth, input.uv)).xxxx; | |||
float4 lowResDepth=0; | |||
#if UNITY_SINGLE_PASS_STEREO | |||
float4 scaleOffset = unity_StereoScaleOffset[unity_StereoEyeIndex]; | |||
input.uv00 = (input.uv00 - scaleOffset.zw) / scaleOffset.xy; | |||
input.uv10 = (input.uv10 - scaleOffset.zw) / scaleOffset.xy; | |||
input.uv01 = (input.uv01 - scaleOffset.zw) / scaleOffset.xy; | |||
input.uv11 = (input.uv11 - scaleOffset.zw) / scaleOffset.xy; | |||
#endif | |||
lowResDepth[0] = (SAMPLE_DEPTH_TEXTURE(loDepth, input.uv00)); | |||
lowResDepth[1] = (SAMPLE_DEPTH_TEXTURE(loDepth, input.uv10)); | |||
lowResDepth[2] = (SAMPLE_DEPTH_TEXTURE(loDepth, input.uv01)); | |||
lowResDepth[3] = (SAMPLE_DEPTH_TEXTURE(loDepth, input.uv11)); | |||
float4 depthDiff = abs(lowResDepth - highResDepth); | |||
float accumDiff = dot(depthDiff, .1);//3.2.1 changed 1 to .1 | |||
//UNITY_BRANCH | |||
if (accumDiff < _UpsampleDepthThreshold) // small error, not an edge -> use bilinear filter | |||
{ | |||
// should be bilinear sampler, dont know how to use two different samplers for one texture in Unity | |||
//return float4(1, 0, 0, 1); | |||
return tex2D(loColor, input.uv); | |||
} | |||
#if VISUALIZE_EDGE | |||
return float4(1, .2, 0, 1); | |||
#endif | |||
// find nearest sample | |||
float minDepthDiff = depthDiff[0]; | |||
float2 nearestUv = input.uv00; | |||
if (depthDiff[1] < minDepthDiff) | |||
{ | |||
nearestUv = input.uv10; | |||
minDepthDiff = depthDiff[1]; | |||
} | |||
if (depthDiff[2] < minDepthDiff) | |||
{ | |||
nearestUv = input.uv01; | |||
minDepthDiff = depthDiff[2]; | |||
} | |||
if (depthDiff[3] < minDepthDiff) | |||
{ | |||
nearestUv = input.uv11; | |||
minDepthDiff = depthDiff[3]; | |||
} | |||
return tex2D(loColor, nearestUv); | |||
} | |||
//----------------------------------------------------------------------------------------- | |||
// DownsampleDepth | |||
//----------------------------------------------------------------------------------------- | |||
float4 DownsampleDepth(v2fDownsample input, sampler2D depthTexture) | |||
{ | |||
float final; | |||
// Normal | |||
final = tex2D(depthTexture, input.uv).x; | |||
#if DOWNSAMPLE_DEPTH_MODE_MIN // min depth | |||
float depth = tex2D(depthTexture, input.uv00) ; | |||
depth = min(depth, tex2D(depthTexture, input.uv01) ); | |||
depth = min(depth, tex2D(depthTexture, input.uv10) ); | |||
depth = min(depth, tex2D(depthTexture, input.uv11) ); | |||
final = (depth); | |||
#elif DOWNSAMPLE_DEPTH_MODE_MAX // max depth | |||
float depth = tex2D(depthTexture, input.uv00) ; | |||
depth = max(depth, tex2D(depthTexture, input.uv01) ); | |||
depth = max(depth, tex2D(depthTexture, input.uv10) ); | |||
depth = max(depth, tex2D(depthTexture, input.uv11) ); | |||
final = (depth); | |||
#else // DOWNSAMPLE_DEPTH_MODE_CHESSBOARD | |||
float4 depth; | |||
depth.x = tex2D(depthTexture, input.uv00) ; | |||
depth.y = tex2D(depthTexture, input.uv01) ; | |||
depth.z = tex2D(depthTexture, input.uv10) ; | |||
depth.w = tex2D(depthTexture, input.uv11) ; | |||
float minDepth = min(min(depth.x, depth.y), min(depth.z, depth.w)); | |||
float maxDepth = max(max(depth.x, depth.y), max(depth.z, depth.w)); | |||
// chessboard pattern | |||
int2 position = input.vertex.xy % 2; | |||
int index = position.x + position.y; | |||
final = (index == 1 ? minDepth : maxDepth); | |||
#endif | |||
return final; | |||
} | |||
ENDCG | |||
// pass 0 - downsample depth | |||
Pass | |||
{ | |||
// Name "downsample depth" | |||
CGPROGRAM | |||
#pragma vertex vertDepth | |||
#pragma fragment frag | |||
#pragma exclude_renderers d3d9 | |||
#pragma target 3.0 | |||
#pragma multi_compile DOWNSAMPLE_DEPTH_MODE_MIN DOWNSAMPLE_DEPTH_MODE_MAX DOWNSAMPLE_DEPTH_MODE_CHESSBOARD | |||
#pragma multi_compile _ FOG_VOLUME_STEREO_ON | |||
v2fDownsample vertDepth(appdata v) | |||
{ | |||
return vertDownsampleDepth(v, _TexelSize); | |||
} | |||
float4 frag(v2fDownsample input) : SV_Target | |||
{ | |||
#ifdef FOG_VOLUME_STEREO_ON | |||
if (RightSide == 1) | |||
return DownsampleDepth(input, _HiResDepthBufferR); | |||
else | |||
return DownsampleDepth(input, _HiResDepthBuffer); | |||
#else | |||
return DownsampleDepth(input, _HiResDepthBuffer); | |||
#endif | |||
} | |||
ENDCG | |||
} | |||
// pass 1 - bilateral upsample | |||
Pass | |||
{ | |||
// Name "bilateral upsample" | |||
Blend One Zero | |||
CGPROGRAM | |||
#pragma vertex vertUpsampleToFull | |||
#pragma fragment frag | |||
#pragma exclude_renderers d3d9 | |||
#pragma target 3.0 | |||
#pragma shader_feature VISUALIZE_EDGE | |||
#pragma multi_compile _ FOG_VOLUME_STEREO_ON | |||
v2fUpsample vertUpsampleToFull(appdata v) | |||
{ | |||
return vertUpsample(v, _TexelSize); | |||
} | |||
float4 frag(v2fUpsample input) : SV_Target | |||
{ | |||
float4 c = 0; | |||
//#ifdef FOG_VOLUME_STEREO_ON | |||
if (RightSide==0) | |||
c = BilateralUpsample(input, _HiResDepthBuffer, _LowResDepthBuffer, _LowResColor); | |||
//c = float4(1, 0, 0, 1); | |||
else | |||
c = BilateralUpsample(input, _HiResDepthBufferR, _LowResDepthBufferR, _LowResColorR); | |||
//c = float4(0, 1, 0, 1); | |||
//#else | |||
//c = BilateralUpsample(input, _HiResDepthBuffer, _LowResDepthBuffer, _LowResColor); | |||
//#endif | |||
return c; | |||
} | |||
ENDCG | |||
} | |||
} | |||
} |
@ -0,0 +1,9 @@ | |||
fileFormatVersion: 2 | |||
guid: 89e45b05aa4202847b04608f973d6e9a | |||
timeCreated: 1484275881 | |||
licenseType: Store | |||
ShaderImporter: | |||
defaultTextures: [] | |||
userData: | |||
assetBundleName: | |||
assetBundleVariant: |
@ -0,0 +1,8 @@ | |||
fileFormatVersion: 2 | |||
guid: cb968920823ca314ba562551821a3d04 | |||
folderAsset: yes | |||
DefaultImporter: | |||
externalObjects: {} | |||
userData: | |||
assetBundleName: | |||
assetBundleVariant: |
@ -0,0 +1,8 @@ | |||
fileFormatVersion: 2 | |||
guid: e53a40c4fcc1096428a83f40d98f52a9 | |||
timeCreated: 1493025228 | |||
licenseType: Store | |||
DefaultImporter: | |||
userData: | |||
assetBundleName: | |||
assetBundleVariant: |
@ -0,0 +1,8 @@ | |||
fileFormatVersion: 2 | |||
guid: b00d15afb49e4d54c9c80368e084c9be | |||
folderAsset: yes | |||
DefaultImporter: | |||
externalObjects: {} | |||
userData: | |||
assetBundleName: | |||
assetBundleVariant: |
@ -0,0 +1,8 @@ | |||
fileFormatVersion: 2 | |||
guid: a5e2898898dc03148a752362ef229cbe | |||
timeCreated: 1499387402 | |||
licenseType: Store | |||
DefaultImporter: | |||
userData: | |||
assetBundleName: | |||
assetBundleVariant: |
@ -0,0 +1,3 @@ | |||
version https://git-lfs.github.com/spec/v1 | |||
oid sha256:286a15c15b6beb74a9cea400ec098a26716f4d6ab20b626d50d782f074e4ef04 | |||
size 22182772 |
@ -0,0 +1,8 @@ | |||
fileFormatVersion: 2 | |||
guid: 313c0dbee1846414088fa8c408c45f4d | |||
NativeFormatImporter: | |||
externalObjects: {} | |||
mainObjectFileID: 25800000 | |||
userData: | |||
assetBundleName: | |||
assetBundleVariant: |
@ -0,0 +1,3 @@ | |||
version https://git-lfs.github.com/spec/v1 | |||
oid sha256:5f0c9a81360f1b81931bb76b310cee32ca835aa21b2d7e6ced826cf47abc4bff | |||
size 139184 |