GL shader in SceneKit

Hi,


I'm trying to bind a simple GL shader in SceneKit. I have shaders that get called but can't seem to bind the texture coordinates. This is what I have for the texture binding:


program.setSemantic(SCNModelViewProjectionTransform, forSymbol: "modelViewProjection", options: nil)

program.setSemantic(SCNGeometrySource.Semantic.vertex.rawValue, forSymbol: "position", options: nil)

program.setSemantic(SCNGeometrySource.Semantic.texcoord.rawValue, forSymbol: "textureCoordinate", options: nil)


material.handleBinding(ofSymbol: "blobTexture", handler: { (programId:UInt32, location:UInt32, node:SCNNode?, renderer:SCNRenderer) in

let imagePath = Bundle.main.path(forResource: "checkerboard", ofType: "png")!

if let cgiImg = UIImage(contentsOfFile: imagePath)?.cgImage {

do {

let _ = try GLKTextureLoader.texture(with: cgiImg, options: nil)

// glBindTexture(GLenum(GL_TEXTURE_2D), texture.name)

glUniform1i(GLint(location), 1)

} catch {

print("Texture not loaded", (error))

}

}

})


Should I use glUniform1i instead of glBindTexture? glBindTexture doesn't seem to work. When I use glUniform the model is the color from a single texel.


These are the shaders:


uniform sampler2D blobTexture;

varying vec2 texCoord;


void main(void) {

gl_FragColor = texture2D(blobTexture, texCoord);

}


and


precision mediump float;


attribute vec4 position;

attribute vec2 textureCoordinate;

uniform mat4 modelViewProjection;


varying vec2 texCoord;


void main(void) {

texCoord = textureCoordinate;

gl_Position = modelViewProjection * position;

}