当前提交
b78bf280
共有 4 个文件被更改,包括 117 次插入 和 0 次删除
-
8MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/PBR.meta
-
101MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/PBR/MetalReflectanceNode.cs
-
8MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/PBR/MetalReflectanceNode.cs.meta
|
|||
fileFormatVersion: 2 |
|||
guid: bc2d9fef9660c574dad26112f3061731 |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Reflection; |
|||
using UnityEngine; |
|||
using UnityEditor.Graphing; |
|||
using UnityEditor.ShaderGraph.Drawing.Controls; |
|||
|
|||
namespace UnityEditor.ShaderGraph |
|||
{ |
|||
public enum MetalMaterial |
|||
{ |
|||
Iron, |
|||
Silver, |
|||
Aluminium, |
|||
Gold, |
|||
Copper, |
|||
Chromium, |
|||
Nickel, |
|||
Titanium, |
|||
Cobalt, |
|||
Platinum |
|||
}; |
|||
|
|||
[Title("Input", "PBR", "Metal Reflectance")] |
|||
public class MetalReflectanceNode : AbstractMaterialNode, IGeneratesBodyCode |
|||
{ |
|||
public MetalReflectanceNode() |
|||
{ |
|||
name = "Metal Reflectance"; |
|||
UpdateNodeAfterDeserialization(); |
|||
} |
|||
|
|||
[SerializeField] |
|||
private MetalMaterial m_Material = MetalMaterial.Iron; |
|||
|
|||
[EnumControl("Material")] |
|||
public MetalMaterial material |
|||
{ |
|||
get { return m_Material; } |
|||
set |
|||
{ |
|||
if (m_Material == value) |
|||
return; |
|||
|
|||
m_Material = value; |
|||
Dirty(ModificationScope.Graph); |
|||
} |
|||
} |
|||
|
|||
private const int kOutputSlotId = 0; |
|||
private const string kOutputSlotName = "Out"; |
|||
|
|||
public override bool hasPreview { get { return true; } } |
|||
public override PreviewMode previewMode |
|||
{ |
|||
get { return PreviewMode.Preview2D; } |
|||
} |
|||
|
|||
|
|||
public sealed override void UpdateNodeAfterDeserialization() |
|||
{ |
|||
AddSlot(new Vector3MaterialSlot(kOutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, Vector3.zero)); |
|||
RemoveSlotsNameNotMatching(new[] { kOutputSlotId }); |
|||
} |
|||
|
|||
public void GenerateNodeCode(ShaderGenerator visitor, GenerationMode generationMode) |
|||
{ |
|||
switch (m_Material) |
|||
{ |
|||
case MetalMaterial.Silver: |
|||
visitor.AddShaderChunk(string.Format("{0}3 {1} = {0}3(0.972, 0.960, 0.915);", precision, GetVariableNameForSlot(kOutputSlotId)), true); |
|||
break; |
|||
case MetalMaterial.Aluminium: |
|||
visitor.AddShaderChunk(string.Format("{0}3 {1} = {0}3(0.913, 0.921, 0.925);", precision, GetVariableNameForSlot(kOutputSlotId)), true); |
|||
break; |
|||
case MetalMaterial.Gold: |
|||
visitor.AddShaderChunk(string.Format("{0}3 {1} = {0}3(1.000, 0.766, 0.336);", precision, GetVariableNameForSlot(kOutputSlotId)), true); |
|||
break; |
|||
case MetalMaterial.Copper: |
|||
visitor.AddShaderChunk(string.Format("{0}3 {1} = {0}3(0.955, 0.637, 0.538);", precision, GetVariableNameForSlot(kOutputSlotId)), true); |
|||
break; |
|||
case MetalMaterial.Chromium: |
|||
visitor.AddShaderChunk(string.Format("{0}3 {1} = {0}3(0.550, 0.556, 0.554);", precision, GetVariableNameForSlot(kOutputSlotId)), true); |
|||
break; |
|||
case MetalMaterial.Nickel: |
|||
visitor.AddShaderChunk(string.Format("{0}3 {1} = {0}3(0.660, 0.609, 0.526);", precision, GetVariableNameForSlot(kOutputSlotId)), true); |
|||
break; |
|||
case MetalMaterial.Titanium: |
|||
visitor.AddShaderChunk(string.Format("{0}3 {1} = {0}3(0.542, 0.497, 0.449);", precision, GetVariableNameForSlot(kOutputSlotId)), true); |
|||
break; |
|||
case MetalMaterial.Cobalt: |
|||
visitor.AddShaderChunk(string.Format("{0}3 {1} = {0}3(0.662, 0.655, 0.634);", precision, GetVariableNameForSlot(kOutputSlotId)), true); |
|||
break; |
|||
case MetalMaterial.Platinum: |
|||
visitor.AddShaderChunk(string.Format("{0}3 {1} = {0}3(0.672, 0.637, 0.585);", precision, GetVariableNameForSlot(kOutputSlotId)), true); |
|||
break; |
|||
default: |
|||
visitor.AddShaderChunk(string.Format("{0}3 {1} = {0}3(0.560, 0.570, 0.580);", precision, GetVariableNameForSlot(kOutputSlotId)), true); |
|||
break; |
|||
} |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: ba3db6b7663a26244a3efba1203bad6e |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
撰写
预览
正在加载...
取消
保存
Reference in new issue