Skip to content

Commit

Permalink
Harmonize MSL and GLSL implementations (AcademySoftwareFoundation#2070)
Browse files Browse the repository at this point in the history
This changelist addresses a handful of remaining cases where our MSL and GLSL code diverged, harmonizing on shading code that works in both contexts.
  • Loading branch information
jstone-lucasfilm authored Oct 15, 2024
1 parent da60312 commit 8af07e1
Show file tree
Hide file tree
Showing 14 changed files with 22 additions and 113 deletions.
7 changes: 4 additions & 3 deletions libraries/stdlib/genglsl/mx_burn_color3.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

void mx_burn_color3(vec3 fg, vec3 bg, float mixval, out vec3 result)
{
mx_burn_float(fg.x, bg.x, mixval, result.x);
mx_burn_float(fg.y, bg.y, mixval, result.y);
mx_burn_float(fg.z, bg.z, mixval, result.z);
float f;
mx_burn_float(fg.x, bg.x, mixval, f); result.x = f;
mx_burn_float(fg.y, bg.y, mixval, f); result.y = f;
mx_burn_float(fg.z, bg.z, mixval, f); result.z = f;
}
9 changes: 5 additions & 4 deletions libraries/stdlib/genglsl/mx_burn_color4.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

void mx_burn_color4(vec4 fg, vec4 bg, float mixval, out vec4 result)
{
mx_burn_float(fg.x, bg.x, mixval, result.x);
mx_burn_float(fg.y, bg.y, mixval, result.y);
mx_burn_float(fg.z, bg.z, mixval, result.z);
mx_burn_float(fg.w, bg.w, mixval, result.w);
float f;
mx_burn_float(fg.x, bg.x, mixval, f); result.x = f;
mx_burn_float(fg.y, bg.y, mixval, f); result.y = f;
mx_burn_float(fg.z, bg.z, mixval, f); result.z = f;
mx_burn_float(fg.w, bg.w, mixval, f); result.w = f;
}
7 changes: 4 additions & 3 deletions libraries/stdlib/genglsl/mx_dodge_color3.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

void mx_dodge_color3(vec3 fg, vec3 bg, float mixval, out vec3 result)
{
mx_dodge_float(fg.x, bg.x, mixval, result.x);
mx_dodge_float(fg.y, bg.y, mixval, result.y);
mx_dodge_float(fg.z, bg.z, mixval, result.z);
float f;
mx_dodge_float(fg.x, bg.x, mixval, f); result.x = f;
mx_dodge_float(fg.y, bg.y, mixval, f); result.y = f;
mx_dodge_float(fg.z, bg.z, mixval, f); result.z = f;
}
9 changes: 5 additions & 4 deletions libraries/stdlib/genglsl/mx_dodge_color4.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

void mx_dodge_color4(vec4 fg , vec4 bg , float mixval, out vec4 result)
{
mx_dodge_float(fg.x, bg.x, mixval, result.x);
mx_dodge_float(fg.y, bg.y, mixval, result.y);
mx_dodge_float(fg.z, bg.z, mixval, result.z);
mx_dodge_float(fg.w, bg.w, mixval, result.w);
float f;
mx_dodge_float(fg.x, bg.x, mixval, f); result.x = f;
mx_dodge_float(fg.y, bg.y, mixval, f); result.y = f;
mx_dodge_float(fg.z, bg.z, mixval, f); result.z = f;
mx_dodge_float(fg.w, bg.w, mixval, f); result.w = f;
}
8 changes: 4 additions & 4 deletions libraries/stdlib/genglsl/mx_normalmap.glsl
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
void mx_normalmap_vector2(vec3 value, vec2 normal_scale, vec3 N, vec3 T, vec3 B, out vec3 result)
{
value = (value == vec3(0.0)) ? vec3(0.0, 0.0, 1.0) : value * 2.0 - 1.0;

value = T * value.x * normal_scale.x + B * value.y * normal_scale.y + N * value.z;

value = (dot(value, value) == 0.0) ? vec3(0.0, 0.0, 1.0) : value * 2.0 - 1.0;
value = T * value.x * normal_scale.x +
B * value.y * normal_scale.y +
N * value.z;
result = normalize(value);
}

Expand Down
9 changes: 0 additions & 9 deletions libraries/stdlib/genmsl/mx_burn_color3.metal

This file was deleted.

10 changes: 0 additions & 10 deletions libraries/stdlib/genmsl/mx_burn_color4.metal

This file was deleted.

9 changes: 0 additions & 9 deletions libraries/stdlib/genmsl/mx_burn_float.metal

This file was deleted.

9 changes: 0 additions & 9 deletions libraries/stdlib/genmsl/mx_dodge_color3.metal

This file was deleted.

10 changes: 0 additions & 10 deletions libraries/stdlib/genmsl/mx_dodge_color4.metal

This file was deleted.

9 changes: 0 additions & 9 deletions libraries/stdlib/genmsl/mx_dodge_float.metal

This file was deleted.

13 changes: 0 additions & 13 deletions libraries/stdlib/genmsl/mx_normalmap.metal

This file was deleted.

9 changes: 0 additions & 9 deletions libraries/stdlib/genmsl/mx_smoothstep_float.metal

This file was deleted.

17 changes: 0 additions & 17 deletions libraries/stdlib/genmsl/stdlib_genmsl_impl.mtlx
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,6 @@
<input name="default" type="vector4" implname="default_value" />
</implementation>

<!-- <normalmap> -->
<implementation name="IM_normalmap_float_genmsl" nodedef="ND_normalmap_float" file="mx_normalmap.metal" function="mx_normalmap_float" target="genmsl" />
<implementation name="IM_normalmap_vector2_genmsl" nodedef="ND_normalmap_vector2" file="mx_normalmap.metal" function="mx_normalmap_vector2" target="genmsl" />

<!-- ======================================================================== -->
<!-- Procedural nodes -->
<!-- ======================================================================== -->
Expand Down Expand Up @@ -134,23 +130,10 @@
<!-- Adjustment nodes -->
<!-- ======================================================================== -->

<!-- <smoothstep> -->
<implementation name="IM_smoothstep_float_genmsl" nodedef="ND_smoothstep_float" file="mx_smoothstep_float.metal" function="mx_smoothstep_float" target="genmsl" />

<!-- ======================================================================== -->
<!-- Compositing nodes -->
<!-- ======================================================================== -->

<!-- <burn> -->
<implementation name="IM_burn_float_genmsl" nodedef="ND_burn_float" file="mx_burn_float.metal" function="mx_burn_float" target="genmsl" />
<implementation name="IM_burn_color3_genmsl" nodedef="ND_burn_color3" file="mx_burn_color3.metal" function="mx_burn_color3" target="genmsl" />
<implementation name="IM_burn_color4_genmsl" nodedef="ND_burn_color4" file="mx_burn_color4.metal" function="mx_burn_color4" target="genmsl" />

<!-- <dodge> -->
<implementation name="IM_dodge_float_genmsl" nodedef="ND_dodge_float" file="mx_dodge_float.metal" function="mx_dodge_float" target="genmsl" />
<implementation name="IM_dodge_color3_genmsl" nodedef="ND_dodge_color3" file="mx_dodge_color3.metal" function="mx_dodge_color3" target="genmsl" />
<implementation name="IM_dodge_color4_genmsl" nodedef="ND_dodge_color4" file="mx_dodge_color4.metal" function="mx_dodge_color4" target="genmsl" />

<!-- ======================================================================== -->
<!-- Conditional nodes -->
<!-- ======================================================================== -->
Expand Down

0 comments on commit 8af07e1

Please sign in to comment.