If you look at the following codepen, you’ll see a white, shiny "cup" which is a .glb
that been loaded in using Three’s GLTFLoader:
https://codepen.io/snakeo/pen/XWOoGPL
However, when I apply a texture on a portion of the mug the shiny cup turns into a dull and spotty cup:
You can apply the texture on the Codepen by uncommenting line 102:
// Create MeshPhongMaterial with the texture
const phongMaterial = new THREE.MeshPhongMaterial({
color: 0xFFFFFF, // White color for the ceramic look
shininess: 30, // Adjust shininess for the ceramic effect
specular: 0x222222, // Specular color
// map: texture // Apply the texture
});
The image only appears on the "face" of the cup.
I’m not sure why this transformation occurs. I’m kind of new to this and hoping for some guidance.
Thank you.
I’ve tried changing texture.wrapS
, texture.wrapT
and texture.repeat
with strange results, none of which cause the cup to be white and shiny again.
2
Answers
MeshPhongMaterial is not that great once once working with shiny or glassy materials, yes it is lighter for the GPU but may never look as good as you want!
So, other options are avilable, like MeshStandardMaterial. This one is quite amazing and not that heavy on the performance.
Yet, if you only need that cup, or simply a single object, then you may use MeshPhysicalMaterial. This one is way better with extra Clearcoat, Physically-based transparency, Advanced reflectivity, and Sheen.
Using textures on those material wont effect how shiny should they look like. If you really only want to use MeshPhongMaterial, for some reason, then see this example. Note: you can check the code by opening the inspector or search for the name of the file if you have the Three.js GitHub repo downloaded, like (#webgpu_lights_phong) in the examples directory. Note: the codepen attached wasn’t working for me for some reason, yet got what you meant and tried to help as much as I can!
Extra Useful Links
Best physical material example
Transparency in the Physical material
Using Physical Material in practice (YouTube)
Textures & Texture Mapping in Three.js (YouTube)
I assume you tried increasing
shininess
andspecular
, for example (shininess: 100
,specular: 0x444444
), but you are not satisfied.Did you try MeshStandardMaterial:
But I assume that you need for some reason
MeshPhongMaterial
, so try this approachYou can play with these values, I think you can easily get desired result.