Skip to content

Commit 293b0d4

Browse files
PaulDemeulenaereGitHub Enterprise
authored andcommitted
Fix Construct Matrix on GPU (#102)
* Fix VFXExpressionVector3sToMatrix & VFXExpressionVector4sToMatrix evaluation on GPU * *Update changelog.md
1 parent 96ffc00 commit 293b0d4

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

com.unity.visualeffectgraph/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
2525
- Normals with non uniform scales are correctly computed [Case 1246989](https://issuetracker.unity3d.com/product/unity/issues/guid/1246989/)
2626
- Fix exposed Texture2DArray and Cubemap types from shader graph not being taken into account in Output Mesh [Case 1265221](https://issuetracker.unity3d.com/product/unity/issues/guid/1265221/)
2727
- Allow world position usage in shaderGraph plugged into an alpha/opacity output [Case 1259511](https://issuetracker.unity3d.com/product/unity/issues/guid/1259511/)
28+
- GPU Evaluation of Construct Matrix
2829

2930
## [10.0.0] - 2019-06-10
3031
### Added

com.unity.visualeffectgraph/Editor/Expressions/VFXExpressionTransform.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,7 @@ sealed protected override VFXExpression Evaluate(VFXExpression[] constParents)
557557

558558
public override string GetCodeString(string[] parents)
559559
{
560-
return string.Format("float4x4(float4({0}, 0.0), float4({1}, 0.0), float4({2}, 0.0), float4({3}, 1.0));", parents[0], parents[1], parents[2], parents[3]);
560+
return string.Format("VFXCreateMatrixFromColumns(float4({0}, 0.0), float4({1}, 0.0), float4({2}, 0.0), float4({3}, 1.0));", parents[0], parents[1], parents[2], parents[3]);
561561
}
562562
}
563563

@@ -603,7 +603,7 @@ sealed protected override VFXExpression Evaluate(VFXExpression[] constParents)
603603

604604
public override string GetCodeString(string[] parents)
605605
{
606-
return string.Format("float4x4({0}, {1}, {2}, {3});", parents[0], parents[1], parents[2], parents[3]);
606+
return string.Format("VFXCreateMatrixFromColumns({0}, {1}, {2}, {3});", parents[0], parents[1], parents[2], parents[3]);
607607
}
608608
}
609609

com.unity.visualeffectgraph/Shaders/VFXCommon.hlsl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,13 @@ float SampleCurve(float4 curveData, float u)
471471
///////////
472472
// Utils //
473473
///////////
474+
float4x4 VFXCreateMatrixFromColumns(float4 i, float4 j, float4 k, float4 o)
475+
{
476+
return float4x4(i.x, j.x, k.x, o.x,
477+
i.y, j.y, k.y, o.y,
478+
i.z, j.z, k.z, o.z,
479+
i.w, j.w, k.w, o.w);
480+
}
474481

475482
// Invert 3D transformation matrix (not perspective). Adapted from graphics gems 2.
476483
// Inverts upper left by calculating its determinant and multiplying it to the symmetric

0 commit comments

Comments
 (0)