Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (516)
Games in Android Showcase (122)
games submitted by our members
Games in WIP (577)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: 1 [2]
  ignore  |  Print  
  Can't get alpha blending to work properly    (Read 4445 times)
0 Members and 1 Guest are viewing this topic.
Offline arne

Senior Duke




money is the worst drug- we should not let it rule


« Reply #30 - Posted 2005-10-13 22:34:59 »

Err... it really works ?
I haven't got it to work, What did I do wrong I wonder? There's nothing more then adding the Shapes Huh Or does this only work, if I don't use opaque planes?

:: JOODE :: Xith3d :: OdeJava ::
Offline hawkwind

Junior Duke




Java games rock!


« Reply #31 - Posted 2005-10-13 23:40:30 »

uncertain without seeing your code.  Opaque planes???  What do you mean here??
Offline arne

Senior Duke




money is the worst drug- we should not let it rule


« Reply #32 - Posted 2005-10-14 10:35:31 »

You wanted to see the code. Here is it  (I tried to remove unimportant stuff, because then it would be even more, the code is from my terrain-loader. It splits the terrain in many different pieces).
I marked the areas bold, where I set Transparency Attributes , cause I believe there could lie the problem)

[size=8pt]
             // g is the Geometry
                for(int i = 0; i < texTypeSplit.length; i++) {
                   System.out.println("----------------------------- "+ i);
                    AppearanceResult res = getAppearance(texTypeSplit, x, y, x+SEGMENT_LENGTH, y+SEGMENT_WIDTH);
                    if(res != null) {
                        Shape3D shape = new Shape3D(g,res.getAppearance());
                        og.addChild(shape);
                     }
                 }



    public AppearanceResult getappearance(String type, int start_x, int start_y, int end_x, int end_y) {
     ....
        Texture tiles = texloader.loadTexture(tilePath,"RGB",true,Texture.BASE_LEVEL,Texture.BASE_LEVEL_LINEAR,Texture.WRAP);
        states[0] = new TextureUnitState();
        states[0].setTexture(tiles);
        TextureAttributes texAttrib = new TextureAttributes();
        texAttrib.setTextureMode(TextureAttributes.DECAL);
        states[0].setTextureAttributes(texAttrib);
        if(checkoutBelow) { // For the purely opaque level at the ground, I don't have an alpha layer, so I skip setting the alpha
            Texture alphamap = texloader.getMinMapAlphaTexture(alphaPath);


            states[1] = new TextureUnitState();
            states[1].setTexture(alphamap);
            TextureAttributes alphaAttrib = new TextureAttributes();
            alphaAttrib.setTextureMode(TextureAttributes.MODULATE);
           
            states[1].setTextureAttributes(alphaAttrib);
            TransparencyAttributes transAttr = new TransparencyAttributes(   // These Transparency Attributes are for the Layers,
                    TransparencyAttributes.BLENDED,                                                // that get layed over others, so they are more
                    0f,                                                                                      // transparent in some places than in others.
                    TransparencyAttributes.BLEND_SRC_ALPHA,
                    TransparencyAttributes.BLEND_ONE_MINUS_SRC_ALPHA);
            transAttr.setSortEnabled(true);
            a.setTransparencyAttributes(transAttr);
        }
        else {
            TransparencyAttributes transAttr = new TransparencyAttributes();   // that's for layer at the bottom, which is fully
            transAttr.setSortEnabled(true);                                                                       // opaque
            a.setTransparencyAttributes(transAttr);
        }
        a.setTextureUnitState(states);
        AppearanceResult res = new AppearanceResult(a, checkoutBelow);
        return(res);
    }
[/size]

Note, that it works, if I don't use the DecalGroup, but Transformgroups, that moves the alpha-layers a bit up, so they get shown over the opaque layer.

Arne

:: JOODE :: Xith3d :: OdeJava ::
Pages: 1 [2]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

TehJavaDev (32 views)
2014-10-27 08:28:38

TehJavaDev (26 views)
2014-10-27 08:27:51

DarkCart (41 views)
2014-10-27 00:37:11

Luminem (22 views)
2014-10-26 15:17:50

Luminem (27 views)
2014-10-26 15:14:04

theagentd (33 views)
2014-10-25 20:46:29

Longarmx (61 views)
2014-10-17 08:59:02

Norakomi (58 views)
2014-10-16 20:22:06

Norakomi (47 views)
2014-10-16 20:20:20

lcass (43 views)
2014-10-15 21:18:58
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-10 03:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-03 03:36:02

List of Learning Resources
by Longor1996
2014-08-16 15:40:00

List of Learning Resources
by SilverTiger
2014-08-06 00:33:27

Resources for WIP games
by CogWheelz
2014-08-01 21:20:17

Resources for WIP games
by CogWheelz
2014-08-01 21:19:50

List of Learning Resources
by SilverTiger
2014-07-31 21:29:50

List of Learning Resources
by SilverTiger
2014-07-31 21:26:06
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!