|
|
|
|
|
|
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); |
|
|
|
} |
|
|
|