Mathematica 12.1 introduced a number of amazing shaders such as StippleShading.

Is there a way to control the grain size of StippleShading?

On a standard resolution screen it looks like this:

enter image description here

On a retina screen, the stippling is much finer:

You can experiment with this using the following:

gr = Graphics3D[{StippleShading[], Sphere[]}, Boxed -> False, Lighting -> "Accent"];
Manipulate[Rasterize[gr, ImageResolution -> 30*10^res], {res, 0, 1}]

The higher the resolution, the finer the stippling. With very high resolutions, the stippling is not visible anymore.

When exporting graphics for publication, one often needs to use high resolution (300 dpi minimum) so that lines, which are a common feature of stippled art, would also look good. But using an appropriately high resolution for print will make the stippling invisible in print, defeating the purpose of stipple shading.

This is why I am looking for a way to control the stipple size.

Example drawing which has both lines (for which high resolution is a must when printing) and stippling:

Graphics3D[{{StippleShading[], Sphere[]}, {Thick, Black, 
   Line[1.7 {{{-1, 0, 0}, {1, 0, 0}}, {{0, -1, 0}, {0, 1, 0}}, {{0, 
        0, -1}, {0, 0, 1}}}]}}, Boxed -> False, Lighting -> "Accent"]

enter image description here

  • 4
    $\begingroup$ Looks like with shift-cmd-e we can change "Tiling" -> {2, 2} to "Tiling" -> {t, t} to get different sizes. $\endgroup$ – Chip Hurst Apr 8 '20 at 13:56
  • 1
    $\begingroup$ @ChipHurst Did you find a way to toggle that without messing with boxes? Even if not, this should be an answer. $\endgroup$ – Szabolcs Apr 9 '20 at 10:31
  • $\begingroup$ @ChipHurst Please post that as an answer if possible. $\endgroup$ – Szabolcs May 11 '20 at 15:04

If we examine the box structure of the output with shift-cmd-e, we can change the value "Tiling" points to.

For the input

Graphics3D[{StippleShading[], Sphere[]}, Boxed -> False, Lighting -> "Accent"]

it's output has boxes

enter image description here

Here's a few choices:

enter image description here


It looks like we can use the box structure in the initial call:

stipple = SurfaceAppearance["RampShading", 
  "StepCount" -> 10, "Tiling" -> {1, 1}, 
  "UseScreenSpace" -> 1, "FeatureColor" -> GrayLevel[0], 
  "IsTwoTone" -> 1, "LuminanceModifier" -> 0.5, 
  "Arguments" -> {"StippleShading", 0.5, Automatic}, 

Graphics3D[{stipple, Sphere[]}, Boxed -> False, Lighting -> "Accent"]


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.