MathGroup Archive 2011

[Date Index] [Thread Index] [Author Index]

Search the Archive

Transparent textures from images

  • To: mathgroup at smc.vnet.net
  • Subject: [mg123362] Transparent textures from images
  • From: Patrick Scheibe <pscheibe at trm.uni-leipzig.de>
  • Date: Sat, 3 Dec 2011 04:14:01 -0500 (EST)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com

Hi,

I sent this already to Wolfram, but maybe someone wants to try this on a
windows machine.
Starting from an image with alpha-channel

data = Table[{Sin[x], Sin[y], 1, Sin[x y]}, {y, 0, 2 Pi, 
    2 Pi/127.}, {x, 0, 2 Pi, 2 Pi/127.}];
img = Image[data, ColorSpace -> "RGB"]
AlphaChannel[img]

When I use this now as texture on a cube, I expect the walls to be
transparent according to the alpha-channel

vtc = {{0, 0}, {1, 0}, {1, 1}, {0, 1}};
coords = {{{0, 0, 0}, {0, 1, 0}, {1, 1, 0}, {1, 0, 0}}, {{0, 0, 
     0}, {1, 0, 0}, {1, 0, 1}, {0, 0, 1}}, {{1, 0, 0}, {1, 1, 0}, {1, 
     1, 1}, {1, 0, 1}}, {{1, 1, 0}, {0, 1, 0}, {0, 1, 1}, {1, 1, 
     1}}, {{0, 1, 0}, {0, 0, 0}, {0, 0, 1}, {0, 1, 1}}, {{0, 0, 
     1}, {1, 0, 1}, {1, 1, 1}, {0, 1, 1}}};
Graphics3D[{Texture[img], 
  Polygon[coords, VertexTextureCoordinates -> Table[vtc, {6}]]}, 
 Boxed -> False]

This does not work here. I get a cube with a white painting where it
should be transparent. Using the pure {r,g,b,a} data I get the right
result:

Graphics3D[{Texture[data], 
  Polygon[coords, VertexTextureCoordinates -> Table[vtc, {6}]]}, 
 Boxed -> False]

Can someone check this or give me a hint which part I understood wrong?

Cheers
Patrick




  • Prev by Date: Plot Legends For Side By Side Graphs
  • Next by Date: Re: how to get string in sci. notation to a number?
  • Previous by thread: Re: Plot Legends For Side By Side Graphs
  • Next by thread: Re: Transparent textures from images