Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix MaterialX compilation on M1 Macs #2579

Merged
merged 2 commits into from
Sep 7, 2022

Conversation

JGamache-autodesk
Copy link
Collaborator

Fixes #2267 ?

Removes a global struct that was used to pass vertex data around.

This is an educated guess based on the GLSL compilation error message I received:

ERROR: 0:338: Missing initializer for const variable ‘g_mxVertexData’
ERROR: 0:1557: Use of undeclared identifier ‘g_mxVertexData’
ERROR: 0:1558: Use of undeclared identifier ‘g_mxVertexData’
ERROR: 0:1559: Use of undeclared identifier ‘g_mxVertexData’

Fixes #2267 ?

Removes a global struct that was used to pass vertex data around.

This is an educated guess based on the GLSL compilation error message I received:
```
ERROR: 0:338: Missing initializer for const variable ‘g_mxVertexData’
ERROR: 0:1557: Use of undeclared identifier ‘g_mxVertexData’
ERROR: 0:1558: Use of undeclared identifier ‘g_mxVertexData’
ERROR: 0:1559: Use of undeclared identifier ‘g_mxVertexData’
```
@JGamache-autodesk
Copy link
Collaborator Author

Confirmed to work by @hodoulp on his M1 machine. Ready for review.

//
// And replace with:
//
// HW::T_POSITION_WORLD(PIX_IN.HW::T_POSITION_WORLD) $normalWorld( PIX_IN.$normalWorld )
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be further replaced later so we get the familiar Nw( PIX_IN.Nw ) that can be observed in the shader main function if looking with APITrace.

//
// And replace with:
//
// (nothing) $inGeomprop_st
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are captured in the shader main and passed as parameters, so they do not require the PIX_IN treatment.

@JGamache-autodesk
Copy link
Collaborator Author

Here is the final change in shader code so we see the result in a less abstract form:

--- /d/fragment1.glsl	2022-09-06 14:03:14.386810800 -0400
+++ /d/fragment2.glsl	2022-09-06 14:06:13.377655600 -0400
@@ -1,9 +1,3 @@
-struct
-{
-    vec3 Nw;
-    vec3 Pw;
-} g_mxVertexData;
-
 #define MAX_LIGHT_SOURCES 1
 
 struct BSDF { vec3 response; vec3 throughput; float thickness; float ior; };
@@ -1329,9 +1323,9 @@
     vec3 coat_affected_diffuse_color_out = pow(base_color, vec3(coat_gamma_out));
     surfaceshader shader_constructor_out = surfaceshader(vec3(0.0),vec3(0.0));
     {
-        vec3 N = normalize(g_mxVertexData.Nw);
-        vec3 V = normalize(u_viewPosition - g_mxVertexData.Pw);
-        vec3 P = g_mxVertexData.Pw;
+        vec3 N = normalize(Nw( PIX_IN.Nw ));
+        vec3 V = normalize(u_viewPosition - Pw( PIX_IN.Pw ));
+        vec3 P = Pw( PIX_IN.Pw );
 
         float surfaceOpacity = opacity_luminance_out.x;
 
@@ -1550,13 +1544,11 @@
     vec3 emission_color,
     vec3 opacity,
     bool thin_walled,
-    vec3 Nw,
-    vec3 Pw)
+    vec3 unused_normalWorld,
+    vec3 unused_positionWorld)
 {
-    g_mxVertexData.Nw = Nw;
-    g_mxVertexData.Pw = Pw;
-    vec3 geomprop_Nworld_out = normalize(g_mxVertexData.Nw);
-    vec3 geomprop_Pworld_out = g_mxVertexData.Pw;
+    vec3 geomprop_Nworld_out = normalize(Nw( PIX_IN.Nw ));
+    vec3 geomprop_Pworld_out = Pw( PIX_IN.Pw );
     vec3 Tw_reader_out = vec3(0.0);
     mx_arbitrarytangents_vector3(geomprop_Pworld_out, geomprop_Nworld_out, Tw_reader_out);
     surfaceshader SR_USD_Mtlx_VP2_Material_out = surfaceshader(vec3(0.0),vec3(0.0));

Copy link
Collaborator

@vlasovi vlasovi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

@JGamache-autodesk
Copy link
Collaborator Author

Timeout glitch on preflight. Ready for merge.

@JGamache-autodesk JGamache-autodesk added the ready-for-merge Development process is finished, PR is ready for merge label Sep 6, 2022
@seando-adsk seando-adsk merged commit 53e5597 into dev Sep 7, 2022
@seando-adsk seando-adsk deleted the t_gamaj/MAYA-122706/remove_global_variable_usage branch September 7, 2022 14:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-for-merge Development process is finished, PR is ready for merge vp2renderdelegate Related to VP2RenderDelegate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[MAYA-122706] Testing MaterialX in Maya 2023
4 participants