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
|
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
namespace AmplifyShaderEditor
{
[System.Serializable]
[NodeAttributes( "Vertex Normal", "Vertex Data", "Vertex normal vector in object space, can be used in both local vertex offset and fragment outputs" )]
public sealed class NormalVertexDataNode : VertexDataNode
{
protected override void CommonInit( int uniqueId )
{
base.CommonInit( uniqueId );
m_currentVertexData = "normal";
ChangeOutputProperties( 0, "XYZ", WirePortDataType.FLOAT3 );
m_outputPorts[ 4 ].Visible = false;
m_drawPreviewAsSphere = true;
m_previewShaderGUID = "6b24b06c33f9fe84c8a2393f13ab5406";
}
public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalVar )
{
string vertexNormal = string.Empty;
if( dataCollector.MasterNodeCategory == AvailableShaderTypes.Template )
{
vertexNormal = dataCollector.TemplateDataCollectorInstance.GetVertexNormal( CurrentPrecisionType );
return GetOutputVectorItem( 0, outputId, vertexNormal );
}
if( dataCollector.PortCategory == MasterNodePortCategory.Fragment || dataCollector.PortCategory == MasterNodePortCategory.Debug )
{
dataCollector.AddToInput( UniqueId, SurfaceInputs.WORLD_NORMAL, CurrentPrecisionType );
if( dataCollector.DirtyNormal )
{
dataCollector.AddToInput( UniqueId, SurfaceInputs.INTERNALDATA, addSemiColon: false );
dataCollector.ForceNormal = true;
}
}
vertexNormal = GeneratorUtils.GenerateVertexNormal( ref dataCollector, UniqueId, CurrentPrecisionType );
return GetOutputVectorItem( 0, outputId, vertexNormal );
}
}
}
|