Jump to content

setAlphaMode and custom shader


highvrahos
 Share

Recommended Posts

Hello,

 

First of all thank you for this great community and tools that you are mainting with the effort of everybody, and most of all of the creators of Babylon JS.

 

We are using Babylon JS with a custom shader to render some plates that allow the dynamic chagning of color and material.

 

We are trying to make the glass render with some opacity, and as we aren't using Babylon JS standard material, but a custom combined with custom shaders, we are using for the plates:

 

        shape.registerBeforeRender(function() {
            engine.setAlphaMode(BABYLON.Engine.ALPHA_COMBINE);
        });

 

And for everything else, to render it normally:

 

        shape.registerBeforeRender(function() {
            engine.setAlphaMode(BABYLON.Engine.ALPHA_DISABLE);
        });

 

Ther result is really good, but we are experiencing an issue when the camera turns low and the plate renders in front of the background, as you can see in the attached photos.

 

The background is a sphere, with inversed normals so it can be rendered from the inside.

 

We know that it's difficult to provide assistance as we are using custom shaders, but we would be really glad if you point us in some direction to search for a fix in this issue.

 

Best regards,

Leonidas

post-5854-0-75394400-1412681940.png

post-5854-0-94596000-1412681946.png

Link to comment
Share on other sites

You should just ask the custom shader to require alpha for you:

var cloudMaterial = new BABYLON.ShaderMaterial("cloud", scene, {            vertexElement: "vertexShaderCode",            fragmentElement: "fragmentShaderCode",        },        {            needAlphaBlending: true,            attributes: ["position", "uv"],            uniforms: ["worldViewProjection"],            samplers: ["textureSampler"]        });
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...