x3dx3dom

x3d blending textures transparent


I want to blend two textures, each with specified opacity, follwing is my imaginary code. (no surprise it won't work)

<appearance>
    <ImageTexture url="texture1.jpg" opacity="0.7"></ImageTexture>
    <ImageTexture url="texture2.jpg" opacity="0.3"></ImageTexture>
</appearance>

Looks like it might have something to do with MultiTexture or BlendMode, but I haven't figure out how it works yet.


Solution

  • I just realize an appearance node can have both texture and material properties at the same time, so the following works perfectly fine to me.

    <shape>
      <sphere></sphere>
      <appearance>
        <ImageTexture url="texture1.jpg"></ImageTexture>
      </appearance>
    </shape>
    
    <shape>
      <sphere></sphere>
      <appearance>
        <material transparency="0.3"></material>
        <ImageTexture url="texture2.jpg"></ImageTexture>
      </appearance>
    </shape>