Message Boards Message Boards

Exporting Graphics3D with no Antialiasing (Windows vs Mac)

Posted 3 years ago

I want to export 3D graphics (a graphics complex) with no Antialiasing. The following code works perfectly on Mac.

img = Rasterize[
  Style[Graphics3D[{Antialiasing -> 
      False, {{Glow[Green], Sphere[{0, 0, 1.5}, 0.35]}, {Glow[Yellow],
        Sphere[{0, 0, 1}, 0.5]}, {Glow[Red], 
       Sphere[{0, 0, 0.5}, 0.35]}}}, PlotRangePadding -> None, 
    Boxed -> False, Lighting -> None, ImageSize -> 100], 
   RenderingOptions -> {"3DRenderingEngine" -> "OpenGL", 
     "HardwareAntialiasingQuality" -> 0}], RasterSize -> 100, 
  ImageResolution -> 100]
Flatten[ImageData[img], 1] // Tally

The tally of the image colors is as expected only 4 colors: Red, Green, Yellow, and White. However, on a Windows 10 machine, using a similar code, I can not enforce the no-AntiAliasing. The tally of the colors in the image gives more than the expected four colors.

img = Rasterize[
  Style[Graphics3D[{Antialiasing -> 
      False, {{Glow[Green], Sphere[{0, 0, 1.5}, 0.35]}, {Glow[Yellow],
        Sphere[{0, 0, 1}, 0.5]}, {Glow[Red], 
       Sphere[{0, 0, 0.5}, 0.35]}}}, PlotRangePadding -> None, 
    Boxed -> False, Lighting -> None, ImageSize -> 100], 
   RenderingOptions -> {"3DRenderingEngine" -> "DirectX", 
     "HardwareAntialiasingQuality" -> 0}], RasterSize -> 100, 
  ImageResolution -> 100]
Flatten[ImageData[img], 1] // Tally

Any idea how to ensure that the code also works in Windows? Thanks

Elie

POSTED BY: Elie Shammas
8 Replies

You cannot specify "HardwareAntialiasingQuality"->0 locally. The only value that matters is the one at the global scope (i.e. the one in the Preferences dialog). All of the Antialiasing specs are superfluous as well.

POSTED BY: Ian Hojnicki

Did you try SVG instead? Graphics are easily imported into e.g. PowerPoint and Edge. Text and a filled Plot scale nicely. Downside: Plots 6x larger than JPEG and my ContourPlot files grow from 240KB to 34MB.

Which version do you try this? What happens on the hardware side is really hard to control. Even with all those rendering options.

I can not (on Mac) copy the behavior you see. i see also mixed colors, despite the antialiasing options.

POSTED BY: Sander Huisman

I had to explicitly run the following settings to get it to work in Mac:

method={"HardwareDepthBuffer","HardwareDepthPeeling","BSPTree","Software"};
method=method[[3]]
SetOptions[$FrontEndSession,RenderingOptions->{"Graphics3DRenderingEngine"->method}];
SetOptions[EvaluationNotebook[],RenderingOptions->{"Graphics3DRenderingEngine"->method}];
CurrentValue[$FrontEndSession,{"Antialiasing"}]=False;
CurrentValue[EvaluationNotebook[],{"Antialiasing"}]=False;
CurrentValue[$FrontEnd,{"Antialiasing"}]=False;

All other methods gave me still some antialiasing…

POSTED BY: Sander Huisman
Posted 3 years ago

Hi,

I tried these options, but it's still not working on Windows! Thanks

Elie

POSTED BY: Elie Shammas

did you try the methods 1 through 4 on line 2?

POSTED BY: Sander Huisman
Posted 3 years ago

Yes, all four methods did not work

POSTED BY: Elie Shammas
Posted 3 years ago

Hi, Thanks for the prompt response. I am using version 12.1.1.0 on MacBook pro 16". Here is my output on mac: enter image description here On Windows, I have version 12.1.0.0, and here is my output: enter image description here

POSTED BY: Elie Shammas
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract