您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 

39 行
1.1 KiB

using System.Reflection;
using UnityEngine;
namespace UnityEditor.ShaderGraph
{
[Title("Artistic", "Normal", "Normal Reconstruct Z")]
public class NormalReconstructZNode : CodeFunctionNode
{
public NormalReconstructZNode()
{
name = "Normal Reconstruct Z";
}
public override string documentationURL
{
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/Normal-Reconstruct-Z-Node"; }
}
protected override MethodInfo GetFunctionToConvert()
{
return GetType().GetMethod("NormalReconstructZ", BindingFlags.Static | BindingFlags.NonPublic);
}
static string NormalReconstructZ(
[Slot(0, Binding.None)] Vector2 In,
[Slot(2, Binding.None, ShaderStageCapability.Fragment)] out Vector3 Out)
{
Out = Vector3.zero;
return
@"
{
{precision} reconstructZ = sqrt(1 - ( In.x * In.x + In.y * In.y));
{precision}3 normalVector = {precision}3(In.x, In.y, reconstructZ);
Out = normalize(normalVector);
}";
}
}
}