浏览代码

Fix bugs in blend node after port.

/main
Tim Cooper 7 年前
当前提交
08ce57cd
共有 3 个文件被更改,包括 32 次插入36 次删除
  1. 34
      MaterialGraphProject/Assets/Rinaldo/BlendModeNode.cs
  2. 18
      MaterialGraphProject/Assets/Rinaldo/BlendModesEnum.cs
  3. 16
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/HLSLNode.cs

34
MaterialGraphProject/Assets/Rinaldo/BlendModeNode.cs


return
@"
{
result = botom / (top + 0.000000000001);
result = bottom / (top + 0.000000000001);
}";
}

return
@"
{
{precision}{dimension2} result1 = 1.0 - 2.0 * (1.0 - top) * (1.0 - bottom);
{precision}{dimension2} result2 = 2.0 * top * bottom;
{precision}{dimension2} zeroOrOne = step(top, 0.5);
{precision}{slot2dimension} result1 = 1.0 - 2.0 * (1.0 - top) * (1.0 - bottom);
{precision}{slot2dimension} result2 = 2.0 * top * bottom;
{precision}{slot2dimension} zeroOrOne = step(top, 0.5);
result = result2 * zeroOrOne + (1 - zeroOrOne) * result1;
}";
}

return
@"
{
result = step(1-top, bottom)
result = step(1-top, bottom);
static string Unity_BlendHardLighten(
static string Unity_BlendLighten(
[Slot(0, Binding.None)] DynamicDimensionVector top,
[Slot(1, Binding.None)] DynamicDimensionVector bottom,
[Slot(2, Binding.None)] out DynamicDimensionVector result)

return
@"
{
{precision}{dimension2} result1 = 1.0 - 2.0 * (1.0 - top) * (1.0 - bottom);
{precision}{dimension2} result2 = 2.0 * top * bottom;
{precision}{dimension2} zeroOrOne = step(bottom, 0.5);
{precision}{slot2dimension} result1 = 1.0 - 2.0 * (1.0 - top) * (1.0 - bottom);
{precision}{slot2dimension} result2 = 2.0 * top * bottom;
{precision}{slot2dimension} zeroOrOne = step(bottom, 0.5);
result = result2 * zeroOrOne + (1 - zeroOrOne) * result1;
}
";

return
@"
{
{precision}{dimension2} check = step (0.5, top);
{precision}{dimension2} result1 = check * max(2.0*(top - 0.5), bottom);
{precision}{slot2dimension} check = step (0.5, top);
{precision}{slot2dimension} result1 = check * max(2.0*(top - 0.5), bottom);
result = result1 + (1.0 - check) * min(2.0 * top, bottom);
}
";

return
@"
{
{precision}{dimension2} result1= 2.0 * bottom * top +bottom*top - 2.0 * bottom*bottom*top;
{precision}{dimension2} result2= 2.0* sqrt(bottom) * top - sqrt(bottom) + 2.0 * bottom - 2.0 * bottom*top;
{precision}{dimension2} zeroOrOne = step(0.5, top);
{precision}{slot2dimension} result1= 2.0 * bottom * top +bottom*top - 2.0 * bottom*bottom*top;
{precision}{slot2dimension} result2= 2.0* sqrt(bottom) * top - sqrt(bottom) + 2.0 * bottom - 2.0 * bottom*top;
{precision}{slot2dimension} zeroOrOne = step(0.5, top);
result = result2 * zeroOrOne + (1 - zeroOrOne) * result1;
}
";

return
@"
{
{precision}{dimension2} result1 = 1.0-(1.0-bottom)/(2.0*top);
{precision}{dimension2} result2 = bottom/(2.0*(1.0-top));
{precision}{dimension2} zeroOrOne = step(0.5, top);
{precision}{slot2dimension} result1 = 1.0-(1.0-bottom)/(2.0*top);
{precision}{slot2dimension} result2 = bottom/(2.0*(1.0-top));
{precision}{slot2dimension} zeroOrOne = step(0.5, top);
result = result2 * zeroOrOne + (1 - zeroOrOne) * result1;
}
";

18
MaterialGraphProject/Assets/Rinaldo/BlendModesEnum.cs


PinLight,
Screen,
SoftLight,
Substract,
Subtract,
/* Old Order
Multiply
Screen
Darken
Lighten
Difference
Negation
Exclusion
Overlay
HardLight
SoftLight
Dodge (ColorDodge)
Burn (ColorBurn)
*/
}
}

16
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/HLSLNode.cs


foreach (var param in info.GetParameters())
args.Add(GetDefault(param.ParameterType));
return info.Invoke(this, args.ToArray()) as string;
var result = info.Invoke(this, args.ToArray()) as string;
if (string.IsNullOrEmpty(result))
return string.Empty;
result = result.Replace("{precision}", precision.ToString());
foreach (var slot in GetSlots<MaterialSlot>())
{
var toReplace = string.Format("{{slot{0}dimension}}", slot.id);
var replacement = ConvertConcreteSlotValueTypeToString(slot.concreteValueType);
result = result.Replace(toReplace, replacement);
}
return result;
string function = GetFunctionHeader() + GetFunctionBody(GetFunctionToConvert()).Replace("{precision}", precision.ToString());
string function = GetFunctionHeader() + GetFunctionBody(GetFunctionToConvert());
visitor.AddShaderChunk(function, true);
}

正在加载...
取消
保存