Skip to content

Commit

Permalink
Implemented missing interface, various bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
friedererdmann committed Oct 10, 2023
1 parent a5119c7 commit fb071c4
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 23 deletions.
12 changes: 10 additions & 2 deletions libraries/stdlib/genglsl/mx_creatematrix.glsl
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
5 changes: 3 additions & 2 deletions libraries/stdlib/genglsl/stdlib_genglsl_impl.mtlx
Original file line number Diff line number Diff line change
Expand Up @@ -755,8 +755,9 @@


<!-- <creatematrix> -->
<implementation name="IM_creatematrix_vector3_genglsl" nodedef="ND_creatematrix_vector3" file="mx_creatematrix.glsl" function="mx_creatematrix_vector3" target="genglsl" />
<implementation name="IM_creatematrix_vector4_genglsl" nodedef="ND_creatematrix_vector4" file="mx_creatematrix.glsl" function="mx_creatematrix_vector4" target="genglsl" />
<implementation name="IM_creatematrix_vector3_matrix33_genglsl" nodedef="ND_creatematrix_vector3_matrix33_genglsl" file="mx_creatematrix.glsl" function="mx_creatematrix_vector3_matrix33" target="genglsl" />
<implementation name="IM_creatematrix_vector4_matrix44_genglsl" nodedef="ND_creatematrix_vector3_matrix44_genglsl" file="mx_creatematrix.glsl" function="mx_creatematrix_vector3_matrix44" target="genglsl" />
<implementation name="IM_creatematrix_vector4_matrix44_genglsl" nodedef="ND_creatematrix_vector4_matrix44_genglsl" file="mx_creatematrix.glsl" function="mx_creatematrix_vector4_matrix44" target="genglsl" />


<!-- ======================================================================== -->
Expand Down
5 changes: 3 additions & 2 deletions libraries/stdlib/genmdl/stdlib_genmdl_impl.mtlx
Original file line number Diff line number Diff line change
Expand Up @@ -760,8 +760,9 @@
<implementation name="IM_combine4_vector4_genmdl" nodedef="ND_combine4_vector4" target="genmdl" />

<!-- <creatematrix> -->
<implementation name="IM_creatematrix_vector3_genmdl" nodedef="ND_creatematrix_vector3" sourcecode="mx::stdlib::mx_creatematrix_vector3({{in1}}, {{in2}}, {{in3}}, {{result}})" target="genmdl" />
<implementation name="IM_creatematrix_vector4_genmdl" nodedef="ND_creatematrix_vector4" sourcecode="mx::stdlib::mx_creatematrix_vector4({{in1}}, {{in2}}, {{in3}}, {{in4}}, {{result}})" target="genmdl" />
<implementation name="IM_creatematrix_vector3_matrix33_genmdl" nodedef="ND_creatematrix_vector3_matrix33" sourcecode="mx::stdlib::mx_creatematrix_vector3_matrix33({{in1}}, {{in2}}, {{in3}}, {{result}})" target="genmdl" />
<implementation name="IM_creatematrix_vector3_matrix44_genmdl" nodedef="ND_creatematrix_vector3_matrix44" sourcecode="mx::stdlib::mx_creatematrix_vector3_matrix44({{in1}}, {{in2}}, {{in3}}, {{in4}}, {{result}})" target="genmdl" />
<implementation name="IM_creatematrix_vector4_matrix44_genmdl" nodedef="ND_creatematrix_vector4_matrix44" sourcecode="mx::stdlib::mx_creatematrix_vector4_matrix44({{in1}}, {{in2}}, {{in3}}, {{in4}}, {{result}})" target="genmdl" />

<!-- ======================================================================== -->
<!-- Convolution nodes -->
Expand Down
5 changes: 3 additions & 2 deletions libraries/stdlib/genmsl/stdlib_genmsl_impl.mtlx
Original file line number Diff line number Diff line change
Expand Up @@ -754,8 +754,9 @@
<implementation name="IM_combine4_vector4_genmsl" nodedef="ND_combine4_vector4" target="genmsl" />

