howHow can I apply a texture over a material?
I've set up an object with the following material:
GLKBaseEffect *effect; effect.colorMaterialEnabled = false; effect.material.ambientColor = GLKVector4Make(251.0/255.0, 95.0/255.0, 96.0/255.0, 1.0); effect.material.diffuseColor = GLKVector4Make(251.0/255.0, 95.0/255.0, 96.0/255.0, 1.0); and it is correctly rendered with a pink color.
WhenHowever, when I apply a texture with:
GLKTextureInfo * info = [GLKTextureLoader textureWithCGImage:...]; effect.texture2d0.name = info.name; effect.texture2d0.enabled = true; the material seems to disappear and I just see the texture; the object is transparent where the texture is not visible, instead of being pink.
Any hint is really appreciated!
Thanks, DANHere's an example:
UPDATE: here's an example, theThe texture is created with the following code:
- (UIImage*)generateTexturefromText:(NSString*)text { NSError *error; UILabel *myLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 200, 200)]; myLabel.text = text; myLabel.font = [UIFont fontWithName:@"Helvetica""Helvetica" size:50]; myLabel.textAlignment = NSTextAlignmentLeft; myLabel.textColor = [UIColor colorWithRed:0/255.0 green:0/255.0 blue:0/255.0 alpha:1]; myLabel.backgroundColor = [UIColor clearColor]; myLabel.numberOfLines = -1; myLabel.lineBreakMode = NSLineBreakByCharWrapping; UIGraphicsBeginImageContextWithOptions(myLabel.bounds.size, NO, 1.0); CGContextTranslateCTM(UIGraphicsGetCurrentContext(), 0, 0); CGContextScaleCTM(UIGraphicsGetCurrentContext(), 1.0, 1.0); [myLabel.layer renderInContext:UIGraphicsGetCurrentContext()]; UIImage *layerImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); if (error) { NSLog(@"" Error loading texture from image: %@"%",error); return nil; } return layerImage; } Why there'sis no color visible where the texture is transparent?
