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: Added sheen #16971

Merged
merged 28 commits into from
Aug 20, 2019
Merged

MeshPhysicalMaterial: Added sheen #16971

merged 28 commits into from
Aug 20, 2019

Conversation

DanielSturk
Copy link
Contributor

@DanielSturk DanielSturk commented Jul 3, 2019

Added sheen for cloth materials such as velvet. The BDRF used is the same as Google's Filament (NDF is Estevez's and Kulla's "Charlie" sheen + Neubelt's visibility term https://google.github.io/filament/Filament.md.html).

I also added support for sheen to the StandardNodeMaterial (@sunag)

The demo for testing is webgl_materials_sheen.html

@DanielSturk
Copy link
Contributor Author

By the way, this implementation only covers direct lighting for the time being. There's a bit of confusion/complication in regards to IBL and ambient lighting because sheen seems to be dependent on the direction of the light source

@bhouston
Copy link
Contributor

bhouston commented Jul 3, 2019

We should never support ambient lighting on this.

@sunag
Copy link
Collaborator

sunag commented Jul 4, 2019

Thank you for your contribution once again...
The parameter and example sheen does not seem to be working.
I believe that changes in the core and in the NodeMaterial should be sent separately but I think if possible unify this feature using nodes only without modify the core...

@DanielSturk
Copy link
Contributor Author

@sunag

The parameter and example sheen does not seem to be working.

What do you mean by this? I asked my colleague tested it and it runs fine on his machine

@sciecode
Copy link
Contributor

sciecode commented Jul 4, 2019

@sunag

If you are using something like "githack" to test, it won't work.
Three.module.js needs to be updated, because of new sheen parameter.
Running it locally works as intended.

@bhouston
Copy link
Contributor

bhouston commented Jul 4, 2019

unify this feature using nodes only without modify the core...

The reason we are adding this is that it is a BRDF improvement and it is to align with the Enterprise PBR model: https://github.com/DassaultSystemes-Technology/EnterprisePBRShadingModel

@bhouston
Copy link
Contributor

bhouston commented Jul 4, 2019

This is being done in this later context of adopting PBR Next / Enterprise PBR #16977 and ensuring Node-graph materials are awesome #16440

@sunag
Copy link
Collaborator

sunag commented Jul 5, 2019

@DanielSturk @sciecode Yeah, I run locally and work thanks.

The reason we are adding this is that it is a BRDF improvement and it is to align with the Enterprise PBR model: https://github.com/DassaultSystemes-Technology/EnterprisePBRShadingModel

The roadmap is very good. My think is advance in BRDF using nodes only to create better support for it and facilitate the merger of PR. Once implemented, create other BRDF features will be easier and optimized since the code can be calculated modularly. Sheen could be one of these new BRDF nodes.

@bhouston
Copy link
Contributor

bhouston commented Jul 5, 2019 via email

@sunag
Copy link
Collaborator

sunag commented Jul 5, 2019

Usually the brdf parameters are part of the base brdf node. Having brdf
parameters as separate nodes generally is not how brdfs are implemented.

I was not thinking about separating the code from BRDF class, just implementing it as a process tree a bit more organized.
brdf/SheenNode for example...

So we can add relatives sheen functions if the parameter .sheen is really used.
Relative the performance, it is good too, even unused function adds an increased time to program creation.

@sunag
Copy link
Collaborator

sunag commented Jul 17, 2019

@mrdoob @WestLangley I do not want to block this PR, maybe I have caused this impression, it looks good to me. I can improve these details relative to the NodeMaterial later with other PR.

@DanielSturk DanielSturk reopened this Jul 24, 2019
@Mugen87
Copy link
Collaborator

Mugen87 commented Jul 25, 2019

https://raw.githack.com/DanielSturk/three.js/sheen/examples/webgl_materials_sheen.html

It seems it's not possible to control the arm with the keys like in the original physics example. Besides, the arm jitters right now in a strange way. At least on my system.

If no interaction is intended, consider to remove the arm or make it static.

@yomboprime
Copy link
Collaborator

