-
Notifications
You must be signed in to change notification settings - Fork 869
Expand file tree
/
Copy pathExposureNode.cs
More file actions
76 lines (67 loc) · 2.65 KB
/
ExposureNode.cs
File metadata and controls
76 lines (67 loc) · 2.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
using System.Collections.Generic;
using System;
using UnityEngine;
using UnityEditor.Graphing;
using UnityEditor.ShaderGraph;
using UnityEditor.ShaderGraph.Drawing.Controls;
using UnityEditor.ShaderGraph.Internal;
using UnityEngine.Rendering.HighDefinition;
namespace UnityEditor.Rendering.HighDefinition
{
[SRPFilter(typeof(HDRenderPipeline))]
[Title("Input", "High Definition Render Pipeline", "Exposure")]
[FormerName("UnityEditor.Experimental.Rendering.HDPipeline.ExposureNode")]
class ExposureNode : AbstractMaterialNode, IGeneratesBodyCode
{
public enum ExposureType
{
CurrentMultiplier,
InverseCurrentMultiplier,
PreviousMultiplier,
InversePreviousMultiplier,
}
static Dictionary<ExposureType, string> exposureFunctions = new Dictionary<ExposureType, string>()
{
{ExposureType.CurrentMultiplier, "GetCurrentExposureMultiplier()"},
{ExposureType.PreviousMultiplier, "GetPreviousExposureMultiplier()"},
{ExposureType.InverseCurrentMultiplier, "GetInverseCurrentExposureMultiplier()"},
{ExposureType.InversePreviousMultiplier, "GetInversePreviousExposureMultiplier()"},
};
public ExposureNode()
{
name = "Exposure";
UpdateNodeAfterDeserialization();
}
[SerializeField]
ExposureType m_ExposureType;
[EnumControl("Type")]
public ExposureType exposureType
{
get => m_ExposureType;
set
{
m_ExposureType = value;
Dirty(ModificationScope.Node);
}
}
const int kExposureOutputSlotId = 0;
const string kExposureOutputSlotName = "Output";
public override bool hasPreview { get { return false; } }
public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new ColorRGBMaterialSlot(kExposureOutputSlotId, kExposureOutputSlotName, kExposureOutputSlotName, SlotType.Output, Color.black, ColorMode.Default));
RemoveSlotsNameNotMatching(new[]
{
kExposureOutputSlotId,
});
}
public void GenerateNodeCode(ShaderStringBuilder sb, GenerationMode generationMode)
{
sb.AppendLine("#ifdef SHADERGRAPH_PREVIEW");
sb.AppendLine($"$precision {GetVariableNameForSlot(kExposureOutputSlotId)} = 1.0;");
sb.AppendLine("#else");
sb.AppendLine($"$precision {GetVariableNameForSlot(kExposureOutputSlotId)} = {exposureFunctions[exposureType]};");
sb.AppendLine("#endif");
}
}
}