|
|
|
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
private static string AdaptNodeOutput(BaseMaterialNode node, GenerationMode mode, ConcreteSlotValueType previewChannelConcreteType) |
|
|
|
public static string AdaptNodeOutput(BaseMaterialNode node, GenerationMode mode, ConcreteSlotValueType convertToType) |
|
|
|
if (outputSlot == null) |
|
|
|
return AdaptNodeOutput(outputSlot, mode, convertToType); |
|
|
|
} |
|
|
|
|
|
|
|
private const string kErrorString = @"ERROR!"; |
|
|
|
public static string AdaptNodeOutput(Slot outputSlot, GenerationMode mode, ConcreteSlotValueType convertToType) |
|
|
|
{ |
|
|
|
if (outputSlot == null) |
|
|
|
var outputConcreteType = node.GetConcreteOutputSlotValueType(outputSlot); |
|
|
|
var node = outputSlot.node as BaseMaterialNode; |
|
|
|
var convertFromType = node.GetConcreteOutputSlotValueType(outputSlot); |
|
|
|
if (outputConcreteType == previewChannelConcreteType) |
|
|
|
if (convertFromType == convertToType) |
|
|
|
switch (previewChannelConcreteType) |
|
|
|
switch (convertToType) |
|
|
|
switch (outputConcreteType) |
|
|
|
switch (convertFromType) |
|
|
|
return string.Format("half2(({0}).x, ({0}).x)", rawOutput); |
|
|
|
return string.Format("({0})", rawOutput); |
|
|
|
return string.Format("half2(({0}).x, ({0}).y)", rawOutput); |
|
|
|
return string.Format("({0}.xy)", rawOutput); |
|
|
|
return string.Empty; |
|
|
|
return kErrorString; |
|
|
|
switch (outputConcreteType) |
|
|
|
switch (convertFromType) |
|
|
|
return string.Format("half3(({0}).x, ({0}).x, ({0}).x)", rawOutput); |
|
|
|
case ConcreteSlotValueType.Vector2: |
|
|
|
return string.Format("half3(({0}).x, ({0}).y, 0.0f)", rawOutput); |
|
|
|
return string.Format("({0})", rawOutput); |
|
|
|
return string.Format("half3(({0}).x, ({0}).y, ({0}).z)", rawOutput); |
|
|
|
return string.Format("({0}.xyz)", rawOutput); |
|
|
|
return string.Empty; |
|
|
|
return kErrorString; |
|
|
|
switch (outputConcreteType) |
|
|
|
switch (convertFromType) |
|
|
|
return string.Format("half4(({0}).x, ({0}).x, ({0}).x, ({0}).x)", rawOutput); |
|
|
|
case ConcreteSlotValueType.Vector2: |
|
|
|
return string.Format("half4(({0}).x, ({0}).y, 0.0f, 0.0f)", rawOutput); |
|
|
|
case ConcreteSlotValueType.Vector3: |
|
|
|
return string.Format("half4(({0}).x, ({0}).y, ({0}).z, 0.0f)", rawOutput); |
|
|
|
return string.Format("({0})", rawOutput); |
|
|
|
return string.Empty; |
|
|
|
return kErrorString; |
|
|
|
return string.Empty; |
|
|
|
return kErrorString; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|