浏览代码

Fixes for PR

/main
Matt Dean 7 年前
当前提交
5c0e0f70
共有 8 个文件被更改,包括 56 次插入65 次删除
  1. 23
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/SamplerShaderProperty.cs
  2. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Scene/AmbientNode.cs
  3. 36
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Scene/DepthTextureNode.cs
  4. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Scene/FogNode.cs
  5. 34
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Scene/MotionVectorTextureNode.cs
  6. 20
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Scene/NormalsTextureNode.cs
  7. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Scene/ObjectNode.cs
  8. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Scene/ScreenNode.cs

23
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/SamplerShaderProperty.cs


namespace UnityEditor.ShaderGraph
{
public class TextureSampler2D { }
public class SamplerShaderProperty : AbstractShaderProperty<float>
public class Sampler2DShaderProperty : AbstractShaderProperty<object>
get { return PropertyType.Float; }
get { return PropertyType.SamplerState; }
get { return new Vector4(value, value, value, value); }
get { return new Vector4(); }
var result = new StringBuilder();
result.Append(referenceName);
result.Append("(\"");
result.Append(displayName);
result.Append("\", Float) = ");
result.Append(value);
return result.ToString();
return string.Empty;
}
public override string GetPropertyDeclarationString()

public override PreviewProperty GetPreviewMaterialProperty()
{
return new PreviewProperty()
{
m_Name = referenceName,
m_PropType = PropertyType.Float,
m_Float = value
};
return default(PreviewProperty);
}
}
}

2
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Scene/AmbientNode.cs