<!-- <creatematrix> -->
<implementation name="IM_creatematrix_vector3_genmsl" nodedef="ND_creatematrix_vector3" file="../genglsl/mx_creatematrix.glsl" function="mx_creatematrix_vector3" nodegroup="genmsl" />
<implementation name="IM_creatematrix_vector4_genmsl" nodedef="ND_creatematrix_vector4" file="../genglsl/mx_creatematrix.glsl" function="mx_creatematrix_vector4" nodegroup="genmsl" />
<implementation name="IM_creatematrix_vector3_matrix33_genmsl" nodedef="ND_creatematrix_vector3_matrix33" file="../genglsl/mx_creatematrix.glsl" function="mx_creatematrix_vector3_matrix33" nodegroup="genmsl" />
<implementation name="IM_creatematrix_vector3_matrix44_genmsl" nodedef="ND_creatematrix_vector3_matrix44" file="../genglsl/mx_creatematrix.glsl" function="mx_creatematrix_vector3_matrix44" nodegroup="genmsl" />
<implementation name="IM_creatematrix_vector4_matrix44_genmsl" nodedef="ND_creatematrix_vector4_matrix44" file="../genglsl/mx_creatematrix.glsl" function="mx_creatematrix_vector4_matrix44" nodegroup="genmsl" />

<!-- ======================================================================== -->
<!-- Convolution nodes -->
Expand Down
18 changes: 13 additions & 5 deletions libraries/stdlib/genosl/mx_creatematrix.osl
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
5 changes: 3 additions & 2 deletions libraries/stdlib/genosl/stdlib_genosl_impl.mtlx
Original file line number Diff line number Diff line change
Expand Up @@ -757,8 +757,9 @@
<implementation name="IM_combine4_vector4_genosl" nodedef="ND_combine4_vector4" target="genosl" />

<!-- <creatematrix> -->
<implementation name="IM_creatematrix_vector3_genosl" nodedef="ND_creatematrix_vector3" file="mx_creatematrix.osl" function="mx_creatematrix_vector3" nodegroup="genosl" />
<implementation name="IM_creatematrix_vector4_genosl" nodedef="ND_creatematrix_vector4" file="mx_creatematrix.osl" function="mx_creatematrix_vector4" nodegroup="genosl" />
<implementation name="IM_creatematrix_vector3_matrix33_genosl" nodedef="ND_creatematrix_vector3_matrix33" file="mx_creatematrix.osl" function="mx_creatematrix_vector3_matrix33" nodegroup="genosl" />
<implementation name="IM_creatematrix_vector3_matrix44_genosl" nodedef="ND_creatematrix_vector3_matrix44" file="mx_creatematrix.osl" function="mx_creatematrix_vector3_matrix44" nodegroup="genosl" />
<implementation name="IM_creatematrix_vector4_matrix44_genosl" nodedef="ND_creatematrix_vector4_matrix44" file="mx_creatematrix.osl" function="mx_creatematrix_vector4_matrix44" nodegroup="genosl" />

<!-- ======================================================================== -->
<!-- Convolution nodes -->
Expand Down
12 changes: 10 additions & 2 deletions libraries/stdlib/stdlib_defs.mtlx
Original file line number Diff line number Diff line change
Expand Up @@ -4363,14 +4363,22 @@
Node <creatematrix>
Combine the the three vectors3 from stream into a matrix 33.
-->
<nodedef name="ND_creatematrix_vector3" node="creatematrix" nodegroup="math">
<nodedef name="ND_creatematrix_vector3_matrix33" node="creatematrix" nodegroup="math">
<input name="in1" type="vector3" value="1.0, 0.0, 0.0" />
<input name="in2" type="vector3" value="0.0, 1.0, 0.0" />
<input name="in3" type="vector3" value="0.0, 0.0, 1.0" />
<output name="result" type="matrix33" default="1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0" />
</nodedef>

<nodedef name="ND_creatematrix_vector4" node="creatematrix" nodegroup="math">
<nodedef name="ND_creatematrix_vector3_matrix44" node="creatematrix" nodegroup="math">
<input name="in1" type="vector3" value="1.0, 0.0, 0.0" />
<input name="in2" type="vector3" value="0.0, 1.0, 0.0" />
<input name="in3" type="vector3" value="0.0, 0.0, 1.0" />
<input name="in4" type="vector3" value="0.0, 0.0, 0.0" />
<output name="result" type="matrix44" default="1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0, 0.0" />
</nodedef>

<nodedef name="ND_creatematrix_vector4_matrix44" node="creatematrix" nodegroup="math">
<input name="in1" type="vector4" value="1.0, 0.0, 0.0, 0.0" />
<input name="in2" type="vector4" value="0.0, 1.0, 0.0, 0.0" />
<input name="in3" type="vector4" value="0.0, 0.0, 1.0, 0.0" />
Expand Down
26 changes: 20 additions & 6 deletions source/MaterialXGenMdl/mdl/materialx/stdlib.mdl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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")
Expand Down

0 comments on commit fb071c4

Please sign in to comment.