Fix invalid shader codegen when using ddx/ddy in material vertex shader

#2376
This commit is contained in:
Wojtek Figat
2024-03-29 18:07:10 +01:00
parent 08e88587e6
commit 3696501050

View File

@@ -420,16 +420,32 @@ void MaterialGenerator::ProcessGroupMaterial(Box* box, Node* node, Value& value)
} }
// DDX // DDX
case 30: case 30:
{
if (_treeType == MaterialTreeType::PixelShader)
{ {
const auto inValue = tryGetValue(node->GetBox(0), 0, Value::Zero); const auto inValue = tryGetValue(node->GetBox(0), 0, Value::Zero);
value = writeLocal(inValue.Type, String::Format(TEXT("ddx({0})"), inValue.Value), node); value = writeLocal(inValue.Type, String::Format(TEXT("ddx({0})"), inValue.Value), node);
}
else
{
// No derivatives support in VS/DS
value = Value::Zero;
}
break; break;
} }
// DDY // DDY
case 31: case 31:
{
if (_treeType == MaterialTreeType::PixelShader)
{ {
const auto inValue = tryGetValue(node->GetBox(0), 0, Value::Zero); const auto inValue = tryGetValue(node->GetBox(0), 0, Value::Zero);
value = writeLocal(inValue.Type, String::Format(TEXT("ddy({0})"), inValue.Value), node); value = writeLocal(inValue.Type, String::Format(TEXT("ddy({0})"), inValue.Value), node);
}
else
{
// No derivatives support in VS/DS
value = Value::Zero;
}
break; break;
} }
// Sign // Sign