From f3ca372d855a75a0dd63bd3223665e354d9f42e2 Mon Sep 17 00:00:00 2001 From: Martijn Courteaux Date: Mon, 4 Nov 2019 01:49:07 +0100 Subject: [PATCH] Add mtxFromCols3/4 as macros to allow for const global matrices. (#1934) --- src/bgfx_shader.sh | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/src/bgfx_shader.sh b/src/bgfx_shader.sh index 487d6aac1..070df9b5d 100644 --- a/src/bgfx_shader.sh +++ b/src/bgfx_shader.sh @@ -593,7 +593,6 @@ mat4 mtxFromRows(vec4 _0, vec4 _1, vec4 _2, vec4 _3) return mat4(_0, _1, _2, _3); #endif // BGFX_SHADER_LANGUAGE_GLSL } - mat4 mtxFromCols(vec4 _0, vec4 _1, vec4 _2, vec4 _3) { #if BGFX_SHADER_LANGUAGE_GLSL @@ -602,7 +601,14 @@ mat4 mtxFromCols(vec4 _0, vec4 _1, vec4 _2, vec4 _3) return transpose(mat4(_0, _1, _2, _3) ); #endif // BGFX_SHADER_LANGUAGE_GLSL } - +mat3 mtxFromRows(vec3 _0, vec3 _1, vec3 _2) +{ +#if BGFX_SHADER_LANGUAGE_GLSL + return transpose(mat3(_0, _1, _2) ); +#else + return mat3(_0, _1, _2); +#endif // BGFX_SHADER_LANGUAGE_GLSL +} mat3 mtxFromCols(vec3 _0, vec3 _1, vec3 _2) { #if BGFX_SHADER_LANGUAGE_GLSL @@ -612,6 +618,30 @@ mat3 mtxFromCols(vec3 _0, vec3 _1, vec3 _2) #endif // BGFX_SHADER_LANGUAGE_GLSL } +#if BGFX_SHADER_LANGUAGE_GLSL +#define mtxFromRows4(_0, _1, _2, _3) transpose(mat4(_0, _1, _2, _3)) +#else +#define mtxFromRows4(_0, _1, _2, _3) mat4(_0, _1, _2, _3) +#endif // BGFX_SHADER_LANGUAGE_GLSL + +#if BGFX_SHADER_LANGUAGE_GLSL +#define mtxFromRows3(_0, _1, _2) transpose(mat3(_0, _1, _2)) +#else +#define mtxFromRows3(_0, _1, _2) mat3(_0, _1, _2) +#endif // BGFX_SHADER_LANGUAGE_GLSL + +#if BGFX_SHADER_LANGUAGE_GLSL +#define mtxFromCols4(_0, _1, _2, _3) mat4(_0, _1, _2, _3) +#else +#define mtxFromCols4(_0, _1, _2, _3) transpose(mat4(_0, _1, _2, _3)) +#endif // BGFX_SHADER_LANGUAGE_GLSL + +#if BGFX_SHADER_LANGUAGE_GLSL +#define mtxFromCols3(_0, _1, _2) mat3(_0, _1, _2) +#else +#define mtxFromCols3(_0, _1, _2) transpose(mat3(_0, _1, _2)) +#endif // BGFX_SHADER_LANGUAGE_GLSL + uniform vec4 u_viewRect; uniform vec4 u_viewTexel; uniform mat4 u_view;