-2

I am using SceneKit and I hate the resolution of the geometry. I read developer documentation and other websites. I found an article on the developer documentation. It gave me this image:

Apples image

But couldn't find any information how to do that, only another stupid article on the developer documentation. I really need a higher resolution – it should be smoothed.

My geometry renders by default

Is there some one how can help me with this problem?

Andy Jazz
  • 49,178
  • 17
  • 136
  • 220
Michael
  • 185
  • 1
  • 11
  • 2
    Is that a `SCNTorus`? If so you should increase `ringSegmentCount` and `pipeSegmentCount` to make it "smoother". If it is your own model, then of course *you* are responsible for making it more high-poly. – Sweeper Apr 17 '22 at 15:50
  • Yes, it is an **SCNTorus**, but I want to make a better resolution for every geometry. – Michael Apr 17 '22 at 15:56
  • 1
    The built-in geometries all have `xxxSegmentCount` properties that you can set. Look at their respective documentation pages for more detail. Does that answer your question? – Sweeper Apr 17 '22 at 15:59
  • I have got one more question: I couldn't find any xxxSegmentCount in SCNText. – Michael Apr 17 '22 at 16:11
  • 1
    I think `SCNText` automatically uses a more detailed geometry when you zoom in, doesn't it? – Sweeper Apr 17 '22 at 16:15
  • Since OP is asking for explanations: I downvoted because OP didn’t seem to put any effort into understanding how 3D models work or even look at the SCNTorus class reference. – EmilioPelaez Apr 17 '22 at 17:08
  • Sorry, @EmilioPelaez but I didn't understand those properties, and I am not good at searching something in google. My English is really bad, too. And I am bad in swift, because I can write code only after school. – Michael Apr 17 '22 at 18:01
  • And you are right, sweeper. – Michael Apr 17 '22 at 18:04

3 Answers3

2

All the built-in shape geometries have xxxSegmentCount properties. You can increase them to make them smoother. Here's a summary table:

Shape segmentCount properties
SCNPlane widthSegmentCount, heightSegmentCount, cornerSegmentCount
SCNBox widthSegmentCount, heightSegmentCount, lengthSegmentCount, chamferSegmentCount
SCNSphere segmentCount
SCNPyramid widthSegmentCount, heightSegmentCount, lengthSegmentCount
SCNCone radialSegmentCount, heightSegmentCount
SCNCylinder radialSegmentCount, heightSegmentCount
SCNCapsule radialSegmentCount, heightSegmentCount, capSegmentCount
SCNTube radialSegmentCount, heightSegmentCount
SCNTorus pipeSegmentCount, ringSegmentCount

You can't control the segment counts for SCNText and SCNShape, however. Their polygon counts are controlled by SceneKit, but it should always be high enough no matter how zoomed in you are. You shouldn't need to worry about this.

Additional note: The levelOfDetail you found is for setting different geometries to use (perhaps with different segment counts) when the camera is a different distance away from the object, to improve performance.

Sweeper
  • 213,210
  • 22
  • 193
  • 313
1

If you've loaded low-poly .dae or .obj models like Utah teapot, you should use the antialiasing mode instance property for smoothing faceted surfaces. You can choose between 4 samples per screen pixel, 2 samples, or none. This will help you load more models, while being smoothed, and not exceed 100K polygons limit.

var antialiasingMode: SCNAntialiasingMode { get set }

SceneKit can provide antialiasing, which smooths edges in a rendered scene, using a technique called multisampling. Multisampling renders each pixel multiple times and combines the results, creating a higher quality image at a performance cost proportional to the number of samples it uses.

Real code looks like this:

let sceneView = SCNView(frame: .zero)

sceneView.antialiasingMode = .multisampling4X

This is a pivot table showing values that available in macOS and iOS.

|               macOS                |                iOS               |
|------------------------------------|----------------------------------|
|  .none                             |  .none               (default)   |
|  .multisampling2X                  |  .multisampling2X                |
|  .multisampling4X  (default)       |  .multisampling4X                |
|  .multisampling8X                  |  -                               |
|  .multisampling16X                 |  -                               | 
Andy Jazz
  • 49,178
  • 17
  • 136
  • 220
0

Depending on the geometry you have, you can sub-divide it on the fly.

i.Ex:

node.geometry?.subdivisionlevel = 2

If your initial geometry is of "good" quality, the result can be astunishing. Give it a try.

Note: it will quadruple your vertices with each incrementation of the sudivision integer. A value of 2 will give you 16 times more vertices than the original geometry contains. This also impacts the memory!

ZAY
  • 3,882
  • 2
  • 13
  • 21