Jump to content

Two questions about texture alpha


Recommended Posts

Hi, two questions:


1. Which is the intended way to correctly render a texture with an alpha channel? The docs say to set "texture.hasAlpha", but this appears to render the texture opaquely while dropping pixels under some threshold. Am I supposed to be setting tex.opacityTexture=tex.diffuseTexture? (opacityTexture doesn't seem to be in any of the tutorials so it's hard to tell..)


2. When I set an opacityTexture on a mesh, it messes up other parts of my scene - for example, sprites get drawn on top of the mesh regardless of position (thusly). Is this avoidable?


Link to comment
Share on other sites

Hmm, another oddity - if a sprite has alpha, it masks out other sprites rather than being composited.

Thus: http://www.babylonjs-playground.com/#5RPNC#1


Is the lesson here that sprites occupy their own rendering layer, so if you want something that renders in with the rest of the scene you need to create a bunch of planes and manage your own u/v scales and offsets?

Link to comment
Share on other sites

For textures with alpha: they are drawn only in color buffer and not in depth buffer to not block blending. So because sprites are rendered after and because there is no depth buffer they cannot take care of their position.


This is done by this instruction:


which in turn call this one:




We should perhaps add a parameter to allow depth rendering for alpha objects.


For sprites: because they are not designed to get alpha, they are not sorted. So alpha sprites may be rendered first and so block the depth buffer.

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.

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.


  • Recently Browsing   0 members

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