Load 3d object in cocos2d-x with materil that have alpha texture

i create a 3d plane in blender and load a texture to it with alpha.
then convert it to c3b file and load it into cocos2d-x with sprite 3d . but alpha pixel filled with black color.

 MainScene::new3dobject = Sprite3D::create("3.c3b");
MainScene::new3dobject->setGlobalZOrder(5);
this->addChild(MainScene::new3dobject);

in blender all thing render truely . what can i do?

Hi. I found a temporary work around to this.
-First, somehow, you can try to export your data from back to front distance (try merging in order).
-Add a “if(gl_FragColor.a <0.5){ discard; }” in cocos/renderer/ccShader_3D_ColorTex.frag to avoid blending on these pixels
-Try deactivating depth buffer
GLContextAttrs glContextAttrs = {8, 8, 8, 8, 0, 0};

texture became full transparent when change the shader and depth buffer does not affect on rendering in my problem

how can i change render order in cocos2d-x?

sorry for my english

Hi. I’m new to cocos and I don’t know if there is a better way, but there is a way to Sort your triangles from your 3D program. Maybe dettaching and attaching the polygons again in order.

Your material should have a transparency map, it problably only has a diffuse map (the regular one) and it needs to have a transparency map also.

Open the .c3t, go to the materials section and u will see that u dont have this one. I went through this just a few days ago.

We solved this checking the checkbox of transparency of the material when exporting the fbx. You can pass the same png you use for the diffuse map as transparency map.

After it, check the .c3t and u will see that there is the new map :wink:

thank for your reply
i uploded my sample projects files

1.zip (79.7 KB)

can you check them and tell me the solution of my problem

Look at this part (the materials section) of our .c3t extension file:

"materials": [
	{
		"id": "Mat", 
		"ambient": [ 0.000000,  0.000000,  0.000000], 
		"diffuse": [ 0.800000,  0.800000,  0.800000], 
		"emissive": [ 0.000000,  0.000000,  0.000000], 
		"opacity":  0.000000, 
		"textures": [
			{
				"id": "imagen_chapter3_texture_ipad_p15.png", 
				"filename": "imagen_chapter3_texture_ipad_p15.png", 
				"type": "DIFFUSE", 
				"wrapModeU": "REPEAT", 
				"wrapModeV": "REPEAT"
			}, 
			{
				"id": "imagen_chapter3_texture_normal_ipad_p15.png", 
				"filename": "imagen_chapter3_texture_normal_ipad_p15.png", 
				"type": "NORMAL", 
				"wrapModeU": "REPEAT", 
				"wrapModeV": "REPEAT"
			}, 
			{
				"id": "imagen_chapter3_texture_ipad_p15.png", 
				"filename": "imagen_chapter3_texture_ipad_p15.png", 
				"type": "TRANSPARENCY", 
				"wrapModeU": "REPEAT", 
				"wrapModeV": "REPEAT"
			}
		]
	}
]

There is the diffuse map (the regular one, the image, the texture, u know what i mean :P), the normal map for the lighting and the transparency map for the alpha.

Notice that we are using the same .png for the diffuse and the transparency map :wink:

2 Likes

thank so much
it worked.
but in some angles it doesnt work.