ProfessorF Posted December 15, 2013 Share Posted December 15, 2013 I use pngs with transparent areas on several planes to simulate plants (see first screenshot in Maya) But when I export to Babylon, the transparent areas are black: Any ideas? Thanks. Quote Link to comment Share on other sites More sharing options...
Ariel Yust Posted December 15, 2013 Share Posted December 15, 2013 Here you go mate:this is what I use in my project.var Materials=[];Materials.push(loadTexture("gfx/CategoryMirror.png", true, true)); function loadTexture(fileName, backFaceCulling, hasAlpha) { var m = new BABYLON.StandardMaterial(fileName, scene); var texture = new BABYLON.Texture(fileName, scene); texture.anisotropicFilteringLevel = 0; m.diffuseTexture = texture; m.backFaceCulling = backFaceCulling; m.diffuseTexture.hasAlpha = hasAlpha; //this is what your looking for =] return m; } GameMonetize 1 Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted December 15, 2013 Share Posted December 15, 2013 Agree with Ariel:)Blender exporter should automatically add it. How do you generate your .babylon file? Quote Link to comment Share on other sites More sharing options...
ProfessorF Posted December 15, 2013 Author Share Posted December 15, 2013 >.hasAlpha Yeah, I saw that in the documentation. I don't mind writing code to add the .hasAlpha, post hoc, but this is something that should be handled in the exporter. > How do you generate your .babylon file?Maya -> .fbx -> BabylonExporter.exe I'll see about hacking the exporter code. (Or I could use Blender. Although I think it's better to support Maya & 3DS Max, since most pro studios use one of the two). Thanks Quote Link to comment Share on other sites More sharing options...
ProfessorF Posted December 15, 2013 Author Share Posted December 15, 2013 (DeltaKosh, could you please add this fix to the BabylonExporter repository?) Okay, I modified the exporter code to work with alphas! But I don't think it's a hack. It should be turned on by default. That model has 500K polys and it works with hasAlpha=true by default.BabylonExport.Core > Entities > Export > StandardMaterial.cs:... babylonMaterial.diffuseTexture = new BabylonTexture(); babylonMaterial.diffuseTexture.name = Path.GetFileName(DiffuseTexture); babylonMaterial.diffuseTexture.hasAlpha = true; // <=== ProfessorF Mod... Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted December 15, 2013 Share Posted December 15, 2013 Hello Prof, I cannot do that because it will force ALL material to activate alpha testing which has a cost when it comes to performance When alpha testing is engaged, I must add a pixel alpha test and a discard into the shaders. Quote Link to comment Share on other sites More sharing options...
ProfessorF Posted December 15, 2013 Author Share Posted December 15, 2013 Oh. I understand. Okay, I think I have a better fix then.The code that determines whether a texture has alpha, is in BabylonExport.Core > Exporters > ThroughXNA > XNAExporter.cs if (texture.Format != SurfaceFormat.Dxt1) { filename = Path.Combine(tempPath, texturesCount + ".png"); } else { filename = Path.Combine(tempPath, texturesCount + ".jpg"); } I experimented with many different files, tga, png, jpg, etc. If a texture had an alpha, then the texture.Format==SurfaceFormat.Dxt5, and the code would create a .png file. Any texture without an alpha would create a .jpg file. NOTE: even if the file was originally a .png, if it had no alpha, the code would force it to become a .jpg. ***** NEW FIX (POSSIBLY): BabylonExport.Core > Entities > Export > StandardMaterial.cs:... babylonMaterial.diffuseTexture = new BabylonTexture(); babylonMaterial.diffuseTexture.name = Path.GetFileName(DiffuseTexture); if (babylonMaterial.diffuseTexture.name.ToLower().EndsWith(".png")) // <=== Do only if texture.Format != SurfaceFormat.Dxt1 babylonMaterial.diffuseTexture.hasAlpha = true; // <=== ProfessorF Mod... I think that is the correct code. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted December 15, 2013 Share Posted December 15, 2013 Great!!! I add the fix right now Thank you very much Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.