Didn't have a lot of time last night to play with this, but it didn't seem to work- 
when I set the CombineRgbSource to COMBINE_PREVIOUS_TEXTURE_UNIT_STATE, which is what 
I'm assuming you meant by ..._COLOR it just drew the whole thing the colour of the 
object. I experimented with other settings- not relevant here, but setting it to 
CONSTANT_COLOR actually turned the whole canvas black and white.

If I set the Alpha combine mode to COMBINE_CONSTANT_COLOR it just drew the background 
object. COMBINE_TEXTURE_COLOR seems to work better, but I'm back where I started.

Is the problem that I'm using the Texture.LUMINANCE_ALPHA format?

Either way, here is the method that creates the TextureUnitState, I call it three 
times along the lines of TUStates[0] = getShine("Texture1.gif", new Color4f(1.0, 0.0, 
0.0, 0.0)); and so on.

private TextureUnitState getShine(String filename, Color4f emissive)
    {
      TextureUnitState bozer=null;
        BufferedImage bi = new BufferedImage(128, 128, BufferedImage.TYPE_BYTE_GRAY);
        Graphics2D g = bi.createGraphics();
        Image inImage = new 
ImageIcon("C:\\jdk1.3\\projects\\3dExperiments\\"+filename).getImage(); 
                        // What do you mean I shouldn't be using direct paths to my 
files? :)
        g.drawImage(inImage, null, null);
        g.dispose();
        ImageComponent2D alpha2D = new 
ImageComponent2D(ImageComponent2D.FORMAT_CHANNEL8, bi, true, false);
        Texture2D texter=new Texture2D(Texture2D.BASE_LEVEL, Texture.LUMINANCE_ALPHA, 
128, 128);
        texter.setImage(0, alpha2D);

        TextureAttributes texatt=new TextureAttributes();
      texatt.setTextureMode(TextureAttributes.COMBINE);
      texatt.setCombineRgbMode(TextureAttributes.COMBINE_REPLACE);

      texatt.setCombineRgbSource(0, texatt.COMBINE_TEXTURE_COLOR);
      texatt.setCombineRgbFunction(0, TextureAttributes.COMBINE_SRC_COLOR);

        texatt.setCombineAlphaMode(TextureAttributes.COMBINE_REPLACE);
        texatt.setCombineAlphaSource(0, TextureAttributes.COMBINE_TEXTURE_COLOR);
        texatt.setCombineAlphaFunction(0, TextureAttributes.COMBINE_SRC_ALPHA);
      
        texatt.setTextureBlendColor(emissive) ;
      
        TexCoordGeneration texas = 
                        new TexCoordGeneration(TexCoordGeneration.OBJECT_LINEAR, 
TexCoordGeneration.TEXTURE_COORDINATE_2);
      texas.setPlaneS(new Vector4f(1f, 0f, 0f, 0.5f));
      texas.setPlaneR(new Vector4f(0f, 1f, 0f, 1f));
      
        bozer=new TextureUnitState(texter, texatt, texas);

      return bozer;

    }

Thanks for your time,

-ben

-----Original Message-----
From: Stoney Jackson [mailto:[EMAIL PROTECTED]]
Sent: 09 October 2002 17:26
To: [EMAIL PROTECTED]
Subject: Re: [JAVA3D] Running greyscale textures into colour/alpha
channels


I'm assuming that the last texture unit (tu[3]) represents the alpha
channel. I have not tried this specific code. But I do something similar in
another project. Let me know if it works :)

TextureAttributes ta = new TextureAttributes();
ta.setTextureMode(ta.COMBINE);

// Keep the color the same as it was
ta.setCombineRgbMode(ta.COMBINE_REPLACE);
ta.setCombineRgbSource(0, ta.COMBINE_PREVIOUS_TEXTURE_UNIT_COLOR);

// Replace the alpha with the texture's alpha.
ta.setCombineAlphaMode(ta.COMBINE_REPLACE);
ta.setCombineAlphaSource(0, ta.COMBINE_CONSTANT_COLOR);
ta.setCombineAlphaFunction(0, ta.COMBINE_SRC_ALPHA);

tu[3].setTextureAttributes(ta);

-Stoney
----- Original Message -----
From: "Ben Moxon" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, October 09, 2002 8:41 AM
Subject: Re: [JAVA3D] Running greyscale textures into colour/alpha channels


> I can see how that will work with setting the colour- what setting to I
have to use (in TextureAttributes.setTextureBlendColor() I'm guessing ) on
the alpha-channel to use the black -> white element of the image for alpha
as well as the colour channel?
>
> -ben
>
> -----Original Message-----
> From: Artur Biesiadowski [mailto:[EMAIL PROTECTED]]
> Sent: 09 October 2002 11:14
> To: [EMAIL PROTECTED]
> Subject: Re: [JAVA3D] Running greyscale textures into colour/alpha
> channels
>
>
> Ben Moxon wrote:
> > How would I go about mixing several textures so that each one fills a
colour channel and the alpha channel?
> >
> > I have created an array of TextureUnitStates, one for each texture, and
they are all drawing correctly but each texture is in a grey_scale/alpha
format and what I want is for texture1 to be red_channel/alpha,  texture2 to
be green_channel_alpha and so on, blending them all so I get a white centre
and a mix of other colours around the edges where they merge.
>
>
> Use BLEND mode + set constant blend color to correct channel on each
stage.
>
> Never done this, but it should work this way.
>
> Artur
>
>
===========================================================================
> 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".
>
> 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".
>

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

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

Reply via email to