1
votes

I have a mesh (plane with some modifiers) with a material assigned to it in Blender, and the texture of the material uses a semi-transparent PNG image.

When exporting to POD file, the mesh still looks semi-transparent in PVRShaman as it does in Blender, but when I import it in Cocos3D as CC3DPODMeshNode it appears as the image itself is still semi-transparent, but it also has a blueish color behind it, in the background.

Any idea why this happens?

The settings seem to be OK in Blender, because I can visualize it correctly after export, but what's wrong on the Cocos3D side?

1

1 Answers

1
votes

You might be dealing with pre-multiplied alpha. For efficiency, Xcode (and the iOS image loaders) assume that alpha is to be pre-multiplied into the colors within each texture, and actually modifies the textures during app packaging and texture loading. This is a well-known issue with Xcode and iOS.

Try changing the name of the PNG file to give it a ppng file extension. That will cause Xcode to skip the file manipulation at build time and will cause Cocos3D to use a non-Apple file loader for the image.

See the notes for the CC3Texture class or the texture property of CC3Material or CC3MeshNode for more on this.

[Edit]:

This turned out to be an issue with the rendering order of two nodes that contain transparency. The bluish color was coming from the scene backdrop, which was behind the skybox. The object of interest was being rendered before the skybox, which also had a texture containing transparency. Normally, Cocos3D will automatically render opaque objects first, then translucent object in reverse order of distance from the camera. In this case, the skybox contained transparency (had an alpha channel), and was being rendered after the object of interest. It's generally good practice to make sure the texture used for skyboxes is opaque and contains no alpha transparency.

It's also possible to force the skybox (even a translucent skybox) to be rendered first by setting its zOrder property to a positive value (it defaults to zero). The zOrder property can be used to fix the rendering order of transparent objects. It is not required (and has no effect) on fully opaque objects.