Hi Justin,
Just some information which may help from OpenGL
specification for GL_ALPHA base internal format
Replace Texture Function
----------------------------
C = Cf
A = At
Modulate Texture Function
---------------------------
C = Cf
A = AfAt
Decal Texture Function
-------------------------
undefined (so don't use it for alpha texture)
Blend Texture Function
------------------------
C = Cf
A = AfAt
where
Ct is the RGB color of Texture and
At is alpha of texture.
Cf, Af is the polygon color and alpha
C and A is the resulting Color and Alpha.
So unless the polygon has alpha > 0, try using replace texture
function for alpha only texture.
I also attach the email from previous discussion
that has similar problem.
- Kelvin
----------------
Java 3D Team
Sun Microsystems Inc.
>Date: Tue, 16 Jul 2002 13:33:37 -0700
>From: Justin Couch <[EMAIL PROTECTED]>
>Subject: [JAVA3D] Help with Alpha-only textures
>To: [EMAIL PROTECTED]
>MIME-version: 1.0
>Content-transfer-encoding: 7bit
>X-Accept-Language: en-us, en
>Delivered-to: [EMAIL PROTECTED]
>User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.0.0)
Gecko/20020530
>
>Chasing some help understanding some of the 2D texture modes. It seems
>they are not what they appear to be.
>
>I'm trying to develop a texture-based solution for the VRML Text node.
>To do this, I'm creating alpha-only textures to act as a "stencil" over
>the geometry as the spec requires that the text be both lit with
>material colours and textured (including possibly multi-texturing).
>While I can get basic RGBA textures working fine, as soon as I swap the
>texture to Texture.ALPHA I end up seeing nothing. Here's my rough code:
>
>BufferedImage bi = new BufferedImage(...BufferedImage.TYPE_BYTE_GRAY);
>Graphics g = bi.createGraphics();
>
>// do a bunch of drawing here...
>
>ImageComponent2D ic = new
> ImageComponent2D(....ImageComponent.FORMAT_CHANNEL8);
>Texture2D texture = new Texture2D(...Texture.ALPHA);
>
>TextureAttributes ta = new TextureAttributes();
>ta.setTextureMode(TextureAttributes.COMBINE);
>ta.setCombineRgbMode(TextureAttributes.COMBINE_REPLACE);
>ta.setCombineAlphaMode(TextureAttributes.COMBINE_REPLACE);
>
>ta.setCombineRgbSource(0, TextureAttributes.COMBINE_OBJECT_COLOR);
>ta.setCombineAlphaSource(0, TextureAttributes.COMBINE_TEXTURE_COLOR);
>
>ta.setCombineRgbFunction(0, TextureAttributes.COMBINE_SRC_COLOR);
>ta.setCombineAlphaFunction(0, TextureAttributes.COMBINE_SRC_ALPHA);
>
>etc. I've tried texture attributes with BLEND and MODULATE as well as
>combine modes of COMBINE_BLEND, COMBINE_MODULATE as well as setting the
>functions to ONE_MINUS_blah, but none of them ever result in something
>visible on screen - no object, no texture, nothing :( Any suggestions on
>what settings I need to come up with here to get the correct appearance?
>
>--
>Justin Couch http://www.vlc.com.au/~justin/
>Java Architect & Bit Twiddler http://www.yumetech.com/
>Author, Java 3D FAQ Maintainer http://www.j3d.org/
>-------------------------------------------------------------------
>"Humanism is dead. Animals think, feel; so do machines now.
>Neither man nor woman is the measure of all things. Every organism
>processes data according to its domain, its environment; you, with
>all your brains, would be useless in a mouse's universe..."
> - Greg Bear, Slant
>-------------------------------------------------------------------
>
>===========================================================================
>To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
>of the message "signoff JAVA3D-INTEREST". For general help, send email to
>[EMAIL PROTECTED] and include in the body of the message "help".
--- Begin Message ---
Hi Justin,
This is not a bug. According to OpenGL specification
for Texture replace (default) function.
Base Internal Format Replace Texture function
--------------------- -----------------------
GL_RGB C = Ct, A = Af
GL_RGBA C = Ct, A = At
where
Ct is the RGB color of Texture and
At is alpha of texture.
Cf, Af is the polygon color and alpha
C and A is the resulting Color and Alpha.
In TextureOverlay,
TransparencyAttributes trans =
new TransparencyAttributes(TransparencyAttributes.BLENDED, 1.0f);
appearance.setTransparencyAttributes(trans);
(comment out the above call will works for RGB format)
the polygon alpha color is set to 0 after blending so Af = 0.
As a resulting when Texture Format RGBA is used we
have A = At but when Format RGB is used we have A = 0
thus the texture is totally transparency and seems disappear.
Our Java3D specification did not mention the alpha component
clearly in this case for TextureAttributes.REPLACE.
Thanks.
- Kelvin
>Date: Thu, 06 Jun 2002 20:08:31 +1000
>From: Justin Couch <[EMAIL PROTECTED]>
>Subject: Texture always requires RGBA
>To: [EMAIL PROTECTED]
>Cc: Alan <[EMAIL PROTECTED]>
>MIME-version: 1.0
>X-Accept-Language: en-us, en
>Delivered-to: [EMAIL PROTECTED]
>User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.0rc3) Gecko/20020523
>
>Guys,
>
>Found a nasty bug here. Taken me 5 hours to isolate it :(
>
>Simple synopsis: Requires setting Texture.RGBA even when the image type
>does not contain an alpha channel which would normally use Texture.RGB.
>
>The attached zip file contains the demo code. In the demo file
>(TextureBugDemo) there is a section in the middle where I load the image
>using the standard AWT toolkit and MediaTracker then turn it into a
>texture. For demo purposes theres a big-arse switch statement to print
>out what the image format is. You will see this tells you the image is
>indexed, no alpha. For display purposes, I put this same image on screen
>twice - once using RGB, once with RGBA. Note that only the RGBA image
>gets rendered. I've tried this with other image other than PNG and they
> exhibit the same problem (JPEG & GIF).
>
>I've used a bit of other j3d.org code to do all the heavy lifting. I
>have tested this without that and confirm the bug still exists (ie
>single textured quad), however the demo file becomes close to 500 lines
>long. Felt is was going to be easier to demonstrate to you in this form.
>Hope I've got all the relevant files, let myself or Alan know if not (as
>I'm still Sydney time and Alan may be able to get you the files quicker).
>
>System (the usual one):
>x86, Win2K, ATI Rage Mobility M3, driver v5.13.1.3245
>
>--
>Justin Couch http://www.vlc.com.au/~justin/
>Java Architect & Bit Twiddler http://www.yumetech.com/
>Author, Java 3D FAQ Maintainer http://www.j3d.org/
>-------------------------------------------------------------------
>"Humanism is dead. Animals think, feel; so do machines now.
>Neither man nor woman is the measure of all things. Every organism
>processes data according to its domain, its environment; you, with
>all your brains, would be useless in a mouse's universe..."
> - Greg Bear, Slant
>-------------------------------------------------------------------
>
--- End Message ---