<p>Your premise is mistaken. The <code>convexity</code> property is only useful (and in fact only available) for object types where the CSG engine doesn't already know the geometry: <code>linear_extrude</code>, <code>rotate_extrude</code>, <code>import</code>ed STLs, and maybe a few other obscure things. What it does is tell the preview rendering engine the number of times a ray through the object might intersect faces facing the camera. If it's too low, rendering may stop after that low number, causing missing surfaces.</p>
<p>What you're seeing is clashing rendering from a zero-thickness part, where the difference has coincident surfaces and which ones overrides flips with numerical instability. The way to fix this is to have the subtracted body always extend <em>past</em> the body you're subtracting from, not exactly to its surface.</p>

CC BY-SA 4.0
2024-08-04T02:32:08.393Z
2024-08-04T02:32:08.393Z
R.. GitHub STOP HELPING ICE
<p>If I do a simple boolean difference where the dimensions of two shapes match there are visual artifacts in the preview. For example:</p>
<pre><code>difference() {
    cube(10, center=true);
    cylinder(10, 5, 5, center=true); 
}
</code></pre>
<p>Previews like:</p>
<p><a href="https://i.sstatic.net/LpCMSrdr.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/LpCMSrdr.png" alt="preview with artifact" /></a></p>
<p>If I do a full render it comes out as intended:
<a href="https://i.sstatic.net/wjEQhMgY.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/wjEQhMgY.png" alt="full render" /></a></p>
<p>I have read about convexity, and it seems that properly setting it would tell the preview renderer what it needs to render more accurately. Can I use convexity to solve this problem?</p>

<cad><openscad><convexity><rendering>
Can I use convexity in OpenSCAD to fix artifacts in the preview?
linuxdan
# Can I use convexity in OpenSCAD to fix artifacts in the preview?

(Asked by: username_0 on 2024-08-03)

If I do a simple boolean difference where the dimensions of two shapes match there are visual artifacts in the preview. For example:
difference() {
    cube(10, center=true);
    cylinder(10, 5, 5, center=true); 
}

Previews like:

If I do a full render it comes out as intended:

I have read about convexity, and it seems that properly setting it would tell the preview renderer what it needs to render more accurately. Can I use convexity to solve this problem?

**Tags:** cad, openscad, convexity, rendering

---

## 1 answers

### Answer by username_1 on 2024-08-04. Score: 2

Your premise is mistaken. The `convexity` property is only useful (and in fact only available) for object types where the CSG engine doesn't already know the geometry: `linear_extrude`, `rotate_extrude`, `import`ed STLs, and maybe a few other obscure things. What it does is tell the preview rendering engine the number of times a ray through the object might intersect faces facing the camera. If it's too low, rendering may stop after that low number, causing missing surfaces.

What you're seeing is clashing rendering from a zero-thickness part, where the difference has coincident surfaces and which ones overrides flips with numerical instability. The way to fix this is to have the subtracted body always extend *past* the body you're subtracting from, not exactly to its surface.


---

