You can redefine shader programs by creating SCNProgram material for this. Then, in one of the delegate methods for SCNProgramDelegate you can bind your own values for the texture (and other uniforms). However, you will write your own shaders.
There are few options if you are used to Objective-C, but it really isn’t that much if you think about the appropriate OpenGL code.
The following is an example of a shader program that associates a texture with the surface of a geometry object. For simplicity, it does not do any shading with normals and light sources.
Note that I don’t know how you want to bind your specific texture, so in the code below I read png using GLKit and use this texture.
In this example, shaders are written as
and
Finally, the implementation of the method ...bindValueForSymbol:... to bind the texture to the "yourTexture" format.
- (BOOL) program:(SCNProgram *)program bindValueForSymbol:(NSString *)symbol atLocation:(unsigned int)location programID:(unsigned int)programID renderer:(SCNRenderer *)renderer { if ([symbol isEqualToString:@"yourTexture"]) {
In addition, for debugging purposes, it is very useful to implement program:handleError: to print any shader compilation errors
- (void)program:(SCNProgram*)program handleError:(NSError*)error {
source share