initial commit
This commit is contained in:
parent
6715289efe
commit
788c3389af
37645 changed files with 2526849 additions and 80 deletions
|
@ -0,0 +1,79 @@
|
|||
using UnityEditor.Graphing;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityEditor.ShaderGraph
|
||||
{
|
||||
[Title("Input", "Scene", "Camera")]
|
||||
class CameraNode : AbstractMaterialNode, IMayRequireTransform
|
||||
{
|
||||
const string kOutputSlotName = "Position";
|
||||
const string kOutputSlot1Name = "Direction";
|
||||
const string kOutputSlot2Name = "Orthographic";
|
||||
const string kOutputSlot3Name = "Near Plane";
|
||||
const string kOutputSlot4Name = "Far Plane";
|
||||
const string kOutputSlot5Name = "Z Buffer Sign";
|
||||
const string kOutputSlot6Name = "Width";
|
||||
const string kOutputSlot7Name = "Height";
|
||||
|
||||
public const int OutputSlotId = 0;
|
||||
public const int OutputSlot1Id = 1;
|
||||
public const int OutputSlot2Id = 2;
|
||||
public const int OutputSlot3Id = 3;
|
||||
public const int OutputSlot4Id = 4;
|
||||
public const int OutputSlot5Id = 5;
|
||||
public const int OutputSlot6Id = 6;
|
||||
public const int OutputSlot7Id = 7;
|
||||
|
||||
public CameraNode()
|
||||
{
|
||||
name = "Camera";
|
||||
synonyms = new string[] { "position", "direction", "orthographic", "near plane", "far plane", "width", "height" };
|
||||
UpdateNodeAfterDeserialization();
|
||||
}
|
||||
|
||||
public sealed override void UpdateNodeAfterDeserialization()
|
||||
{
|
||||
AddSlot(new Vector3MaterialSlot(OutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, Vector3.zero));
|
||||
AddSlot(new Vector3MaterialSlot(OutputSlot1Id, kOutputSlot1Name, kOutputSlot1Name, SlotType.Output, Vector3.zero));
|
||||
AddSlot(new Vector1MaterialSlot(OutputSlot2Id, kOutputSlot2Name, kOutputSlot2Name, SlotType.Output, 0));
|
||||
AddSlot(new Vector1MaterialSlot(OutputSlot3Id, kOutputSlot3Name, kOutputSlot3Name, SlotType.Output, 0));
|
||||
AddSlot(new Vector1MaterialSlot(OutputSlot4Id, kOutputSlot4Name, kOutputSlot4Name, SlotType.Output, 1));
|
||||
AddSlot(new Vector1MaterialSlot(OutputSlot5Id, kOutputSlot5Name, kOutputSlot5Name, SlotType.Output, 1));
|
||||
AddSlot(new Vector1MaterialSlot(OutputSlot6Id, kOutputSlot6Name, kOutputSlot6Name, SlotType.Output, 1));
|
||||
AddSlot(new Vector1MaterialSlot(OutputSlot7Id, kOutputSlot7Name, kOutputSlot7Name, SlotType.Output, 1));
|
||||
RemoveSlotsNameNotMatching(new[] { OutputSlotId, OutputSlot1Id, OutputSlot2Id, OutputSlot3Id, OutputSlot4Id, OutputSlot5Id, OutputSlot6Id, OutputSlot7Id });
|
||||
}
|
||||
|
||||
public override string GetVariableNameForSlot(int slotId)
|
||||
{
|
||||
switch (slotId)
|
||||
{
|
||||
case OutputSlot1Id:
|
||||
return "(-1 * mul((float3x3)UNITY_MATRIX_M, transpose(mul(UNITY_MATRIX_I_M, UNITY_MATRIX_I_V)) [2].xyz))";
|
||||
case OutputSlot2Id:
|
||||
return "unity_OrthoParams.w";
|
||||
case OutputSlot3Id:
|
||||
return "_ProjectionParams.y";
|
||||
case OutputSlot4Id:
|
||||
return "_ProjectionParams.z";
|
||||
case OutputSlot5Id:
|
||||
return "_ProjectionParams.x";
|
||||
case OutputSlot6Id:
|
||||
return "unity_OrthoParams.x";
|
||||
case OutputSlot7Id:
|
||||
return "unity_OrthoParams.y";
|
||||
default:
|
||||
return "_WorldSpaceCameraPos";
|
||||
}
|
||||
}
|
||||
|
||||
public NeededTransform[] RequiresTransform(ShaderStageCapability stageCapability = ShaderStageCapability.All)
|
||||
{
|
||||
return new[]
|
||||
{
|
||||
NeededTransform.ObjectToWorld,
|
||||
NeededTransform.WorldToObject
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: dd27728b9ce314209beef46e595204c5
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
|
@ -0,0 +1,35 @@
|
|||
using System.Reflection;
|
||||
|
||||
namespace UnityEditor.ShaderGraph
|
||||
{
|
||||
[Title("Input", "Scene", "Eye Index")]
|
||||
class EyeIndexNode : CodeFunctionNode
|
||||
{
|
||||
public override bool hasPreview { get { return false; } }
|
||||
|
||||
public EyeIndexNode()
|
||||
{
|
||||
name = "Eye Index";
|
||||
synonyms = new string[] { "stereo", "3d" };
|
||||
}
|
||||
|
||||
protected override MethodInfo GetFunctionToConvert()
|
||||
{
|
||||
return GetType().GetMethod("UnityGetEyeIndex", BindingFlags.Static | BindingFlags.NonPublic);
|
||||
}
|
||||
|
||||
static string UnityGetEyeIndex([Slot(0, Binding.None)] out Vector1 Out)
|
||||
{
|
||||
return
|
||||
@"
|
||||
{
|
||||
#if defined(UNITY_SINGLE_PASS_STEREO) || defined(UNITY_STEREO_INSTANCING_ENABLED) || defined(UNITY_STEREO_MULTIVIEW_ENABLED)
|
||||
Out = unity_StereoEyeIndex;
|
||||
#else
|
||||
Out = 0;
|
||||
#endif
|
||||
}
|
||||
";
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 8ef30ebbb2a5c6c4989bfa74ad4600bf
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,35 @@
|
|||
using System.Reflection;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityEditor.ShaderGraph
|
||||
{
|
||||
[Title("Input", "Scene", "Fog")]
|
||||
class FogNode : CodeFunctionNode
|
||||
{
|
||||
public FogNode()
|
||||
{
|
||||
name = "Fog";
|
||||
}
|
||||
|
||||
public override bool hasPreview { get { return false; } }
|
||||
|
||||
protected override MethodInfo GetFunctionToConvert()
|
||||
{
|
||||
return GetType().GetMethod("Unity_Fog", BindingFlags.Static | BindingFlags.NonPublic);
|
||||
}
|
||||
|
||||
static string Unity_Fog(
|
||||
[Slot(2, Binding.ObjectSpacePosition)] Vector3 Position,
|
||||
[Slot(0, Binding.None)] out Vector4 Color,
|
||||
[Slot(1, Binding.None)] out Vector1 Density)
|
||||
{
|
||||
Color = Vector4.zero;
|
||||
return
|
||||
@"
|
||||
{
|
||||
SHADERGRAPH_FOG(Position, Color, Density);
|
||||
}
|
||||
";
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f934acb3f675022448ac439d87d84a80
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
|
@ -0,0 +1,44 @@
|
|||
using UnityEditor.Graphing;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityEditor.ShaderGraph
|
||||
{
|
||||
[Title("Input", "Scene", "Object")]
|
||||
sealed class ObjectNode : AbstractMaterialNode, IMayRequireTransform
|
||||
{
|
||||
const string kOutputSlotName = "Position";
|
||||
const string kOutputSlot1Name = "Scale";
|
||||
|
||||
public const int OutputSlotId = 0;
|
||||
public const int OutputSlot1Id = 1;
|
||||
|
||||
public ObjectNode()
|
||||
{
|
||||
name = "Object";
|
||||
synonyms = new string[] { "position", "scale" };
|
||||
UpdateNodeAfterDeserialization();
|
||||
}
|
||||
|
||||
public override void UpdateNodeAfterDeserialization()
|
||||
{
|
||||
AddSlot(new Vector3MaterialSlot(OutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, Vector3.zero));
|
||||
AddSlot(new Vector3MaterialSlot(OutputSlot1Id, kOutputSlot1Name, kOutputSlot1Name, SlotType.Output, Vector3.zero));
|
||||
RemoveSlotsNameNotMatching(new[] { OutputSlotId, OutputSlot1Id });
|
||||
}
|
||||
|
||||
public override string GetVariableNameForSlot(int slotId)
|
||||
{
|
||||
switch (slotId)
|
||||
{
|
||||
case OutputSlot1Id:
|
||||
return @"$precision3(length($precision3(UNITY_MATRIX_M[0].x, UNITY_MATRIX_M[1].x, UNITY_MATRIX_M[2].x)),
|
||||
length($precision3(UNITY_MATRIX_M[0].y, UNITY_MATRIX_M[1].y, UNITY_MATRIX_M[2].y)),
|
||||
length($precision3(UNITY_MATRIX_M[0].z, UNITY_MATRIX_M[1].z, UNITY_MATRIX_M[2].z)))";
|
||||
default:
|
||||
return "SHADERGRAPH_OBJECT_POSITION";
|
||||
}
|
||||
}
|
||||
|
||||
public NeededTransform[] RequiresTransform(ShaderStageCapability stageCapability = ShaderStageCapability.All) => new[] { NeededTransform.ObjectToWorld };
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 081b8aed5e33ba1418a6a80f7693b9b4
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
|
@ -0,0 +1,48 @@
|
|||
using System.Reflection;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityEditor.ShaderGraph
|
||||
{
|
||||
[Title("Input", "Scene", "Scene Color")]
|
||||
sealed class SceneColorNode : CodeFunctionNode, IMayRequireCameraOpaqueTexture
|
||||
{
|
||||
const string kScreenPositionSlotName = "UV";
|
||||
const string kOutputSlotName = "Out";
|
||||
|
||||
public const int ScreenPositionSlotId = 0;
|
||||
public const int OutputSlotId = 1;
|
||||
|
||||
public SceneColorNode()
|
||||
{
|
||||
name = "Scene Color";
|
||||
synonyms = new string[] { "screen buffer" };
|
||||
UpdateNodeAfterDeserialization();
|
||||
}
|
||||
|
||||
public override bool hasPreview { get { return false; } }
|
||||
|
||||
|
||||
protected override MethodInfo GetFunctionToConvert()
|
||||
{
|
||||
return GetType().GetMethod("Unity_SceneColor", BindingFlags.Static | BindingFlags.NonPublic);
|
||||
}
|
||||
|
||||
static string Unity_SceneColor(
|
||||
[Slot(0, Binding.ScreenPosition)] Vector4 UV,
|
||||
[Slot(1, Binding.None, ShaderStageCapability.Fragment)] out Vector3 Out)
|
||||
{
|
||||
Out = Vector3.one;
|
||||
return
|
||||
@"
|
||||
{
|
||||
Out = SHADERGRAPH_SAMPLE_SCENE_COLOR(UV.xy);
|
||||
}
|
||||
";
|
||||
}
|
||||
|
||||
public bool RequiresCameraOpaqueTexture(ShaderStageCapability stageCapability)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c4ba33edde21e400685cf0fb5c8f2551
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,113 @@
|
|||
using System.Reflection;
|
||||
using UnityEngine;
|
||||
using UnityEditor.Graphing;
|
||||
using UnityEditor.ShaderGraph.Drawing.Controls;
|
||||
|
||||
namespace UnityEditor.ShaderGraph
|
||||
{
|
||||
enum DepthSamplingMode
|
||||
{
|
||||
Linear01,
|
||||
Raw,
|
||||
Eye
|
||||
};
|
||||
|
||||
[Title("Input", "Scene", "Scene Depth")]
|
||||
sealed class SceneDepthNode : CodeFunctionNode, IMayRequireDepthTexture
|
||||
{
|
||||
const string kScreenPositionSlotName = "UV";
|
||||
const string kOutputSlotName = "Out";
|
||||
|
||||
public const int ScreenPositionSlotId = 0;
|
||||
public const int OutputSlotId = 1;
|
||||
|
||||
[SerializeField]
|
||||
private DepthSamplingMode m_DepthSamplingMode = DepthSamplingMode.Linear01;
|
||||
|
||||
[EnumControl("Sampling Mode")]
|
||||
public DepthSamplingMode depthSamplingMode
|
||||
{
|
||||
get { return m_DepthSamplingMode; }
|
||||
set
|
||||
{
|
||||
if (m_DepthSamplingMode == value)
|
||||
return;
|
||||
|
||||
m_DepthSamplingMode = value;
|
||||
Dirty(ModificationScope.Graph);
|
||||
}
|
||||
}
|
||||
|
||||
public SceneDepthNode()
|
||||
{
|
||||
name = "Scene Depth";
|
||||
synonyms = new string[] { "zbuffer", "zdepth" };
|
||||
UpdateNodeAfterDeserialization();
|
||||
}
|
||||
|
||||
public override bool hasPreview { get { return false; } }
|
||||
|
||||
|
||||
protected override MethodInfo GetFunctionToConvert()
|
||||
{
|
||||
switch (m_DepthSamplingMode)
|
||||
{
|
||||
case DepthSamplingMode.Raw:
|
||||
return GetType().GetMethod("Unity_SceneDepth_Raw", BindingFlags.Static | BindingFlags.NonPublic);
|
||||
case DepthSamplingMode.Eye:
|
||||
return GetType().GetMethod("Unity_SceneDepth_Eye", BindingFlags.Static | BindingFlags.NonPublic);
|
||||
case DepthSamplingMode.Linear01:
|
||||
default:
|
||||
return GetType().GetMethod("Unity_SceneDepth_Linear01", BindingFlags.Static | BindingFlags.NonPublic);
|
||||
}
|
||||
}
|
||||
|
||||
static string Unity_SceneDepth_Linear01(
|
||||
[Slot(0, Binding.ScreenPosition)] Vector4 UV,
|
||||
[Slot(1, Binding.None, ShaderStageCapability.Fragment)] out Vector1 Out)
|
||||
{
|
||||
return
|
||||
@"
|
||||
{
|
||||
Out = Linear01Depth(SHADERGRAPH_SAMPLE_SCENE_DEPTH(UV.xy), _ZBufferParams);
|
||||
}
|
||||
";
|
||||
}
|
||||
|
||||
static string Unity_SceneDepth_Raw(
|
||||
[Slot(0, Binding.ScreenPosition)] Vector4 UV,
|
||||
[Slot(1, Binding.None, ShaderStageCapability.Fragment)] out Vector1 Out)
|
||||
{
|
||||
return
|
||||
@"
|
||||
{
|
||||
Out = SHADERGRAPH_SAMPLE_SCENE_DEPTH(UV.xy);
|
||||
}
|
||||
";
|
||||
}
|
||||
|
||||
static string Unity_SceneDepth_Eye(
|
||||
[Slot(0, Binding.ScreenPosition)] Vector4 UV,
|
||||
[Slot(1, Binding.None, ShaderStageCapability.Fragment)] out Vector1 Out)
|
||||
{
|
||||
return
|
||||
@"
|
||||
{
|
||||
if (unity_OrthoParams.w == 1.0)
|
||||
{
|
||||
Out = LinearEyeDepth(ComputeWorldSpacePosition(UV.xy, SHADERGRAPH_SAMPLE_SCENE_DEPTH(UV.xy), UNITY_MATRIX_I_VP), UNITY_MATRIX_V);
|
||||
}
|
||||
else
|
||||
{
|
||||
Out = LinearEyeDepth(SHADERGRAPH_SAMPLE_SCENE_DEPTH(UV.xy), _ZBufferParams);
|
||||
}
|
||||
}
|
||||
";
|
||||
}
|
||||
|
||||
public bool RequiresDepthTexture(ShaderStageCapability stageCapability)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f8e0a75d065844105a06ca48151adb7b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,39 @@
|
|||
using UnityEditor.Graphing;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityEditor.ShaderGraph
|
||||
{
|
||||
[Title("Input", "Scene", "Screen")]
|
||||
sealed class ScreenNode : AbstractMaterialNode
|
||||
{
|
||||
const string kOutputSlotName = "Width";
|
||||
const string kOutputSlot1Name = "Height";
|
||||
|
||||
public const int OutputSlotId = 0;
|
||||
public const int OutputSlot1Id = 1;
|
||||
|
||||
public ScreenNode()
|
||||
{
|
||||
name = "Screen";
|
||||
UpdateNodeAfterDeserialization();
|
||||
}
|
||||
|
||||
public override void UpdateNodeAfterDeserialization()
|
||||
{
|
||||
AddSlot(new Vector1MaterialSlot(OutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, 0));
|
||||
AddSlot(new Vector1MaterialSlot(OutputSlot1Id, kOutputSlot1Name, kOutputSlot1Name, SlotType.Output, 0));
|
||||
RemoveSlotsNameNotMatching(new[] { OutputSlotId, OutputSlot1Id });
|
||||
}
|
||||
|
||||
public override string GetVariableNameForSlot(int slotId)
|
||||
{
|
||||
switch (slotId)
|
||||
{
|
||||
case OutputSlot1Id:
|
||||
return "_ScreenParams.y";
|
||||
default:
|
||||
return "_ScreenParams.x";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 94b2801c66359164e93dc371fc6762e2
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
Loading…
Add table
Add a link
Reference in a new issue