question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

MeshPhysicalMaterial should use the thin surface model when thickness is zero

See original GitHub issue

The thin-surface model and the volume model should be separate models in the MeshPhysicalMaterial shader.

Currently, only the volume model is implemented, and if thickness is 0, all components of attenuation color must be non-zero, otherwise the material renders black. A properly-implemented thin-surface model would prevent that.

Maybe define USE_VOLUME if ( .thickness > 0 ). Then something like:

#ifdef USE_TRANSMISSION

	#ifdef USE_TRANSMISSIONMAP

		transmissionFactor *= texture2D( transmissionMap, vUv ).r;

	#endif

	#ifdef USE_THICKNESSMAP

		thicknessFactor *= texture2D( thicknessMap, vUv ).g;

	#endif

	#ifdef USE_VOLUME

		vec4 transmission = getIBLVolumeRefraction( ... );

	#else

		vec4 transmission = getIBLThinSurfaceRefraction( ... );

	#endif

	totalDiffuse = mix( totalDiffuse, transmission.rgb, transmissionFactor );

#endif

three.js version: r.137

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:1
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
mrdoobcommented, Feb 9, 2022

I can give it a go. Where do I find getIBLThinSurfaceRefraction?

0reactions
donmccurdycommented, Sep 16, 2022

Thanks @WestLangley! I haven’t run into this problem yet in working with MeshPhysicalMaterial, but I agree with your suggestions here. 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

MeshPhysicalMaterial – three.js docs
The thickness of the volume beneath the surface. The value is given in the coordinate space of the mesh. If the value is...
Read more >
MeshPhysicalMaterial - Three.js Tutorials - sbcode.net
In this lecture we experiment with the Three.js MeshPhysicalMaterial. It is an extension of the MeshStandardMaterial which gives more reflectivity options.
Read more >
MeshPhysicalMaterial - Verge3D User Manual - Soft8Soft
Represents the thickness of the clear coat layer, from 0.0 to 1.0. Use clear coat related properties to enable multilayer materials that have...
Read more >
Creating the Effect of Transparent Glass and Plastic in Three.js
They can be used to set the stage for how our material responds to ... MeshPhysicalMaterial({ roughness: 0, transmission: 1, thickness: 0.5 ......
Read more >
Surface Type | High Definition RP | 14.0.4 - Unity - Manual
Transparent, Simulates a transparent Material that light can penetrate, ... Use the thin refraction model with thin objects if you use the Path...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found