SceneKit Point Rendering not working

I've been trying to render some point clouds for the last few days, and I've gone through various examples and I'm pretty sure I got things right but nothing seems to work as of iOS 11 I think, or at least all the examples I find are around 2 years old and nothing after that. I've become convinced it's just broken, as github project and stack overflow questions that were at one point correct no longer work.


This is a quick and dirty example in a view controller, pretty much the same as other examples. The scenekitview property just ties to a scnview. I'm trying to render in metal, but opengl doesn't work either.


#import 
#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    SCNScene *scene = [SCNScene new];
    SCNNode *cameraNode = [SCNNode new];
    cameraNode.camera = [SCNCamera new];
    cameraNode.camera.zNear = 0.0;
    cameraNode.camera.zFar = 40.0;
    [scene.rootNode addChildNode:cameraNode];
    cameraNode.position = SCNVector3Make(6.0, 1.5, 15.0);
    [cameraNode lookAt:SCNVector3Make(6.0, 1.5, 0.5)];
    [scene.rootNode addChildNode:[self pointCloudNode]];
    self.sceneKitView.showsStatistics = YES;
    self.sceneKitView.scene = scene;
    self.sceneKitView.pointOfView = cameraNode;
   
}

- (NSData*)pointCloudData {
    NSMutableData *data = [NSMutableData data];
    float values[] = {
        12.0, 2.0, 1.0, 1.0, 0.0, 0.5,
        11.0, 1.9, 0.9, 0.9, 0.1, 0.4,
        10.0, 1.8, 0.8, 0.8, 0.2, 0.3,
        9.0, 1.7, 0.7, 0.7, 0.3, 0.4,
        8.0, 1.6, 0.6, 0.6, 0.4, 0.5,
        7.0, 1.5, 0.5, 0.5, 0.5, 0.6,
        6.0, 1.4, 0.4, 0.4, 0.6, 0.6,
        5.0, 1.3, 0.3, 0.3, 0.7, 0.7,
        4.0, 1.2, 0.2, 0.2, 0.8, 0.8,
        3.0, 1.1, 0.1, 0.1, 0.9, 0.9,
        2.0, 1.0, 0.0, 0.0, 1.0, 1.0
    };
    for (int i = 0; i < 11 * 6; i = i + 6) {
        PointCloudStruct pcs;
        pcs.x = values[i];
        pcs.y = values[i+1];
        pcs.z = values[i+2];
        pcs.r = values[i+3];
        pcs.g = values[i+4];
        pcs.b = values[i+5];
        [data appendBytes:&pcs length:sizeof(pcs)];
    }
    return data;
}

- (SCNNode *)pointCloudNode {
    NSData *data = [self pointCloudData];
    SCNGeometrySource *vertices = [SCNGeometrySource geometrySourceWithData:data
                                                                   semantic:SCNGeometrySourceSemanticVertex
                                                                vectorCount:11
                                                            floatComponents:YES
                                                        componentsPerVector:3
                                                          bytesPerComponent:sizeof(float)
                                                                 dataOffset:offsetof(PointCloudStruct, x)
                                                                 dataStride:sizeof(PointCloudStruct)];
   
    SCNGeometrySource *colours = [SCNGeometrySource geometrySourceWithData:data
                                                                  semantic:SCNGeometrySourceSemanticColor
                                                               vectorCount:11
                                                           floatComponents:YES
                                                       componentsPerVector:3
                                                         bytesPerComponent:sizeof(float)
                                                                dataOffset:offsetof(PointCloudStruct, r)
                                                                dataStride:sizeof(PointCloudStruct)];

    SCNGeometryElement *elements = [SCNGeometryElement geometryElementWithData:nil
                                                                 primitiveType:SCNGeometryPrimitiveTypePoint
                                                                primitiveCount:11
                                                                 bytesPerIndex:sizeof(int)];
   
    elements.pointSize = 1.0;
    elements.minimumPointScreenSpaceRadius = 1.0;
    elements.maximumPointScreenSpaceRadius = 5.0;
    SCNGeometry *geometry = [SCNGeometry geometryWithSources:@[vertices, colours] elements:@[elements]];

    return [SCNNode nodeWithGeometry:geometry];
}

@end


I've tried adding shaders using SCNProgram on the SCNGeometry but that doesn't seem to do anything. Setting the geometry element data didn't help either.


One unusual thing, when showing the stats on the scnview, it shows over 2.7k vertices, that can't be right....


Most of the code is straight ported to obj-c from here https://github.com/eugeneu/PoindCloudRenderer


There are other examples too around.


Is there something obvious (or not so obvious) wrong that I've missed?

Missed off the struct I'm using:

typedef struct {
    float x, y, z;
    float r, g, b;
} PointCloudStruct;

I finaly got a point cloud to work using a pure metal implementation with MTLPrimitiveTypePoint, a lot of work for someone starting out in metal.

SceneKit Point Rendering not working
 
 
Q