浏览代码
Merge pull request #192 from Unity-Technologies/node-bugfixes
Merge pull request #192 from Unity-Technologies/node-bugfixes
Property type refactor and Blackboard extension/main
GitHub
7 年前
当前提交
d2f86285
共有 33 个文件被更改,包括 367 次插入 和 417 次删除
-
20MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/ColorShaderProperty.cs
-
4MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/DynamicVectorMaterialSlot.cs
-
2MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/MaterialSlot.cs
-
10MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/PreviewProperty.cs
-
4MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/Vector1MaterialSlot.cs
-
85MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/Vector1ShaderProperty.cs
-
4MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Channel/SwizzleNode.cs
-
52MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Basic/ColorNode.cs
-
9MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Basic/IntegerNode.cs
-
15MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Basic/SliderNode.cs
-
40MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Basic/Vector1Node.cs
-
8MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/PBR/DielectricSpecularNode.cs
-
30MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/PropertyNode.cs
-
2MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/PropertyType.cs
-
2MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Utility/SubGraphNode.cs
-
2MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Util/GenerationResults.cs
-
4MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Util/GraphUtil.cs
-
164MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Blackboard/BlackboardFieldPropertyView.cs
-
3MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Blackboard/BlackboardProvider.cs
-
50MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Controls/ColorControl.cs
-
6MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/GraphInspectorView.cs
-
14MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/ShaderPropertyView.cs
-
2MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/MaterialGraphEditWindow.cs
-
25MaterialGraphProject/Assets/UnityShaderEditor/Editor/Resources/Styles/MaterialGraph.uss
-
2MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/UnitTests/MaterialNodeTests.cs
-
56MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/IntegerShaderProperty.cs
-
3MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/IntegerShaderProperty.cs.meta
-
61MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/SliderShaderProperty.cs
-
3MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/SliderShaderProperty.cs.meta
-
94MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Basic/HDRColorNode.cs
-
8MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Basic/HDRColorNode.cs.meta
-
0/MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/Vector1ShaderProperty.cs.meta
-
0/MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/Vector1ShaderProperty.cs
|
|||
using System; |
|||
using System.Text; |
|||
using UnityEditor.Graphing; |
|||
using UnityEngine; |
|||
|
|||
namespace UnityEditor.ShaderGraph |
|||
{ |
|||
[Serializable] |
|||
public class IntegerShaderProperty : AbstractShaderProperty<int> |
|||
{ |
|||
public IntegerShaderProperty() |
|||
{ |
|||
displayName = "Integer"; |
|||
} |
|||
|
|||
public override PropertyType propertyType |
|||
{ |
|||
get { return PropertyType.Float; } |
|||
} |
|||
|
|||
public override Vector4 defaultValue |
|||
{ |
|||
get { return new Vector4(value, value, value, value); } |
|||
} |
|||
|
|||
public override string GetPropertyBlockString() |
|||
{ |
|||
var result = new StringBuilder(); |
|||
result.Append(referenceName); |
|||
result.Append("(\""); |
|||
result.Append(displayName); |
|||
result.Append("\", Int) = "); |
|||
result.Append(value); |
|||
return result.ToString(); |
|||
} |
|||
|
|||
public override string GetPropertyDeclarationString(string delimiter = ";") |
|||
{ |
|||
return string.Format("float {0}{1}", referenceName, delimiter); |
|||
} |
|||
|
|||
public override PreviewProperty GetPreviewMaterialProperty() |
|||
{ |
|||
return new PreviewProperty(PropertyType.Float) |
|||
{ |
|||
name = referenceName, |
|||
floatValue = value |
|||
}; |
|||
} |
|||
|
|||
public override INode ToConcreteNode() |
|||
{ |
|||
return new IntegerNode { value = value }; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 5980fe29fe1b01c4fa3fb434dd9eb9e2 |
|||
timeCreated: 1505346922 |
|
|||
using System; |
|||
using System.Text; |
|||
using UnityEditor.Graphing; |
|||
using UnityEngine; |
|||
|
|||
namespace UnityEditor.ShaderGraph |
|||
{ |
|||
[Serializable] |
|||
public class SliderShaderProperty : AbstractShaderProperty<Vector3> |
|||
{ |
|||
public SliderShaderProperty() |
|||
{ |
|||
displayName = "Slider"; |
|||
value = new Vector3(0, 0, 1); |
|||
} |
|||
|
|||
public override PropertyType propertyType |
|||
{ |
|||
get { return PropertyType.Float; } |
|||
} |
|||
|
|||
public override Vector4 defaultValue |
|||
{ |
|||
get { return new Vector4(value.x, value.y, value.z, value.x); } |
|||
} |
|||
|
|||
public override string GetPropertyBlockString() |
|||
{ |
|||
var result = new StringBuilder(); |
|||
result.Append(referenceName); |
|||
result.Append("(\""); |
|||
result.Append(displayName); |
|||
result.Append("\", Range("); |
|||
result.Append(value.y); |
|||
result.Append(", "); |
|||
result.Append(value.z); |
|||
result.Append(")) = "); |
|||
result.Append(value.x); |
|||
return result.ToString(); |
|||
} |
|||
|
|||
public override string GetPropertyDeclarationString(string delimiter = ";") |
|||
{ |
|||
return string.Format("float {0}{1}", referenceName, delimiter); |
|||
} |
|||
|
|||
public override PreviewProperty GetPreviewMaterialProperty() |
|||
{ |
|||
return new PreviewProperty(PropertyType.Float) |
|||
{ |
|||
name = referenceName, |
|||
floatValue = value.x |
|||
}; |
|||
} |
|||
|
|||
public override INode ToConcreteNode() |
|||
{ |
|||
return new SliderNode { value = value }; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 116edc957722a90438d51cf6610694d3 |
|||
timeCreated: 1505346922 |
|
|||
using System.Collections.Generic; |
|||
using UnityEditor.ShaderGraph.Drawing.Controls; |
|||
using UnityEngine; |
|||
using UnityEditor.Graphing; |
|||
|
|||
namespace UnityEditor.ShaderGraph |
|||
{ |
|||
[Title("Input", "Basic", "HDR Color")] |
|||
public class HDRColorNode : AbstractMaterialNode, IGeneratesBodyCode, IPropertyFromNode |
|||
{ |
|||
[SerializeField] |
|||
private Color m_Color; |
|||
|
|||
public const int OutputSlotId = 0; |
|||
private const string kOutputSlotName = "Out"; |
|||
|
|||
public HDRColorNode() |
|||
{ |
|||
name = "HDR Color"; |
|||
UpdateNodeAfterDeserialization(); |
|||
} |
|||
|
|||
public sealed override void UpdateNodeAfterDeserialization() |
|||
{ |
|||
AddSlot(new ColorRGBAMaterialSlot(OutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, Vector4.zero)); |
|||
RemoveSlotsNameNotMatching(new[] { OutputSlotId }); |
|||
} |
|||
|
|||
[ColorControl("", ColorMode.HDR)] |
|||
public Color color |
|||
{ |
|||
get { return m_Color; } |
|||
set |
|||
{ |
|||
if (m_Color == value) |
|||
return; |
|||
|
|||
m_Color = value; |
|||
Dirty(ModificationScope.Node); |
|||
} |
|||
} |
|||
|
|||
|
|||
public override void CollectShaderProperties(PropertyCollector properties, GenerationMode generationMode) |
|||
{ |
|||
if (!generationMode.IsPreview()) |
|||
return; |
|||
|
|||
properties.AddShaderProperty(new ColorShaderProperty() |
|||
{ |
|||
overrideReferenceName = GetVariableNameForNode(), |
|||
generatePropertyBlock = false, |
|||
value = color, |
|||
HDR = true |
|||
}); |
|||
} |
|||
|
|||
public void GenerateNodeCode(ShaderGenerator visitor, GenerationMode generationMode) |
|||
{ |
|||
if (generationMode.IsPreview()) |
|||
return; |
|||
|
|||
visitor.AddShaderChunk(string.Format( |
|||
@"{0}4 {1} = IsGammaSpace() ? {0}4({2}, {3}, {4}, {5}) : {0}4(SRGBToLinear({0}3({2}, {3}, {4})), {5});" |
|||
, precision |
|||
, GetVariableNameForNode() |
|||
, color.r |
|||
, color.g |
|||
, color.b |
|||
, color.a), true); |
|||
} |
|||
|
|||
public override string GetVariableNameForSlot(int slotId) |
|||
{ |
|||
return GetVariableNameForNode(); |
|||
} |
|||
|
|||
public override void CollectPreviewMaterialProperties(List<PreviewProperty> properties) |
|||
{ |
|||
properties.Add(new PreviewProperty(PropertyType.Color) |
|||
{ |
|||
name = GetVariableNameForNode(), |
|||
colorValue = color |
|||
}); |
|||
} |
|||
|
|||
public IShaderProperty AsShaderProperty() |
|||
{ |
|||
return new ColorShaderProperty { value = color, HDR = true }; |
|||
} |
|||
|
|||
public int outputSlotId { get { return OutputSlotId; } } |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 948ed387e8c19c14c82965be937d7284 |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
撰写
预览
正在加载...
取消
保存
Reference in new issue