| 604 | } |
| 605 | |
| 606 | void ShaderGenerator::ProcessGroupTools(Box* box, Node* node, Value& value) |
| 607 | { |
| 608 | switch (node->TypeID) |
| 609 | { |
| 610 | // Desaturation |
| 611 | case 2: |
| 612 | { |
| 613 | Value input = tryGetValue(node->GetBox(0), Value::Zero).AsFloat3(); |
| 614 | Value scale = tryGetValue(node->GetBox(1), Value::Zero).AsFloat(); |
| 615 | Value luminanceFactors = Value(node->Values[0]); |
| 616 | auto dot = writeFunction2(node, input, luminanceFactors, TEXT("dot"), ValueType::Float); |
| 617 | value = writeFunction3(node, input, dot, scale, TEXT("lerp"), ValueType::Float3); |
| 618 | break; |
| 619 | } |
| 620 | // Color Gradient |
| 621 | case 10: |
| 622 | { |
| 623 | Value time, prevTime, curTime; |
| 624 | Value prevColor, curColor; |
| 625 | const int32 count = (int32)node->Values[0]; |
| 626 | switch (count) |
| 627 | { |
| 628 | case 0: |
| 629 | // No sample |
| 630 | value = Value::Zero; |
| 631 | break; |
| 632 | case 1: |
| 633 | // Single sample |
| 634 | value = Value(node->Values[2]); |
| 635 | break; |
| 636 | case 2: |
| 637 | // Linear blend between 2 samples |
| 638 | time = tryGetValue(node->GetBox(0), Value::Zero).AsFloat(); |
| 639 | prevTime = Value(node->Values[1]); |
| 640 | prevColor = Value(node->Values[2]); |
| 641 | curTime = Value(node->Values[3]); |
| 642 | curColor = Value(node->Values[4]); |
| 643 | value = writeLocal(ValueType::Float4, String::Format( |
| 644 | TEXT("lerp({0}, {1}, saturate(({2} - {3}) / ({4} - {3})))"), |
| 645 | prevColor.Value, |
| 646 | curColor.Value, |
| 647 | time.Value, |
| 648 | prevTime.Value, |
| 649 | curTime.Value, |
| 650 | prevTime.Value), |
| 651 | node); |
| 652 | break; |
| 653 | default: |
| 654 | time = tryGetValue(node->GetBox(0), Value::Zero).AsFloat(); |
| 655 | prevTime = Value(node->Values[1]); |
| 656 | prevColor = Value(node->Values[2]); |
| 657 | value = writeLocal(ValueType::Float4, node); |
| 658 | for (int32 i = 1; i < count; i++) |
| 659 | { |
| 660 | curTime = Value(node->Values[i * 2 + 1]); |
| 661 | curColor = Value(node->Values[i * 2 + 2]); |
| 662 | |
| 663 | _writer.Write( |
nothing calls this directly
no test coverage detected