namespace UnityEditor.ShaderGraph
{
[Title("Input/Scene/Ambient")]
[Title("Input", "Scene", "Ambient")]
public class AmbientNode : AbstractMaterialNode
{
const string kOutputSlotName = "Color";

36
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Scene/DepthTextureNode.cs


namespace UnityEditor.ShaderGraph
{
public enum DepthTextureMode
public enum SceneDepthMode
[Title("Input/Scene/Depth Texture")]
public class DepthTextureNode : AbstractMaterialNode, IGenerateProperties, IGeneratesBodyCode, IMayRequireScreenPosition
[Title("Input", "Scene", "Scene Depth")]
public class SceneDepthNode : AbstractMaterialNode, IGenerateProperties, IGeneratesBodyCode, IMayRequireScreenPosition
{
const string kUVSlotName = "UV";
const string kOutputSlotName = "Out";

public DepthTextureNode()
public SceneDepthNode()
name = "Depth Texture";
name = "Scene Depth";
UpdateNodeAfterDeserialization();
}

}
[SerializeField]
private DepthTextureMode m_DepthTextureMode = DepthTextureMode.Default;
private SceneDepthMode m_SceneDepthMode = SceneDepthMode.Default;
public DepthTextureMode depthTextureMode
public SceneDepthMode sceneDepthMode
get { return m_DepthTextureMode; }
get { return m_SceneDepthMode; }
if (m_DepthTextureMode == value)
if (m_SceneDepthMode == value)
m_DepthTextureMode = value;
m_SceneDepthMode = value;
if (onModified != null)
{
onModified(this, ModificationScope.Graph);

{
properties.Add(new PreviewProperty()
{
m_Name = "_CameraDepthTexture",
m_PropType = PropertyType.Float,
m_Vector4 = new Vector4(1, 1, 1, 1),
m_Float = 1,
m_Color = new Vector4(1, 1, 1, 1),
name = "_CameraDepthTexture",
propType = PropertyType.Float,
vector4Value = new Vector4(1, 1, 1, 1),
floatValue = 1,
colorValue = new Vector4(1, 1, 1, 1),
properties.AddShaderProperty(new SamplerShaderProperty
properties.AddShaderProperty(new Sampler2DShaderProperty
{
overrideReferenceName = "_CameraDepthTexture",
generatePropertyBlock = false

string uvValue = GetSlotValue(UVSlotId, generationMode);
string outputValue = GetSlotValue(OutputSlotId, generationMode);
string methodName = "";
switch (depthTextureMode)
switch (sceneDepthMode)
case DepthTextureMode.Normalized:
case SceneDepthMode.Normalized:
methodName = "Linear01Depth";
break;
default:

2
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Scene/FogNode.cs


ExponentialSquared
};
[Title("Input/Scene/Fog")]
[Title("Input", "Scene", "Fog")]
public class FogNode : AbstractMaterialNode, IGeneratesBodyCode, IMayRequirePosition
{
const string kOutputSlotName = "Color";

34
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Scene/MotionVectorTextureNode.cs


namespace UnityEditor.ShaderGraph
{
public enum MotionVectorTextureMode
public enum SceneVelocityMode
[Title("Input/Scene/Motion Vector Texture")]
public class MotionVectorTextureNode : AbstractMaterialNode, IGenerateProperties, IGeneratesBodyCode, IMayRequireScreenPosition
[Title("Input", "Scene", "Scene Velocity")]
public class SceneVelocityNode : AbstractMaterialNode, IGenerateProperties, IGeneratesBodyCode, IMayRequireScreenPosition
{
const string kUVSlotName = "UV";
const string kOutputSlotName = "Out";

public MotionVectorTextureNode()
public SceneVelocityNode()
name = "Motion Vector Texture";
name = "Scene Velocity";
UpdateNodeAfterDeserialization();
}

}
[SerializeField]
private MotionVectorTextureMode m_MotionVectorTextureMode = MotionVectorTextureMode.Default;
private SceneVelocityMode m_SceneVelocityMode = SceneVelocityMode.Default;
public MotionVectorTextureMode motionVectorTextureMode
public SceneVelocityMode sceneVelocityMode
get { return m_MotionVectorTextureMode; }
get { return m_SceneVelocityMode; }
if (m_MotionVectorTextureMode == value)
if (m_SceneVelocityMode == value)
m_MotionVectorTextureMode = value;
m_SceneVelocityMode = value;
if (onModified != null)
{
onModified(this, ModificationScope.Graph);

{
properties.Add(new PreviewProperty()
{
m_Name = "_CameraMotionVectorTexture",
m_PropType = PropertyType.Float,
m_Vector4 = new Vector4(1, 1, 1, 1),
m_Float = 1,
m_Color = new Vector4(1, 1, 1, 1),
name = "_CameraMotionVectorTexture",
propType = PropertyType.Float,
vector4Value = new Vector4(1, 1, 1, 1),
floatValue = 1,
colorValue = new Vector4(1, 1, 1, 1),
properties.AddShaderProperty(new SamplerShaderProperty
properties.AddShaderProperty(new Sampler2DShaderProperty
{
overrideReferenceName = "_CameraMotionVectorTexture",
generatePropertyBlock = false

string outputValue = GetSlotValue(OutputSlotId, generationMode);
visitor.AddShaderChunk(string.Format("{0}3 _MotionVectorTexture = {0}3(tex2D(_CameraMotionVectorTexture, {1}).rg, 0);", precision, uvValue), true);
if (motionVectorTextureMode == MotionVectorTextureMode.Hue)
if (sceneVelocityMode == SceneVelocityMode.Hue)
{
visitor.AddShaderChunk(string.Format("{0} hue = (atan2(_MotionVectorTexture.x, _MotionVectorTexture.y) / 3.14159265359 + 1.0) * 0.5;", precision), true);
visitor.AddShaderChunk(string.Format("_MotionVectorTexture = saturate({0}3(abs(hue * 6.0 - 3.0) - 1.0, 2.0 - abs(hue * 6.0 - 2.0), 2.0 - abs(hue * 6.0 - 4.0)));", precision), true);

20
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Scene/NormalsTextureNode.cs


namespace UnityEditor.ShaderGraph
{
[Title("Input/Scene/Normals Texture")]
public class NormalsTextureNode : AbstractMaterialNode, IGeneratesBodyCode, IGeneratesFunction, IGenerateProperties, IMayRequireScreenPosition
[Title("Input", "Scene", "Scene Normals")]
public class SceneNormalsNode : AbstractMaterialNode, IGeneratesBodyCode, IGeneratesFunction, IGenerateProperties, IMayRequireScreenPosition
{
const string kUVSlotName = "UV";
const string kOutputSlotName = "Out";

public NormalsTextureNode()
public SceneNormalsNode()
name = "Normals Texture";
name = "Scene Normals";
UpdateNodeAfterDeserialization();
}

{
properties.Add(new PreviewProperty()
{
m_Name = "_CameraDepthNormalsTexture",
m_PropType = PropertyType.Float,
m_Vector4 = new Vector4(1, 1, 1, 1),
m_Float = 1,
m_Color = new Vector4(1, 1, 1, 1),
name = "_CameraDepthNormalsTexture",
propType = PropertyType.Float,
vector4Value = new Vector4(1, 1, 1, 1),
floatValue = 1,
colorValue = new Vector4(1, 1, 1, 1),
properties.AddShaderProperty(new SamplerShaderProperty
properties.AddShaderProperty(new Sampler2DShaderProperty
{
overrideReferenceName = "_CameraDepthNormalsTexture",
generatePropertyBlock = false

2
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Scene/ObjectNode.cs


namespace UnityEditor.ShaderGraph
{
[Title("Input/Scene/Object")]
[Title("Input", "Scene", "Object")]
public class ObjectNode : AbstractMaterialNode
{
const string kOutputSlotName = "Position";

2
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Scene/ScreenNode.cs


namespace UnityEditor.ShaderGraph
{
[Title("Input/Scene/Screen")]
[Title("Input", "Scene", "Screen")]
public class ScreenNode : AbstractMaterialNode
{
const string kOutputSlotName = "Width";

正在加载...
取消
保存