Fix Pre-Skinned Normal and Position when accessed in Pixel Shader

#2549
This commit is contained in:
Wojtek Figat
2024-09-19 10:11:49 +02:00
parent fb4b0b2f75
commit be395304ec
3 changed files with 36 additions and 33 deletions

View File

@@ -832,4 +832,32 @@ void MaterialGenerator::WriteCustomGlobalCode(const Array<const MaterialGraph::N
}
}
ShaderGenerator::Value MaterialGenerator::VsToPs(Node* node, Box* input)
{
// If used in VS then pass the value from the input box
if (_treeType == MaterialTreeType::VertexShader)
{
return tryGetValue(input, Value::Zero).AsFloat4();
}
// Check if can use more interpolants
if (_vsToPsInterpolants.Count() == 16)
{
OnError(node, input, TEXT("Too many VS to PS interpolants used."));
return Value::Zero;
}
// Check if can use interpolants
const auto layer = GetRootLayer();
if (!layer || layer->Domain == MaterialDomain::Decal || layer->Domain == MaterialDomain::PostProcess)
{
OnError(node, input, TEXT("VS to PS interpolants are not supported in Decal or Post Process materials."));
return Value::Zero;
}
// Indicate the interpolator slot usage
_vsToPsInterpolants.Add(input);
return Value(VariantType::Float4, String::Format(TEXT("input.CustomVSToPS[{0}]"), _vsToPsInterpolants.Count() - 1));
}
#endif