Why is this simple (I think?) program flickering?

Hi @sourmike ! Welcome to the forum :slight_smile:

I had that same issue in the past. The issue is that most drawing operations are optimized for 2D, not for 3D. The current options for combining fills with contours in 3D are limited. Some places to look into 3D drawing are

I鈥檒l post again if I have an example to run.

btw. I tweaked your code to show some helper functions:

imports
import org.openrndr.application
import org.openrndr.color.ColorRGBa
import org.openrndr.draw.DepthTestPass
import org.openrndr.draw.isolated
import org.openrndr.extras.color.presets.DARK_SEA_GREEN
import org.openrndr.extras.color.presets.DIM_GRAY
import org.openrndr.extras.color.presets.SEA_GREEN
import org.openrndr.math.Polar
import org.openrndr.math.Vector2
import org.openrndr.math.Vector3
import org.openrndr.math.asDegrees
import org.openrndr.shape.Rectangle
import org.openrndr.shape.ShapeContour
fun main() = application {
    configure {
        width = 800
        height = 800
    }
    program {
        val ratioAS = 0.866
        val apothem = 100.0
        val rect = Rectangle.fromCenter(
            Vector2.ZERO, apothem / ratioAS, 80.0
        )
        val strokeW = 5.0
        val triangleWidth = rect.width - strokeW
        val tri = ShapeContour.fromPoints(
            listOf(
                Vector2(-triangleWidth / 2, 0.0),
                Vector2(triangleWidth / 2, 0.0),
                Vector2(0.0, 200.0)
            ), true
        )

        extend {
            drawer.apply {
                clear(ColorRGBa.DIM_GRAY)
                depthWrite = true
                depthTestPass = DepthTestPass.LESS_OR_EQUAL
                stroke = ColorRGBa.DARK_SEA_GREEN
                strokeWeight = strokeW
                fill = ColorRGBa.SEA_GREEN
                perspective(90.0, 1.0, 1.0, -300.0)
                translate(0.0, 0.0, -400.0)
            }

            val tempo = seconds * 0.5

            repeat (6) { num ->
                val angle = tempo.asDegrees + 60 * num
                val tr = Polar(angle, apothem).cartesian
                drawer.isolated {
                    translate(tr.y, 0.0, tr.x)
                    rotate(Vector3.UNIT_Y, angle)
                    rectangle(rect)

                    translate(0.0, (rect.height + strokeW) / 2.0);
                    rotate(Vector3.UNIT_X, -28.0)
                    contour(tri)
                }
            }
        }
    }
}
1 Like