Fix invalid shader codegen when using ddx/ddy in material vertex shader
#2376
This commit is contained in:
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user