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

@@ -421,15 +421,31 @@ void MaterialGenerator::ProcessGroupMaterial(Box* box, Node* node, Value& value)
// DDX // DDX
case 30: case 30:
{ {
const auto inValue = tryGetValue(node->GetBox(0), 0, Value::Zero); if (_treeType == MaterialTreeType::PixelShader)
value = writeLocal(inValue.Type, String::Format(TEXT("ddx({0})"), inValue.Value), node); {
const auto inValue = tryGetValue(node->GetBox(0), 0, Value::Zero);
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:
{ {
const auto inValue = tryGetValue(node->GetBox(0), 0, Value::Zero); if (_treeType == MaterialTreeType::PixelShader)
value = writeLocal(inValue.Type, String::Format(TEXT("ddy({0})"), inValue.Value), node); {
const auto inValue = tryGetValue(node->GetBox(0), 0, Value::Zero);
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