I'm trying to convert OGL ES 1.1. code to GLKit. GLKit offers a pair of texture slots:
- texture2d0
- texture2d1
Each texture has an env mode:
- GLKTextureEnvModeReplace,
- GLKTextureEnvModeModulate,
- GLKTextureEnvModeDecal
Normally, you leave texture2d1 blank, and just set texture2d0. I assumed - from reading Apple's docs - that 2d1 was for blending/combining/modifying textures. Since GLKit is "merely" sitting on top of shaders, and it's standard for each shader to have a pair of texture slots - the "incoming" slot representing what's already on the material, and the "modification" slot representing the stuff that the shader is going to use as parameter to modiffy the material.
But that doesn't seem to work.
I tried:
self.baseEffect.texture2d0.envMode = GLKTextureEnvModeReplace;
self.baseEffect.texture2d0.target = GLKTextureTarget2D;
self.baseEffect.texture2d0.name = [earthTextureDefault name];
self.baseEffect.texture2d1.envMode = GLKTextureEnvModeModulate;
self.baseEffect.texture2d1.target = GLKTextureTarget2D;
self.baseEffect.texture2d1.enabled = TRUE;
self.baseEffect.texture2d1.name = [textureClouds name];
...and all I got was a black non-texture. Either texture, placed into 0 (with nothing in 1), works fine. The second texture is shaded alpha-to-white, where the first texture is all opaque, but with a fairly rich pallette.
What I'd really like to do is start applying dynamicly-generated / updated blends, efficiently. e.g.:
- load a base texture
- load a second texture
- load a blend-mask that blends between them
- ...update the blend-mask frame-by-frame. Without having to re-upload the first two textures
NB: I'm not looking to throw-away GLKit and write custom shaders for this instead. I want to understand how GLKit works - and by the looks of things it should be a LOT easier to maintain for simple things like this than if I go around writing a bunch of shaders.