| 853 | } |
| 854 | |
| 855 | ShaderGenerator::Value MaterialGenerator::VsToPs(Node* node, Box* input) |
| 856 | { |
| 857 | // If used in VS then pass the value from the input box |
| 858 | if (_treeType == MaterialTreeType::VertexShader) |
| 859 | { |
| 860 | return tryGetValue(input, Value::Zero).AsFloat4(); |
| 861 | } |
| 862 | |
| 863 | // Check if can use more interpolants |
| 864 | if (_vsToPsInterpolants.Count() == 16) |
| 865 | { |
| 866 | OnError(node, input, TEXT("Too many VS to PS interpolants used.")); |
| 867 | return Value::Zero; |
| 868 | } |
| 869 | |
| 870 | // Check if can use interpolants |
| 871 | const auto layer = GetRootLayer(); |
| 872 | if (!layer || layer->Domain == MaterialDomain::Decal || layer->Domain == MaterialDomain::PostProcess) |
| 873 | { |
| 874 | OnError(node, input, TEXT("VS to PS interpolants are not supported in Decal or Post Process materials.")); |
| 875 | return Value::Zero; |
| 876 | } |
| 877 | |
| 878 | // Indicate the interpolator slot usage |
| 879 | _vsToPsInterpolants.Add(input); |
| 880 | return Value(VariantType::Float4, String::Format(TEXT("input.CustomVSToPS[{0}]"), _vsToPsInterpolants.Count() - 1)); |
| 881 | } |
| 882 | |
| 883 | #endif |