Skip to content

Commit

Permalink
Merge pull request #18 from steam-test1/AbsModifierFix
Browse files Browse the repository at this point in the history
Fixed shaders with the abs source modifier
  • Loading branch information
AndresTraks authored Jan 20, 2025
2 parents 4d08044 + a3897ab commit e709b35
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion Hlsl/HlslSimpleWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,8 @@ private string GetSourceConstantValue(D3D9Instruction instruction, int srcIndex,
.Take(destinationLength.Value)
.Select(s => constantRegister[s]).ToArray();

string size = constant.Length == 1 ? "" : constant.Length.ToString();

switch (instruction.GetSourceModifier(srcIndex))
{
case SourceModifier.None:
Expand All @@ -532,6 +534,18 @@ private string GetSourceConstantValue(D3D9Instruction instruction, int srcIndex,
constant[i] = -constant[i];
}
break;
case SourceModifier.Abs:
for (int i = 0; i < constant.Length; i++)
{
return $"abs(float{size}({string.Join(", ", constant.Select(c => c.ToString(_culture)))}))";
}
break;
case SourceModifier.AbsAndNegate:
for (int i = 0; i < constant.Length; i++)
{
return $"-abs(float{size}({string.Join(", ", constant.Select(c => c.ToString(_culture)))}))";
}
break;
default:
throw new NotImplementedException();
}
Expand All @@ -540,7 +554,6 @@ private string GetSourceConstantValue(D3D9Instruction instruction, int srcIndex,
{
return constant[0].ToString(_culture);
}
string size = constant.Length == 1 ? "" : constant.Length.ToString();
return $"float{size}({string.Join(", ", constant.Select(c => c.ToString(_culture)))})";
}
default:
Expand Down

0 comments on commit e709b35

Please sign in to comment.