浏览代码

Add LOD input and inline reflection vector

/main
Matt Dean 7 年前
当前提交
736a2328
共有 1 个文件被更改,包括 7 次插入3 次删除
  1. 10
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Texture/CubemapNode.cs

10
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Texture/CubemapNode.cs


public const int CubemapInputId = 1;
public const int ViewDirInputId = 2;
public const int NormalInputId = 3;
public const int LODInputId = 4;
const string kLODInputName = "LOD";
public override bool hasPreview { get { return true; } }

AddSlot(new CubemapInputMaterialSlot(CubemapInputId, kCubemapInputName, kCubemapInputName));
AddSlot(new ViewDirectionMaterialSlot(ViewDirInputId, kViewDirInputName, kViewDirInputName, CoordinateSpace.Object));
AddSlot(new NormalMaterialSlot(NormalInputId, kNormalInputName, kNormalInputName, CoordinateSpace.Object));
RemoveSlotsNameNotMatching(new[] { OutputSlotId, CubemapInputId, ViewDirInputId, NormalInputId });
AddSlot(new Vector1MaterialSlot(LODInputId, kLODInputName, kLODInputName, SlotType.Input, 0));
RemoveSlotsNameNotMatching(new[] { OutputSlotId, CubemapInputId, ViewDirInputId, NormalInputId, LODInputId });
}
public override PreviewMode previewMode

// Node generations
public virtual void GenerateNodeCode(ShaderGenerator visitor, GenerationMode generationMode)
{
string result = string.Format("{0}4 {1} = texCUBE ({2}, reflect(-{3}, {4}));"
string result = string.Format("{0}4 {1} = texCUBElod ({2}, {0}4(reflect(-{3}, {4}), {5}));"
, GetSlotValue(NormalInputId, generationMode));
, GetSlotValue(NormalInputId, generationMode)
, GetSlotValue(LODInputId, generationMode));
visitor.AddShaderChunk(result, true);
}

正在加载...
取消
保存