Skip to content

Commit

Permalink
define for building 4x4 matrices added
Browse files Browse the repository at this point in the history
define for building 4x4 matrices added in the same way to buildFloat3x3.
(Someone should look up the metal version, because I don't know much about it).
  • Loading branch information
Th3V1kt0r authored and darksylinc committed Apr 22, 2024
1 parent a2243a3 commit 2ca9dc9
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@
#define toFloat3x3( x ) mat3( x )
#define buildFloat3x3( row0, row1, row2 ) mat3( row0, row1, row2 )

#define buildFloat4x4( row0, row1, row2, row3 ) mat4( row0, row1, row2, row3 )

// Let's explain this madness:
//
// We use the keyword "midf" because "half" is already taken on Metal.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ precision highp sampler2DArray;
#define toFloat3x3( x ) mat3( x )
#define buildFloat3x3( row0, row1, row2 ) mat3( row0, row1, row2 )

#define buildFloat4x4( row0, row1, row2, row3 ) mat4( row0, row1, row2, row3 )

#define mul( x, y ) ((x) * (y))
#define saturate(x) clamp( (x), 0.0, 1.0 )
#define lerp mix
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
#define toFloat3x3( x ) ((float3x3)(x))
#define buildFloat3x3( row0, row1, row2 ) transpose( float3x3( row0, row1, row2 ) )

#define buildFloat4x4( row0, row1, row2, row3 ) transpose( float4x4( row0, row1, row2, row3 ) )

// See CrossPlatformSettings_piece_all.glsl for an explanation
@property( precision_mode == full32 )
#define _h(x) (x)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ inline half3x3 toMatHalf3x3( float3x4 m )
#define toFloat3x3( x ) toMat3x3( x )
#define buildFloat3x3( row0, row1, row2 ) float3x3( float3( row0 ), float3( row1 ), float3( row2 ) )

#define buildFloat4x4( row0, row1, row2, row3 ) float4x4( float4( row0 ), float4( row1 ), float4( row2 ), float4( row3 ) )

// See CrossPlatformSettings_piece_all.glsl for an explanation
@property( precision_mode == full32 )
// In Metal 'half' is an actual datatype. It should be OK to override it
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,7 @@
@foreach( 4, n )
float4 row@n = readOnlyFetch( worldMatBuf, int( poseDataStart + @value(NumPoseWeightVectors)u + 4u + @nu ) );
@end
float4x4 worldView = float4x4( row0, row1, row2, row3 );
@property( syntax == hlsl )
worldView = transpose( worldView );
@end
float4x4 worldView = buildFloat4x4( row0, row1, row2, row3 );
@end
@end
@end // PoseTransform
Expand Down

0 comments on commit 2ca9dc9

Please sign in to comment.