2 Replies Latest reply on Aug 14, 2006 5:25 AM by Jez Cheesman

    Multiple texture layers

    Jez Cheesman
      I've been using Director for years, but am new to 3D.

      I have a plane, that the user dynamically swaps textures on using:
      -- member("Scene2").deleteTexture("planeTexture")
      -- member("Scene2").newTexture("planeTexture", #fromCastmember, member("3D_texture"))
      -- member("Scene2").shader("planeShader").texture = MEMBER("SCENE2").texture("planeTexture")
      (I load the chosen texture from a file into cast member "3D_texture")

      The above shows the users "driveway" I am now trying to add another texture layer, which will be a bitmap of a patterned circle: a square png with a circular alpha channel) so the user can move it around to see where on their driveway they'd like it

      see photoshop mockup:

      " http://trgs.net/client/pic_for_help.jpg"

      the outcome will show my base texture (from the lines of code above) and a circle on top of that texture that the user can move, so the perspective will automatically adjust as they move it around the plane.

      But I can't get the second texture to work, I've tried things like:

      -- member("Scene2").newTexture("Circle2texture",#fromCastmember, member("circle2"))
      -- member("Scene2").model("plane").addModifier(#meshDeform)
      -- member("Scene2").model("plane").meshdeform.mesh[2].texturelayer.add("Circle2texture")

      but the whole object just goes pink!

      am i trying to do something that can't be done?

      all help greatfully recieved (the client wants it on tuesday!)

        • 1. Re: Multiple texture layers
          tedalde2 Level 2
          The easiest thing might be to just create another plane with another texture on top. Otherwise, just use the shader's texturelist[ ] property to do the work and disregard #meshDeform.

          Set the texturelist[1] of your shader to the driveway bricks, then shader's texturelist[2] to your texture with the alpha. Then set shader's blendFunctionList[2] to #blend, and blendsourceList[2] to #alpha.

          Your alpha texture will then be a "decal" on top of the bricks texture. You can then move the decal texture around using textureTransfromList[2].position. But make sure your alpha has enough "whitespace" on the edges, else you'll get streaking.

          ** Important to note that the renderer will affect how this looks. I think the above description is good with directX but if using openGL you may need to use blendsourceList[2] = #constant and blendConstantList[2] = 100.
          • 2. Re: Multiple texture layers
            Jez Cheesman Level 1
            tedalde2 you're a star

            it works like a dream, (except for the transformList[2].position command, which makes the circle disappear - see my post this morning)

            any ideas?