From 2ca9dc961ea027275aa3decc6efe4803c365e154 Mon Sep 17 00:00:00 2001 From: Th3V1kt0r <98119869+Th3V1kt0r@users.noreply.github.com> Date: Mon, 22 Apr 2024 21:14:44 +0200 Subject: [PATCH] define for building 4x4 matrices added 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). --- .../Hlms/Common/GLSL/CrossPlatformSettings_piece_all.glsl | 2 ++ .../Hlms/Common/GLSLES/CrossPlatformSettings_piece_all.glsl | 2 ++ .../Hlms/Common/HLSL/CrossPlatformSettings_piece_all.hlsl | 2 ++ .../Hlms/Common/Metal/CrossPlatformSettings_piece_all.metal | 2 ++ .../Media/Hlms/Pbs/Any/Main/800.VertexShader_piece_vs.any | 5 +---- 5 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Samples/Media/Hlms/Common/GLSL/CrossPlatformSettings_piece_all.glsl b/Samples/Media/Hlms/Common/GLSL/CrossPlatformSettings_piece_all.glsl index a6702974136..6c9ec57208b 100644 --- a/Samples/Media/Hlms/Common/GLSL/CrossPlatformSettings_piece_all.glsl +++ b/Samples/Media/Hlms/Common/GLSL/CrossPlatformSettings_piece_all.glsl @@ -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. diff --git a/Samples/Media/Hlms/Common/GLSLES/CrossPlatformSettings_piece_all.glsl b/Samples/Media/Hlms/Common/GLSLES/CrossPlatformSettings_piece_all.glsl index 432eea890f8..01f75c3b5ad 100644 --- a/Samples/Media/Hlms/Common/GLSLES/CrossPlatformSettings_piece_all.glsl +++ b/Samples/Media/Hlms/Common/GLSLES/CrossPlatformSettings_piece_all.glsl @@ -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 diff --git a/Samples/Media/Hlms/Common/HLSL/CrossPlatformSettings_piece_all.hlsl b/Samples/Media/Hlms/Common/HLSL/CrossPlatformSettings_piece_all.hlsl index f6095767b36..473a1b5401e 100644 --- a/Samples/Media/Hlms/Common/HLSL/CrossPlatformSettings_piece_all.hlsl +++ b/Samples/Media/Hlms/Common/HLSL/CrossPlatformSettings_piece_all.hlsl @@ -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) diff --git a/Samples/Media/Hlms/Common/Metal/CrossPlatformSettings_piece_all.metal b/Samples/Media/Hlms/Common/Metal/CrossPlatformSettings_piece_all.metal index 3fe63c9c920..64b1387e728 100644 --- a/Samples/Media/Hlms/Common/Metal/CrossPlatformSettings_piece_all.metal +++ b/Samples/Media/Hlms/Common/Metal/CrossPlatformSettings_piece_all.metal @@ -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 diff --git a/Samples/Media/Hlms/Pbs/Any/Main/800.VertexShader_piece_vs.any b/Samples/Media/Hlms/Pbs/Any/Main/800.VertexShader_piece_vs.any index 1016983eba2..1e9e4fd3019 100644 --- a/Samples/Media/Hlms/Pbs/Any/Main/800.VertexShader_piece_vs.any +++ b/Samples/Media/Hlms/Pbs/Any/Main/800.VertexShader_piece_vs.any @@ -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