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

MeshPhysicalMaterial: Support clearcoatMap, clearcoatRoughnessMap #18677

Closed
donmccurdy opened this issue Feb 19, 2020 · 15 comments
Closed

MeshPhysicalMaterial: Support clearcoatMap, clearcoatRoughnessMap #18677

donmccurdy opened this issue Feb 19, 2020 · 15 comments

Comments

@donmccurdy
Copy link
Collaborator

MeshPhysicalMaterial currently offers:

  • clearcoat
  • clearcoatRoughness
  • clearcoatNormalMap

The glTF extension KHR_materials_clearcoat will also require texture versions of the first two, which I'd propose adding to (only) MeshPhysicalMaterial:

  • clearcoatMap
  • clearcoatRoughnessMap
@donmccurdy
Copy link
Collaborator Author

/cc @arobertson0 @bhouston

donmccurdy added a commit to donmccurdy/three.js that referenced this issue Feb 20, 2020
- GLTFLoader: Implement KHR_materials_clearcoat extension.
- MeshPhysicalMaterial: Support clearcoatMap and clearcoatRoughnessMap.
- Fixes mrdoob#18677.
donmccurdy added a commit to donmccurdy/three.js that referenced this issue Feb 20, 2020
- GLTFLoader: Implement KHR_materials_clearcoat extension.
- MeshPhysicalMaterial: Support clearcoatMap and clearcoatRoughnessMap.
- Fixes mrdoob#18677.
@donmccurdy
Copy link
Collaborator Author

In progress: #18682

@donmccurdy
Copy link
Collaborator Author

Fixed by #18769.

@WestLangley
Copy link
Collaborator

@donmccurdy What support do you intend for clearcoat/roughness map offset/repeat settings?

Currently, it is not considered in the offset/repeat priority list.

@donmccurdy
Copy link
Collaborator Author

Hm. My first reaction would be uv2 for clearcoatNormalMap, uv1 for everything else. It would be nice to get out of having to hardcode those pairings. 😅

@WestLangley
Copy link
Collaborator

Should the clearcoat normal/roughness map be added to the priority list so -- at a minimum -- offset/repeat is honored if it is the only map.

@PaulMitch
Copy link

Are there any known limitations apart from performance that is stopping repeat texturing of the clear coat normal?
I'm happy to have a look into it if someone can point me where to start.

@WestLangley
Copy link
Collaborator

This is a long-standing issue. For the primary uv set, three.js only supports one offset/repeat pair per material. See #8278.

// uv repeat and offset setting priorities
// 1. color map
// 2. specular map
// 3. normal map
// 4. bump map
// 5. alpha map
// 6. emissive map

@PaulMitch
Copy link

Ok, thanks for the info. So in a perfect world we'd need 3 UV sets as AO works great on UV set 2. So the clearcoat normals would have to be moved to UV set 3 :)

@donmccurdy
Copy link
Collaborator Author

On second thought, I don't know why I suggested uv2 for clearcoat normals... all of these could be uv1, as far as I can tell. More flexibility would be nice of course, but clearcoat has no unique need for uv3, compared to other maps.

I don't know what's in your model, @PaulMitch, does it require a 3rd UV set?

If reusing the existing uv1 is enough, then my answer to @WestLangley's question ...

Should the clearcoat normal/roughness map be added to the priority list so -- at a minimum -- offset/repeat is honored if it is the only map.

... would be yes.

@PaulMitch
Copy link

Ok so when @WestLangley says "the only map", does that mean the only map using offset/repeat for that UV set.
So we could potentially have an aoMap (non repeating) and a clearcoatNormalMap that repeats on UV set 2.
Is this something that could be done already using Node materials?

@donmccurdy
Copy link
Collaborator Author

The change we should probably make would be to update the code that @WestLangley linked to and ensure that if any clearcoat-related texture has a UV transform, three.js will use it. Because clearcoat maps are not in that list, they currently only get a UV transform if another texture using UV1 has a transform.

My original suggestion of putting clearcoatNormalMap on UV2 was probably a bad idea, I don't know of any reason clearcoatNormalMap is more likely to share UVs with AO and lightmaps than with other clearcoat-related textures.

The NodeMaterial system has (much) more flexibility — it can pair any texture slot with any UV map, and supports an arbitrary number of UV attributes. However, (1) I don't know if we can consider it stable, and (2) I'm not sure whether new features like clearcoat, clearcoat roughness, and clearcoat normals have been added to the NodeMaterial shaders yet.

@PaulMitch
Copy link

Yeah it looks like MeshStandardNodeMaterial is added to the master branch, Thanks for your quick responses guys, much appreciated.

@PaulMitch
Copy link

Wow adding a map texture with a transform worked great, The clearcoatnormal is now repeating.
I was just using a colour as there was no map texture, so making that colour as an 8x8 map and making it a repeating texture worked a treat.
Thanks

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

No branches or pull requests

3 participants