Stroke Width with a SceneKit line primitive type

后端 未结 2 772
没有蜡笔的小新
没有蜡笔的小新 2020-12-05 12:04

I am trying to replicate this cube image shape (with permission from the original creator) using scene kit.

\"en

相关标签:
2条回答
  • 2020-12-05 12:38

    SceneKit doesn't provide controls for this. However, SceneKit draws using OpenGL ES, which does.

    When you're drawing with GL in the GL_LINES mode, the glLineWidth call changes the line width. (Watch out: the argument is in actual pixels, not UI-layout points, so you'll need a larger width than you might think if you don't want super-thin hairlines on a Retina display.)

    So, where do you call that in your SceneKit app? You have a few options there. In a simple scene like yours, where you're only rendering one thing, you can just set it before the scene renders. Set a delegate for your view, then implement renderer:willRenderSceneAtTime: and call glLineWidth there.

    However, OpenGL line rendering is pretty limited — if you want to customize rendering more, you'll need a different approach. Just which approach works best depends on exactly what you're going for, so here are a few ideas for you to research:

    • Make your "lines" from narrow triangle strips
    • Make them from primitive SCN geometries like boxes and cylinders
    • Keep a simple cube geometry, but use a fragment shader (or shader modifier snippet) to draw only near the edges of each polygon
    0 讨论(0)
  • 2020-12-05 12:42

    You can use glLineWidth to set the line width.
    Make sure to include OpenGLES in your project.

    Line Width 8

    Here's how your cube looks like with line width set to 8.

    0 讨论(0)
提交回复
热议问题