MathGroup Archive 2012

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

Search the Archive

Textures with AlphaChannel not working on OS X system


I am running into some interesting problems when working with textures on 3D surfaces on my Mac OS X system.  First off, system specs of my test systems:
Mac System:
OS X 10.6.8
Intel Core Duo x86 (32-Bit)
ATI Radeon x1600
Mathematica 8.0.1 - 8.0.4

Windows System:
Windows 7 x64
Intel Core 2 Duo 3Ghz x64 (64-bit)
Nvidia 260
Mathematica 8.0.1

Everything seems to be working well on my PC, but on my mac, whenever there are textures involved, there seems to be problems.  Apple has made some changes that has caused a lot of compatibility issues with 32 bit systems and recent versions of applications, and this is what I suspect to be the cause of this, but I am not sure.

Basically, whenever there is a 3D surface that has a texture that has been converted to ImageData so that the alpha channels are respected when applied to the surface, the textured object won't show up when running on my mac.  Sometimes it will even result in an unrecoverable crash as soon as the textured object is on screen.

Is this a know bug?  Are there workarounds?

I included a program that illustrates this issue.  I did not write it, but it does not require any image data, so I figured it would work well for this medium.  Basically, on my PC, the text "This is a label" is shown.  On my mac, it does not show up. 

label3D[s_, pos_, xVec_, tiltAngle_, opts : OptionsPattern[]] :=
  Module[{ra, width, height, r},
   ra = Rasterize[
     Style[HoldForm[s], FilterRules[{opts}, Options[Style]],
      Magnification -> 10],
      Apply[Sequence, FilterRules[{opts}, Options[Rasterize]]]];
   {width, height} = ImageDimensions[ra];
   r = SetAlphaChannel[ra,
     With[{color =
          "TransparentColor" /. {opts} /. {"TransparentColor" ->
             Apply[RGBColor, ImageData[ra][[2, 2]]]}, "RGB"]]},
      Binarize[ra, (Norm[# - color] > .005) &]]];
   Translate[(* //to make lefthand corner pos*)
    Rotate[(*   //around z axis*)
     Rotate[(* //around y axis*)
      Rotate[(* //tilt around x axis*)
       Scale[(*//to make width equal|
        xVec|*){EdgeForm[FrameStyle /. {opts} /. FrameStyle -> None],
         Texture[ImageData@r],(* //
         Texture fills polygon initially in the xz plane*)
         Polygon[{{0, 0, 0}, {width, 0, 0}, {width, 0, height}, {0, 0,
          VertexTextureCoordinates -> {{0, 0}, {1, 0}, {1, 1}, {0,
             1}}]}, Norm[xVec]/width, {0, 0, 0}],
       tiltAngle, {1, 0, 0}],(* //x rotation*)
      Arg[Norm[xVec[[1 ;; 2]]] + I xVec[[3]]], {0, -1, 0}],(* //
     y rotation*)Arg[xVec[[1]] + I xVec[[2]]], {0, 0, 1}],(* //
    z rotation*)pos]];
SetAttributes[label3D, HoldFirst];

With[{position = {0, 0, 0}, direction = {1.5, 0, 1.3},
  tiltAngle = -.8},
    label3D["This is a label", position, direction, tiltAngle,
     FontColor -> Orange, FontSize -> 18, FontFamily -> "Helvetica",
     FontWeight -> Bold, Magnification -> 4,
     FrameStyle -> Directive[Purple, Thick]]}}, Boxed -> False,
  SphericalRegion -> True, Background -> Cyan]]

  • Prev by Date: Re: Dr. Lynchs book Dynamical Systems with Applications using Mathematica
  • Next by Date: Re: Real time sound processing?
  • Previous by thread: Re: maximize crosscorrelation
  • Next by thread: Re: Textures with AlphaChannel not working on OS X system