0

Let's say we have a black and white Shader on a sphere. Is it possible to use it as an alphaMap on a MeshPhongMaterial for another sphere?

Can we use a ShaderMaterial as an alphaMap of a MeshPhongMaterial, like we use a MeshPhongMaterial.map for an alphaMap?

VΛVΛV
  • 93
  • 1
  • 11
  • Yes you can. https://threejs.org/docs/#api/en/materials/MeshPhongMaterial.alphaMap – M - Aug 05 '22 at 17:44
  • Nope, MeshPhongMaterial does not accept ShaderMaterial as alphaMap. Atleast on my tests. – VΛVΛV Aug 05 '22 at 19:26
  • Right. You need to render your shader to a `RenderTarget`. then use the `RenderTarget.texture` as the input texture to your alphaMap. That's the essence [of this demo](https://threejs.org/examples/#webgl_rtt). – M - Aug 05 '22 at 20:42
  • That looks promising! Thank you for pointing me to the right direction! – VΛVΛV Aug 06 '22 at 07:29
  • So yeah, I first unwrapped the sphere using this: http://stemkoski.github.io/Three.js/Sphere-Unwrapping.html and now I am gonna get the texture as alphamap. – VΛVΛV Aug 06 '22 at 09:55
  • Unwrapped and captured in WebGLRenderTarget in a buffer scene, helpful code for that https://codepen.io/tutsplus/pen/eJGzzK – VΛVΛV Aug 06 '22 at 15:54

0 Answers0