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

Bad Texture Unit-scale, missing Transparency and Metal for Fusion360 Materials #51

Open
wallabyway opened this issue Feb 16, 2022 · 3 comments

Comments

@wallabyway
Copy link
Collaborator

wallabyway commented Feb 16, 2022

prism-materials-wrong

Markers:

  • Red: Fabric has the wrong texture scale
  • Green: Transparent fabric is not working (using alpha cut-through mask)
  • Blue: Metalic materiał comes out black, maybe scale issue?

Right: Fusion(F3D) in LMV
Left: LGLTracer with glTF

Source F3D: https://developer.api.autodesk.com/oss/v2/signedresources/8982cad5-0eda-4beb-96fb-6244062d21aa?region=US

@wallabyway
Copy link
Collaborator Author

wallabyway commented Feb 17, 2022

Missing Metals

The metal issue is related to using the wrong materials json file.

The Materials.json.gz file maps the f0 base color into the specular value, but the metallic-roughness value is gone. The ProteinMaterials.json.gz file contains both the f0 base color of metals, as well as it's metallic roughness.
The ProteinMaterials.json.gz has more information needed for glTF's PBR materials, than Materials.json.gz. You may want to switch over to that.
Note: fixing metals will also fix this issue... #23

Texture Scale

Looks like LGLTracer is missing support for KHR_texture_transform, causing the texture scale issue. Nothing to do with forge-convert-utils.
https://github.com/LGL-Tracer-Renderer/LGL-Tracer-Renderer.github.io/issues/15

@wallabyway
Copy link
Collaborator Author

The fix:

divide glossiness by 20 and by 60, depending on isMetal, like so...

at line 126 in reader.ts

            roughness: _mat?.glossiness ? ( 20.0/ _mat.glossiness ) : 1.0, // TODO: how to map glossiness to roughness properly?
            scale: {x: _mat?.maps?.diffuse?.scale.texture_UScale ?? 1.0 , y: _mat?.maps?.diffuse?.scale.texture_VScale ?? 1.0}
        };
        if (_mat?.diffuse) {
            mat.diffuse.x = _mat.diffuse[0];
            mat.diffuse.y = _mat.diffuse[1];
            mat.diffuse.z = _mat.diffuse[2];
        }
        if (_mat?.metal && _mat.specular && _mat.glossiness) {
            mat.diffuse.x = _mat.specular[0];
            mat.diffuse.y = _mat.specular[1];
            mat.diffuse.z = _mat.specular[2];
            mat.roughness = 60/_mat.glossiness;
        }        

Reference (LMV)

Screen Shot 2022-02-17 at 7 22 16 PM

Results ( Three.js, Babylon.js, LGLTracer ):

Screen Shot 2022-02-17 at 7 20 02 PM

@petrbroz
Copy link
Owner

Thanks @wallabyway, I've just merged the PR. Next week we can test it out and publish a new version if everything looks correct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants