浏览代码
Add HDR Color
Add HDR Color
- Add HDR Color node - Add new constructor to ColorShaderProperty - Add hdr flag to ColorControl - Add HDR Color property to GraphInspectorView/main
Matt Dean
7 年前
当前提交
8ea43935
共有 7 个文件被更改,包括 125 次插入 和 6 次删除
-
6MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/ColorShaderProperty.cs
-
14MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Controls/ColorControl.cs
-
2MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Controls/DefaultControl.cs
-
1MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/GraphInspectorView.cs
-
6MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/ShaderPropertyView.cs
-
94MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Basic/HDRColorNode.cs
-
8MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Basic/HDRColorNode.cs.meta
|
|||
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("", true)] |
|||
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