浏览代码

fix node adaption so casting works as expected

/main
Tim Cooper 8 年前
当前提交
0336445f
共有 2 个文件被更改,包括 11 次插入11 次删除
  1. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/AbstractMaterialNode.cs
  2. 20
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Util/ShaderGenerator.cs

2
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/AbstractMaterialNode.cs


if (slot == null)
return string.Empty;
return ShaderGenerator.AdaptNodeOutput(fromNode, slot.id, slot.concreteValueType);
return ShaderGenerator.AdaptNodeOutput(fromNode, slot.id, inputSlot.concreteValueType);
}
return inputSlot.GetDefaultValue(generationMode);

20
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Util/ShaderGenerator.cs


switch (convertFromType)
{
case ConcreteSlotValueType.Vector1:
return string.Format("({0}{1})", rawOutput, textureSampleUVHack ? ".xx" : string.Empty);
return string.Format("({0}{1})", rawOutput, ".xx");
case ConcreteSlotValueType.Vector3:
case ConcreteSlotValueType.Vector4:
return string.Format("({0}.xy)", rawOutput);

switch (convertFromType)
{
case ConcreteSlotValueType.Vector1:
return string.Format("({0}{1})", rawOutput, textureSampleUVHack ? ".xxx" : string.Empty);
return string.Format("({0}{1})", rawOutput, ".xxx");
case ConcreteSlotValueType.Vector4:
return string.Format("({0}.xyz)", rawOutput);
default:

switch (convertFromType)
{
case ConcreteSlotValueType.Vector1:
return string.Format("({0}{1})", rawOutput, textureSampleUVHack ? ".xxxx" : string.Empty);
return string.Format("({0}{1})", rawOutput, ".xxxx");
default:
return kErrorString;
}

if (requiresViewDir || requiresViewDirTangentSpace)
{
shaderBodyVisitor.AddShaderChunk(
"float3 "
+ ShaderGeneratorNames.WorldSpaceViewDirection
+ " = normalize(UnityWorldSpaceViewDir("
+ ShaderGeneratorNames.WorldSpacePosition
"float3 "
+ ShaderGeneratorNames.WorldSpaceViewDirection
+ " = normalize(UnityWorldSpaceViewDir("
+ ShaderGeneratorNames.WorldSpacePosition
+ "));", true);
}

(activeNode as IGeneratesFunction).GenerateNodeFunction(shaderFunctionVisitor, generationMode);
if (activeNode is IGeneratesBodyCode)
(activeNode as IGeneratesBodyCode).GenerateNodeCode(shaderBodyVisitor, generationMode);
template = template.Replace("${ShaderName}", shaderName);
template = template.Replace("${ShaderPropertiesHeader}", shaderPropertiesVisitor.GetShaderString(2));
template = template.Replace("${ShaderPropertyUsages}", shaderPropertyUsagesVisitor.GetShaderString(3));

正在加载...
取消
保存