I got a strange behavior since Xcode 4.5 and the iOS 6 SDK when using textures on my 3D objects. The problem also appears on my mac application when building against OS X 10.8 SDK.
I am using OpenGL ES 2.0 on iOS and OpenGL legacy profile ( < 3.0 ) on OS X 10.8.
The textures are not placed at there correct coordinates anymore and i have lots of artifacts. The VAOs are correctly uploaded and they look good without texturing. When using XCode 4.4.1 and iOS 5.1 SDK everything is fine.
The VAO is exactly the same (checked with OpenGL ES frame capture) and also the texture uniforms are binded correct.
Xcode 4.4 VAO Overview
Xcode 4.5 VAO Overview
XCode 4.4.1 (iOS 5.1 SDK)
XCode 4.5 (iOS 6 SDK)
Code / Shader Snippet
Relevant parts for uploading and processing the texture. I had to strip the shaders to the minium.
Vertex shader
precision highp float;
attribute vec2 a_vTextureCoordinate;
uniform mat4 u_mModelViewMatrix;
uniform mat4 u_mModelViewMatrixInverse;
uniform mat4 u_mProjectionMatrix;
uniform mat4 u_mNormalMatrix;
void main()
{
....
// Transform output position
gl_Position = u_mProjectionMatrix * u_mModelViewMatrix * a_vPosition;
// Pass through texture coordinate v_texcoord = a_vTextureCoordinate.xy;
v_vPosition = vec3(u_mModelViewMatrix * a_vPosition);
v_vTextureCoordinate = a_vTextureCoordinate.xy;
....
}
Fragment Shader
precision highp float;
// location 1
uniform sampler2D u_diffuseTexture;
varying vec2 v_vTextureCoordinate;
varying vec3 v_vPosition;
....
void main() {
....
vec4 base = texture2D(u_diffuseTexture, v_vTextureCoordinate);
gl_FragColor = base;
....
}
Texture loading
NSDictionary *options = @{GLKTextureLoaderOriginBottomLeft: @(YES), [NSNumber numberWithBool:YES] : GLKTextureLoaderGenerateMipmaps};
NSError *error;
path = [path stringByReplacingOccurrencesOfString:@"/" withString:@""];
path = [[NSBundle mainBundle] pathForResource:[path stringByDeletingPathExtension] ofType:[path pathExtension]];
GLKTextureInfo *texture = [GLKTextureLoader textureWithContentsOfFile:path options:options error:&error];
Render loop (Only sending the uniform of the active texture)
....
[self setShaderTexture:[[materials objectForKey:@"diffuse"] objectForKey:@"glktexture"]
forKey:@"u_diffuseTexture"
withUniform1i:0
andTextureUnit:GL_TEXTURE0+0];
....
#pragma mark - Texture communication
-(void)setShaderTexture:(GLKTextureInfo*)texture forKey:(NSString*)key withUniform1i:(int32_t)uniform andTextureUnit:(int32_t)unit {
glActiveTexture(unit);
glBindTexture(texture.target, texture.name);
[self.shaderManager sendUniform1Int:key parameter:uniform];
}
Had anyone a close problem to mine since iOS 6?