Defines in cube_uv_reflection_fragment can break MeshPhongMaterial
See original GitHub issueDescribe the bug
Short defines such as those in cube_uv_reflection_fragment
can clash with user-defined materials via ShaderMaterial
and built-in materials that use bsdfs
(related: #22728).
To Reproduce
The above behavior can be reproduced when passing a texture from PMREMGenerator
to a MeshPhongMaterial
via envMap
.
Code
import * as THREE from 'three';
import { RGBELoader } from 'three/examples/jsm/loaders/RGBELoader.js';
const renderer = new THREE.WebGLRenderer();
new RGBELoader().load( '/lago_disola_1k.hdr', ( texture ) => {
const envMap = new THREE.PMREMGenerator( renderer ).fromEquirectangular( texture ).texture;
const geometry = new THREE.BoxGeometry();
const material = new THREE.MeshPhongMaterial( { envMap } );
const mesh = new THREE.Mesh( geometry, material );
renderer.compile( mesh );
});
Live example
Expected behavior
Defines in cube_uv_reflection_fragment
should be more specific and probably follow the existing local cubeUV_*
pattern.
Screenshots
Platform:
- Device: [N/A]
- OS: [N/A]
- Browser: [N/A]
- Three.js version: [r143, since #18004]
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:7 (1 by maintainers)
Top Results From Across the Web
Three.js Materials
They define how objects will appear in the scene. Which materials you use really depends on what you're trying to accomplish. There are...
Read more >javascript - MeshPhongMaterial doesn't appear - Stack Overflow
I am a beginner in THREE.js, I want to create a sphere which I will use to create globe ...
Read more >Three.js: Geometries and materials - LogRocket Blog
Geometries are used to create and define shapes in Three.js. ... A value of 3 will split the surface into three smaller sides....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I think this issue is pretty clearly about loose defines made in
cube_uv_reflection_fragment
which can only cause trouble with built-in materials and user-defined materials –bsdfs
being merely an example.If
MeshPhongMaterial
(and alsoMeshLambertMaterial
&MeshPhysicalMaterial
) aren’t supposed to includecube_uv_reflection_fragment
then remove it, but it’s not the (intentional) focus of this issue.Edit: I see you already got it in #24475
Since we want to support background blurriness at some point, the engine potentially needs PMREM support for the background shader. #23712 implemented this feature with normal mipmaps, however, other engines actually use PMREM. So this question has to be decided first before we can update the background shader.