From fb071c4c812a01b8ac60d4498518fcf52ce9efa8 Mon Sep 17 00:00:00 2001 From: Frieder Erdmann Date: Tue, 10 Oct 2023 15:27:57 +0200 Subject: [PATCH] Implemented missing interface, various bug fixes --- libraries/stdlib/genglsl/mx_creatematrix.glsl | 12 +++++++-- .../stdlib/genglsl/stdlib_genglsl_impl.mtlx | 5 ++-- .../stdlib/genmdl/stdlib_genmdl_impl.mtlx | 5 ++-- .../stdlib/genmsl/stdlib_genmsl_impl.mtlx | 5 ++-- libraries/stdlib/genosl/mx_creatematrix.osl | 18 +++++++++---- .../stdlib/genosl/stdlib_genosl_impl.mtlx | 5 ++-- libraries/stdlib/stdlib_defs.mtlx | 12 +++++++-- .../MaterialXGenMdl/mdl/materialx/stdlib.mdl | 26 ++++++++++++++----- 8 files changed, 65 insertions(+), 23 deletions(-) diff --git a/libraries/stdlib/genglsl/mx_creatematrix.glsl b/libraries/stdlib/genglsl/mx_creatematrix.glsl index 7dc7317201..2ece43353b 100644 --- a/libraries/stdlib/genglsl/mx_creatematrix.glsl +++ b/libraries/stdlib/genglsl/mx_creatematrix.glsl @@ -1,11 +1,19 @@ -void mx_creatematrix_vector3(vec3 in1, vec3 in2, vec3 in3, out mat3 result) +void mx_creatematrix_vector3_matrix33(vec3 in1, vec3 in2, vec3 in3, out mat3 result) { result = mat3(in1.x, in1.y, in1.z, in2.x, in2.y, in2.z, in3.x, in3.y, in3.z); } -void mx_creatematrix_vector4(vec4 in1, vec4 in2, vec4 in3, vec4 in4, out mat4 result) +void mx_creatematrix_vector3_matrix44(vec3 in1, vec3 in2, vec3 in3, vec3 in4, out mat4 result) +{ + result = mat4(in1.x, in1.y, in1.z, 0.0, + in2.x, in2.y, in2.z, 0.0, + in3.x, in3.y, in3.z, 0.0, + in4.x, in4.y, in4.z, 1.0); +} + +void mx_creatematrix_vector4_matrix44(vec4 in1, vec4 in2, vec4 in3, vec4 in4, out mat4 result) { result = mat4(in1.x, in1.y, in1.z, in1.w, in2.x, in2.y, in2.z, in2.w, diff --git a/libraries/stdlib/genglsl/stdlib_genglsl_impl.mtlx b/libraries/stdlib/genglsl/stdlib_genglsl_impl.mtlx index 555dbd4c81..f4402d0afc 100644 --- a/libraries/stdlib/genglsl/stdlib_genglsl_impl.mtlx +++ b/libraries/stdlib/genglsl/stdlib_genglsl_impl.mtlx @@ -755,8 +755,9 @@ - - + + + diff --git a/libraries/stdlib/genmdl/stdlib_genmdl_impl.mtlx b/libraries/stdlib/genmdl/stdlib_genmdl_impl.mtlx index 11424f0cbf..e006316c71 100644 --- a/libraries/stdlib/genmdl/stdlib_genmdl_impl.mtlx +++ b/libraries/stdlib/genmdl/stdlib_genmdl_impl.mtlx @@ -760,8 +760,9 @@ - - + + + diff --git a/libraries/stdlib/genmsl/stdlib_genmsl_impl.mtlx b/libraries/stdlib/genmsl/stdlib_genmsl_impl.mtlx index c7aea7f638..55d91ac394 100644 --- a/libraries/stdlib/genmsl/stdlib_genmsl_impl.mtlx +++ b/libraries/stdlib/genmsl/stdlib_genmsl_impl.mtlx @@ -754,8 +754,9 @@ - - + + + diff --git a/libraries/stdlib/genosl/mx_creatematrix.osl b/libraries/stdlib/genosl/mx_creatematrix.osl index b15b18673c..be3ab34b34 100644 --- a/libraries/stdlib/genosl/mx_creatematrix.osl +++ b/libraries/stdlib/genosl/mx_creatematrix.osl @@ -1,14 +1,22 @@ #include "lib/matrix33.h" -void mx_creatematrix_vector3(vector in1, vector in2, vector in3, out matrix33 result) +void mx_creatematrix_vector3_matrix33(vector in1, vector in2, vector in3, out matrix33 result) { result = matrix33.matrix44To33(matrix(in1.x, in1.y, in1.z, 0.0, - in2.x, in2.y, in2.z, 0.0, - in3.x, in3.y, in3.z, 0.0, - 0.0, 0.0, 0.0, 0.0)); + in2.x, in2.y, in2.z, 0.0, + in3.x, in3.y, in3.z, 0.0, + 0.0, 0.0, 0.0, 1.0)); } -void mx_creatematrix_vector4(vector4 in1, vector4 in2, vector4 in3, vector4 in4, out matrix result) +void mx_creatematrix_vector3_matrix44(vector3 in1, vector3 in2, vector3 in3, vector3 in4, out matrix result) +{ + result = matrix(in1.x, in1.y, in1.z, 0.0, + in2.x, in2.y, in2.z, 0.0, + in3.x, in3.y, in3.z, 0.0, + in4.x, in4.y, in4.z, 1.0); +} + +void mx_creatematrix_vector4_matrix44(vector4 in1, vector4 in2, vector4 in3, vector4 in4, out matrix result) { result = matrix(in1.x, in1.y, in1.z, in1.w, in2.x, in2.y, in2.z, in2.w, diff --git a/libraries/stdlib/genosl/stdlib_genosl_impl.mtlx b/libraries/stdlib/genosl/stdlib_genosl_impl.mtlx index 760897a249..59c1f1f932 100644 --- a/libraries/stdlib/genosl/stdlib_genosl_impl.mtlx +++ b/libraries/stdlib/genosl/stdlib_genosl_impl.mtlx @@ -757,8 +757,9 @@ - - + + + diff --git a/libraries/stdlib/stdlib_defs.mtlx b/libraries/stdlib/stdlib_defs.mtlx index 5ecb7f1a8a..9092c8b42e 100644 --- a/libraries/stdlib/stdlib_defs.mtlx +++ b/libraries/stdlib/stdlib_defs.mtlx @@ -4363,14 +4363,22 @@ Node Combine the the three vectors3 from stream into a matrix 33. --> - + - + + + + + + + + + diff --git a/source/MaterialXGenMdl/mdl/materialx/stdlib.mdl b/source/MaterialXGenMdl/mdl/materialx/stdlib.mdl index 203e1a0206..d9a3e2115b 100644 --- a/source/MaterialXGenMdl/mdl/materialx/stdlib.mdl +++ b/source/MaterialXGenMdl/mdl/materialx/stdlib.mdl @@ -4149,7 +4149,7 @@ export float4 mx_combine4_vector4( return float4(mxp_in1, mxp_in2, mxp_in3, mxp_in4); } -export float3x3 mx_creatematrix_vector3( +export float3x3 mx_creatematrix_vector3_matrix33( float3 mxp_in1 = float3(1.0, 0.0, 0.0), float3 mxp_in2 = float3(0.0, 1.0, 0.0), float3 mxp_in3 = float3(0.0, 0.0, 1.0) @@ -4162,11 +4162,25 @@ export float3x3 mx_creatematrix_vector3( } -export float4x4 mx_creatematrix_vector4( - float4 mxp_in1 = float3(1.0, 0.0, 0.0, 0.0), - float4 mxp_in2 = float3(0.0, 1.0, 0.0, 0.0), - float4 mxp_in3 = float3(0.0, 0.0, 1.0, 0.0) - float4 mxp_in4 = float3(0.0, 0.0, 0.0, 1.0) +export float4x4 mx_creatematrix_vector3_matrix44( + float3 mxp_in1 = float3(1.0, 0.0, 0.0), + float3 mxp_in2 = float3(0.0, 1.0, 0.0), + float3 mxp_in3 = float3(0.0, 0.0, 1.0) + float3 mxp_in4 = float3(0.0, 0.0, 0.0) +) + [[ + anno::description("Node Group: math") + ]] +{ + return float4x4(mxp_in1[0],mxp_in1[1],mxp_in1[2],0.0, mxp_in2[0],mxp_in2[1],mxp_in2[2],0.0, mxp_in3[0],mxp_in3[1],mxp_in3[2]0.0, mxp_in4[0],mxp_in4[1],mxp_in4[2],1.0); +} + + +export float4x4 mx_creatematrix_vector4_matrix44( + float4 mxp_in1 = float4(1.0, 0.0, 0.0, 0.0), + float4 mxp_in2 = float4(0.0, 1.0, 0.0, 0.0), + float4 mxp_in3 = float4(0.0, 0.0, 1.0, 0.0) + float4 mxp_in4 = float4(0.0, 0.0, 0.0, 1.0) ) [[ anno::description("Node Group: math")