Jump to content

Alpha ignored?


ProfessorF
 Share

Recommended Posts

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;    }
Link to comment
Share on other sites

>.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

Link to comment
Share on other sites

(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
...
Bbityl8CEAAVrlR.png
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...