pmndrs / lamina

🍰 An extensible, layer based shader material for ThreeJS
MIT License
1.01k stars 41 forks source link

LayerMaterials: With Base baked in, transparency should be the default and can be deterministic #9

Closed DennisSmolek closed 2 years ago

DennisSmolek commented 2 years ago

If we bake in the base as mentioned in #8 there's no need to call transparent. You still could I guess, just to be 100% sure or if you planned on adjusting the other values later.

But if you place a color in base:

 <LayerMaterial>
    <Base color="#603295" />
</LaterMaterial>

or by #8 :

<LayerMaterial color="#603295">

There's no alpha set so it is 100% opaque

where this becomes confusing is actually on the inverse:

 <LayerMaterial>
    <Base color="#603295" alpha=".5" />
</LaterMaterial>

You would think that layer is 50% see through (opaque) but it's not...

Transparent maps to the material, while base and alpha map to the material color map..

I have NO IDEA what this would do..

//simplified from @Fasani Blob experiment
<mesh>
  <sphereGeometry args={[0.8, 128, 128]} />
  <LayerMaterial>
    <Base color="#603295" />
          {...}
  </LayerMaterial>
</mesh>
<mesh ref={glow} scale={0.6} visible={showGlow}>
    <circleGeometry args={[2, 16]} />
    <LayerMaterial depthWrite={false} side={THREE.FrontSide} blending={THREE.AdditiveBlending}>
        {...}
    </LayerMaterial>
</mesh>

In that instance the user accidentally left of the transparent value on glow. Now, because the blending mode isnt the default we know we're supposed to be transparent..

TLDR: based on input props we can assume the intended transparency value

Transparency on meshStandardMaterial in Three.js doscs

FarazzShaikh commented 2 years ago

If I understand correctly, you mean to say, we should set the transparent flag on the material if any alpha other than 1 is used in any of the layers?

Yep we could do that

FarazzShaikh commented 2 years ago

Addressed in 1.1.0