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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using System;
using UnityEngine;
namespace AmplifyShaderEditor
{
[Serializable]
public class SurfaceShaderINParentNode : ParentNode
{
[SerializeField]
protected SurfaceInputs m_currentInput;
[SerializeField]
protected string m_currentInputValueStr;
[SerializeField]
protected string m_currentInputDecStr;
protected override void CommonInit( int uniqueId )
{
base.CommonInit( uniqueId );
m_currentInput = SurfaceInputs.UV_COORDS;
m_textLabelWidth = 65;
m_customPrecision = true;
}
public override void DrawProperties()
{
base.DrawProperties();
DrawPrecisionProperty();
}
//This needs to be called on the end of the CommonInit on all children
protected void InitialSetup()
{
m_currentInputValueStr = Constants.InputVarStr + "." + UIUtils.GetInputValueFromType( m_currentInput );
string outputName = "Out";
switch ( m_currentInput )
{
case SurfaceInputs.DEPTH:
{
AddOutputPort( WirePortDataType.FLOAT, outputName );
}
break;
case SurfaceInputs.UV_COORDS:
{
outputName = "UV";
AddOutputVectorPorts( WirePortDataType.FLOAT2, outputName );
}
break;
case SurfaceInputs.UV2_COORDS:
{
outputName = "UV";
AddOutputVectorPorts( WirePortDataType.FLOAT2, outputName );
}
break;
case SurfaceInputs.VIEW_DIR:
{
outputName = "XYZ";
AddOutputVectorPorts( WirePortDataType.FLOAT3, outputName );
}
break;
case SurfaceInputs.COLOR:
{
outputName = "RGBA";
AddOutputVectorPorts( WirePortDataType.FLOAT4, outputName );
}
break;
case SurfaceInputs.SCREEN_POS:
{
outputName = "XYZW";
AddOutputVectorPorts( WirePortDataType.FLOAT4, outputName );
}
break;
case SurfaceInputs.WORLD_POS:
{
outputName = "XYZ";
AddOutputVectorPorts( WirePortDataType.FLOAT3, outputName );
}
break;
case SurfaceInputs.WORLD_REFL:
{
outputName = "XYZ";
AddOutputVectorPorts( WirePortDataType.FLOAT3, outputName );
}
break;
case SurfaceInputs.WORLD_NORMAL:
{
outputName = "XYZ";
AddOutputVectorPorts( WirePortDataType.FLOAT3, outputName );
}
break;
}
}
public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalVar )
{
dataCollector.AddToInput( UniqueId, m_currentInput, CurrentPrecisionType );
switch ( m_currentInput )
{
case SurfaceInputs.VIEW_DIR:
case SurfaceInputs.WORLD_REFL:
case SurfaceInputs.WORLD_NORMAL:
{
dataCollector.AddToInput( UniqueId, SurfaceInputs.INTERNALDATA, addSemiColon: false );
}
break;
case SurfaceInputs.WORLD_POS:
case SurfaceInputs.DEPTH:
case SurfaceInputs.UV_COORDS:
case SurfaceInputs.UV2_COORDS:
case SurfaceInputs.COLOR:
case SurfaceInputs.SCREEN_POS: break;
};
return GetOutputVectorItem( 0, outputId, m_currentInputValueStr );
}
}
}
|