https://raw.githack.com/DanielSturk/three.js/sheen/examples/webgl_materials_sheen.html

It seems it's not possible to control the arm with the keys like in the original physics example. Besides, the arm jitters right now in a strange way. At least on my system.

If no interaction is intended, consider to remove the arm or make it static.

He has put a Math.random() in the arm control.

# Conflicts:
#	examples/jsm/nodes/materials/nodes/StandardNode.js
@Mugen87
Copy link
Collaborator

Mugen87 commented Aug 7, 2019

@DanielSturk Can you please resolve the merge conflicts?

# Conflicts:
#	src/materials/MeshPhysicalMaterial.d.ts
#	src/materials/MeshPhysicalMaterial.js
#	src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js
#	src/renderers/shaders/ShaderLib.js
@Mugen87
Copy link
Collaborator

Mugen87 commented Aug 8, 2019

@mrdoob Looks ready to merge 👍

@bhouston
Copy link
Contributor

Is there a reason this isn't being merged?

@Mugen87
Copy link
Collaborator

Mugen87 commented Aug 20, 2019

Sorry, I'm sure this PR was just overlooked.

@DanielSturk Can you please resolve the merge conflicts one more time?

@romainguy
Copy link

@DanielSturk What problems did you run into with IBL support for sheen? Folks on Babylon.js and I both got it to work, we can help if you'd like.

@DanielSturk
Copy link
Contributor Author

@Mugen87 Np. Merge conflicts resolved :)

@DanielSturk
Copy link
Contributor Author

@DanielSturk What problems did you run into with IBL support for sheen? Folks on Babylon.js and I both got it to work, we can help if you'd like.

Thank you, I appreciate the support! I've got it working now (was a little confused by the DFG (DG) LUT but it's working now). As soon as we can get this merged, I'll create the PR for the IBL Sheen!

@mrdoob mrdoob changed the title Added sheen MeshPhysicalMaterial: Added sheen Aug 20, 2019
@mrdoob mrdoob merged commit 1855c15 into mrdoob:dev Aug 20, 2019
@mrdoob
Copy link
Owner

mrdoob commented Aug 20, 2019

Thanks!

@mrdoob
Copy link
Owner

mrdoob commented Aug 20, 2019

@DanielSturk @bhouston I have renamed the property to sheen to match emissive, specular, ... 3e9af1f

@mrdoob
Copy link
Owner

mrdoob commented Aug 21, 2019

@sunag on one of my computers (MacBook Air, Early 2015, Intel HD Graphics 6000) the sheen example runs at 20fps when using the node material, and at 60fps when not using it.

In this screenshot, the fps graph shows when nodematerial was enabled and disabled:

Screenshot 2019-08-20 at 17 10 59

@sunag
Copy link
Collaborator

sunag commented Aug 21, 2019

@sunag on one of my computers (MacBook Air, Early 2015, Intel HD Graphics 6000) the sheen example runs at 20fps when using the node material, and at 60fps when not using it.

This because the NodeMaterial is being compiled every frame: nodeMaterial.needsCompile = true; is added in render loop. I already send a PR to fix this.

@mrdoob
Copy link
Owner

mrdoob commented Aug 21, 2019

This because the NodeMaterial is being compiled every frame: nodeMaterial.needsCompile = true; is added in render loop. I already send a PR to fix this.

Oh, what's the PR that fixes it?

@sunag
Copy link
Collaborator

sunag commented Aug 21, 2019

Oh, what's the PR that fixes it?

Ops, I'm already sending, sry my english 😳

@DanielSturk
Copy link
Contributor Author

Thanks for the merge @mrdoob and everyone involved
Make sure to check out my follow up PR for IBL support @romainguy #17303

@donmccurdy
Copy link
Collaborator

The glTF sheen extension (KHR_materials_sheen) is nearly complete, although still welcoming feedback for a bit longer. To implement in MeshPhysicalMaterial, it would require:

  • sheen
  • sheenMap
  • sheenRoughness
  • sheenRoughnessMap

The two maps use .rgb and .a channels respectively; they can be combined.

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

Successfully merging this pull request may close these issues.

10 participants