-
-
Notifications
You must be signed in to change notification settings - Fork 35.4k
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
Added clear coat normal maps #17079
Added clear coat normal maps #17079
Conversation
Added the option to use a clearcoat normal independent from the (maybe) perturbed geometry normal.
Created a separate variable for cc normal, independent perturb implementations
Scale is fine as long as cc scale <= normal scale
Thanks for this! It's great.
I'm not sure we need to worry about adding support for that, but Ben will know.
@sunag will need to be aware of this change, unless you wish to take care of it in a later PR. If someone can contribute a clearcoat normal map that simulates scratches, that would be great. (So would a golf ball normal map for the sphere.) |
It would be helpful if you could clean up your formatting. Try https://zz85.github.io/mrdoobapproves/. It may have a bit of trouble parsing your code, but you can work it out. |
Great job. I can add this feature in node material later once that this PR is merged. |
I've already got work underway for node materials, I wanted to make the PRs as small as I could. Can we add this to the contribution guidelines? That's an awesome tool! |
(@WestLangley I presume it would be better for that case to work with a detailed Icosahedron (Polyhedron), making a high-resolution map for a single face. :-) Update: Or something like this, avoiding a map altogether: https://eliashasle.github.io/golf_ball.html (phew!)) |
@WestLangley, I'm pretty new at Github, so I was wondering what the next step was after linting. |
I think the golf ball idea is great. It would definitely look better than the face/tentacle maps. |
Yeah, this looks good. I am very interested in the node material implementation.
I believe to achieve the UE4 effect they have anisotropy on the underlying threads + a normal map. |
@mrdoob Let's merge this if you approve, as it impacts other concurrent issues. |
Thanks! |
@arobertson0 @bhouston I've refactored the clear coat code a bit. e3dc226 4df6d7c Now, if |
@arobertson0 @bhouston I've also updated the example:
The light code seems correct to me, but the reflection doesn't... Seems like the reflection is being "disturbed" by the normalmap in the clearcoat layer too? (Trying to replicate the UE4 effect) |
Nevermind, I figured it out! 93668f7 https://raw.githack.com/mrdoob/three.js/dev/examples/webgl_materials_clearcoat_normalmap.html 🙌 |
A few suggestions:
/ping @arobertson0 |
I quickly checked, this also happens without clearcoat, on a reflective sphere:
IMO, the effect is "correct". We're seeing specular reflections on microfacets that are aligned with the normal. It looks weird because, due to the high normal scale, the adjacent fragments have a wildly varying normals. So, the highlight doesn't ramp off smoothly. |
I'll work on improving the example and the bottom spheres later today. I was focusing on the top-right one. |
One will see this exact effect in cold snow with a certain crystal type/size at night, when dimly lit by street lights. The snow looks like a night sky of "stars". When you stand still, the "stars" are static. When you walk, the "stars" disappear and appear "randomly". It is beautiful! (I do not have anything to say on whether the effect is correct in this particular case, though.) |
Better add it to |
Temporary live link: For easy comparison, my version with no scene lights, no rotating of spheres. Textures may not be open-source. WestLangley dev three.js dev |
Bottom-right is nice! |
I like all of these variations. :) I just wanted to get rid of the weird
sparkles. It does appear it works correctly.
…On Thu, Aug 8, 2019 at 2:16 PM Mr.doob ***@***.***> wrote:
Bottom-right is nice!
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#17079?email_source=notifications&email_token=AAEPV7OEUBYQZROIKSMPV4TQDRPIXA5CNFSM4IGKAV5KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD34O47A#issuecomment-519630460>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAEPV7P3XVQ2F4HIT6M5R6LQDRPIXANCNFSM4IGKAV5A>
.
--
*Ben Houston*CTO
*M: *+1-613-762-4113
bhouston@threekit.com
Ottawa, ON
[image: LogoThreeKit215x491559143581.png] <https://www.threekit.com/>
ThreeKit Visualization Platform: 3D, 2D, AV, VR <https://www.threekit.com/>
|
Should we rename all the properties before it's too late? clearCoat > clearcoat
clearCoatRoughness > clearcoatRoughness
clearCoatNormalScale > clearcoatNormalScale
clearCoatNormalMap > clearcoatNormalMap |
Yes. I think so. |
@WestLangley Done! b75dd04 |
Don't forget the legacy getter/setters to prevent breakage. |
@WestLangley I was thinking that these properties were so new that getters/setter wouldn't be needed? Was |
My personal examples are broken, so I used it... I added a migration note, but we usually do more than that for user convenience. |
In an effort to align more with the Enterprise PBR model (#16977) I've implemented clearcoat normals. This also addresses issue #12867
When a physical material receives a clear coat normal map, it enables independent clear coat normals and calculates them using the same formulas as the normals, but with a different map.
I've had to change the signature of many GLSL functions that implicitly assumed the clear coat normal was identical to the geometry normal.
To get smooth normals, one can set the clearcoat normalmap to anything as then setting the scale to (0, 0).
I haven't yet added object space clearcoat normals because I wanted to reduce the PR size as much as possible. Same goes for node physical materials.