Skip to content

MeshPhysicalMaterial: Added clearcoat support for rect area lights.#32809

Merged
Mugen87 merged 3 commits into
mrdoob:devfrom
TobiasNoell:feature/clearcoat-for-rect-area-lights
Jan 23, 2026
Merged

MeshPhysicalMaterial: Added clearcoat support for rect area lights.#32809
Mugen87 merged 3 commits into
mrdoob:devfrom
TobiasNoell:feature/clearcoat-for-rect-area-lights

Conversation

@TobiasNoell

Copy link
Copy Markdown
Contributor

Description

directRectArea method in PhysicalLightingModel did not consider a materials' clearcoat settings. Thus, a material appeared without clearcoat if being illuminated by rect area light sources.

@github-actions

github-actions Bot commented Jan 21, 2026

Copy link
Copy Markdown

📦 Bundle size

Full ESM build, minified and gzipped.

Before After Diff
WebGL 356.54
84.66
357.28
84.79
+749 B
+132 B
WebGPU 621.76
172.66
622.03
172.75
+272 B
+86 B
WebGPU Nodes 620.36
172.43
620.63
172.51
+272 B
+86 B

🌳 Bundle size after tree-shaking

Minimal build including a renderer, camera, empty scene, and dependencies.

Before After Diff
WebGL 489.35
119.68
490.1
119.81
+749 B
+135 B
WebGPU 692.73
187.97
693
188.05
+272 B
+79 B
WebGPU Nodes 642.4
175.15
642.4
175.15
+0 B
+0 B

@Mugen87 Mugen87 added this to the r183 milestone Jan 21, 2026
@Mugen87 Mugen87 changed the title Added clearcoat rendering for rect area lights in webgpu renderer WebGPURenderer: Added clearcoat support for rect area lights. Jan 21, 2026
Comment thread src/nodes/functions/PhysicalLightingModel.js
@Mugen87

Mugen87 commented Jan 22, 2026

Copy link
Copy Markdown
Collaborator

Can you also provide a fiddle that allows use to verify the change? Like a simple scene with a clear coat material and a rect area light?

@TobiasNoell

Copy link
Copy Markdown
Contributor Author

Can you also provide a fiddle that allows use to verify the change? Like a simple scene with a clear coat material and a rect area light?

Sure, but is there any documentation how I can make the fiddle use the build attached to this PR?

@Mugen87

Mugen87 commented Jan 22, 2026

Copy link
Copy Markdown
Collaborator

It's sufficient to show how it's not working with the current release. I can then test this change locally.

@TobiasNoell TobiasNoell force-pushed the feature/clearcoat-for-rect-area-lights branch from e68f0bc to d6f6a00 Compare January 22, 2026 10:52
@TobiasNoell

Copy link
Copy Markdown
Contributor Author

I have added a fiddle here: https://jsfiddle.net/TobiasNoell/jprxayeb/47/
It is basically the rect area light source example, just the torus has a roughness of 1 plus a clearcoat added with roughness 0

@Mugen87

Mugen87 commented Jan 22, 2026

Copy link
Copy Markdown
Collaborator

Small advice: In general, when you file a PR that updates a material's shader, it's good to share before/after screenshots in the initial comment so the community immediately sees what the PR is about.

@TobiasNoell

Copy link
Copy Markdown
Contributor Author

I have also generalized the LTC formula to cope with materials that have a specularF90 that is not one
d6f6a00

@Mugen87

Mugen87 commented Jan 22, 2026

Copy link
Copy Markdown
Collaborator

For comparison:

Before:
image

After:

image

@Mugen87

Mugen87 commented Jan 22, 2026

Copy link
Copy Markdown
Collaborator

I have also generalized the LTC formula to cope with materials that have a specularF90 that is not one

When I understand the code correctly, the F90 value was previously hard coded to vec3(1.0). But depending how specular and metalness are configured, the material's F90 value is different. So the proposed change looks like a correct extension.

@TobiasNoell

Copy link
Copy Markdown
Contributor Author

When I understand the code correctly, the F90 value was previously hard coded to vec3(1.0). But depending how specular and metalness are configured, the material's F90 value is different. So the proposed change looks like a correct extension.

The rational behind this is that in the LTC approximation (https://blog.selfshadow.com/publications/s2016-advances/s2016_ltc_fresnel.pdf) the Schlick approximation was used but with a hardcoded setting of F90 = 1,

vec3 F_Schlick(float u, vec3 f0) {
    return f0 + (1.0 - f0) * pow(1.0 - u, 5.0);
}

The more general term with F90 would be

vec3 F_Schlick(float u, vec3 f0, float f90) {
    return f0 + (vec3(f90) - f0) * pow(1.0 - u, 5.0);
}

which would yield to this update

@Mugen87 Mugen87 changed the title WebGPURenderer: Added clearcoat support for rect area lights. MeshPhysicalMaterial: Added clearcoat support for rect area lights. Jan 22, 2026
@Mugen87 Mugen87 merged commit fffb5ac into mrdoob:dev Jan 23, 2026
10 checks passed
@mrdoob

mrdoob commented Jan 23, 2026

Copy link
Copy Markdown
Owner

Nice!

@TobiasNoell I was working on this before the holidays: #32496

Need to find some time to get back to it.

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.

3 participants