Hi three gurus, I am trying to find a way to capture a cubemap inside a room, more like a reflection probe, currently I am using .CubeTextureLoader
but obviously the reflection is totall wrong when inside a room.
I search the forum but find nothing related to a sort of “reflection probe” like unreal has, am I miss something important? How can I capture a cube texutre in a room?
Please guide me through, thank you so much!
Have you considered to use an instance of CubeCamera
like demonstrated in the following example? It can be used to dynamically create environment maps representing the current visual state of the 3D scene.
https://threejs.org/examples/webgl_materials_cubemap_dynamic
Thank you sir for your reply, I’ve already read this link many times and I have load a gltf scene for test, but still I can’t get the reflection.
As a total noob I can only get this far, could you please guild me through?
I would like my gltf scene reflected itself with each other, so I crate a cubeCamera
and positioned to the center of the room, here is what I currently done
https://jsfiddle.net/devnkwx8/
You removed the object from the scene before updating the cube camera. The solution is to instead remove the cubemap from the scene before updating the cube camera, and add it back after updating the cube camera, before the main render. Not super-elegant, but I don’t know of any better solution when using built-in materials. If using ShaderMaterial, you can try to share a Uniform instance for the texture, and modify only that.
Also, I moved the cubecamera and increased its near
so that it captures the plane and other pot, rather than half the inside of the pot. The other pot will in principle need a separate cube camera to get the right environment map, though.
(the Box3 and AxesHelper are not used anymore. I only created them to find out where to locate the cube camera and to tone the near clipping planes)
wow thank you so much sir, I learned a lot
however the fps drops like crazy and I can see [Violation] 'requestAnimationFrame' handler took <N>ms
increased a lot.
May I ask you why? Thank you sir.
Maybe we trigger material recompiles, or maybe the envmap is too big. I don’t know. I don’t have time now either, sorry. But I’m glad to have helped.
If material recompiles are the problem, it will perhaps help to use a dummy CubeTexture instead of null
.