Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (527)
Games in Android Showcase (127)
games submitted by our members
Games in WIP (594)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Blending problems  (Read 1623 times)
0 Members and 1 Guest are viewing this topic.
Offline bohdan

Junior Devvie




Java-positive...


« Posted 2006-09-16 15:59:33 »

Hi!

Here is very simple test case:

Two non-coinsiding planes (far enough from each other) of same size; Bottom one - GREEN, top one - BLUE.
Top plane is in the TransformGroup, and it is oscilating forward and backward (on Y axis) (you will see later why this is needed).

Two bug-like situations you can see here. To get better picture of what is happening please follow this steps:

1. Run it as it is. Both planes are opaque. You will see NO PROBLEMS here, just note the actual colors - pure GREEN & BLUE.
2. Find the line marked "play here", and uncoment transparency for TOP plane (BLUE one) only. So we have opague GREEN plane and on top of it there is transparent BLUE plane. As you can see, no matter what is the translation of BLUE plane - it is always BLENDED with BACKGROUND in some reason and never with the opaque GREEN plane!!! This is WRONG.
3. Now, uncoment transparency for GREEN plane as well. So we have two transparent planes. If you run the test you will see that depending on the translation of BLUE plane we are getting either RIGHT or WRONG blending efect - this is the most strange case for me....

Here is the code (also, screenshots attached).
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
80  
81  
82  
83  
84  
85  
86  
87  
88  
89  
90  
91  
92  
93  
94  
95  
96  
97  
98  
99  
import java.awt.Color;
import javax.swing.JFrame;
import javax.vecmath.Color3f;
import javax.vecmath.Point3f;
import javax.vecmath.Vector3f;
import org.xith3d.test.util.TestUtils;
import com.xith3d.render.CanvasPeer;
import com.xith3d.render.jsr231.RenderPeerImpl;
import com.xith3d.scenegraph.Appearance;
import com.xith3d.scenegraph.BranchGroup;
import com.xith3d.scenegraph.Canvas3D;
import com.xith3d.scenegraph.ColoringAttributes;
import com.xith3d.scenegraph.Locale;
import com.xith3d.scenegraph.Shape3D;
import com.xith3d.scenegraph.Transform3D;
import com.xith3d.scenegraph.TransformGroup;
import com.xith3d.scenegraph.TransparencyAttributes;
import com.xith3d.scenegraph.View;
import com.xith3d.scenegraph.VirtualUniverse;

public class Bleeding_BlendingTest {

    public Bleeding_BlendingTest() {
        JFrame frame = new JFrame("Bleeding BlendingTest");
        frame.setSize(500, 500);
        //======= setting up Universe ===============
        VirtualUniverse My_Universe = new VirtualUniverse();
        Locale locale = new Locale();
        My_Universe.addLocale(locale);
        BranchGroup scRootBG  = new BranchGroup();
        locale.addBranchGraph(scRootBG);
        //------------------------------
        CanvasPeer canvasPeer = new RenderPeerImpl().makeCanvas(
              frame.getContentPane(), 0, 0, 32, false);
        Canvas3D scrCanvas = new Canvas3D();
        scrCanvas.set3DPeer(canvasPeer);
        //------------------------------
        View scView = new View();
        scView.addCanvas3D(scrCanvas);
        My_Universe.addView(scView);
        //------------------------------
        Appearance plane_BOTTOM_GREEN = new Appearance();
        plane_BOTTOM_GREEN.setColoringAttributes(
              new ColoringAttributes(new Color3f(Color.GREEN),0));

        Appearance plane_TOP_BLUE = new Appearance();
        plane_TOP_BLUE.setColoringAttributes(new ColoringAttributes(new Color3f(Color.BLUE),0));
        TransparencyAttributes ta = new TransparencyAttributes(
              TransparencyAttributes.BLENDED, 0.7f);
        //-------------------------------------------
        Shape3D planeBOTTOM_GREEN = new Shape3D(TestUtils.
                createPlane(0, 0, -2, 5, 5), plane_BOTTOM_GREEN);
        Shape3D planeTOP_BLUE =  new Shape3D(TestUtils.
                createPlane(1, 0, -1, 5, 5), plane_TOP_BLUE);

        //__________________________________________________
        //*************** play here ************************
        //plane_BOTTOM_GREEN.setTransparencyAttributes(ta);
        //plane_TOP_BLUE.setTransparencyAttributes(ta);
        //**************************************************

        TransformGroup translateY_TG = new TransformGroup();
        translateY_TG.addChild(planeTOP_BLUE);

        scRootBG.addChild(planeBOTTOM_GREEN);
        scRootBG.addChild(translateY_TG);
        //======= running =============================
        Point3f camL = new Point3f(0,-4f,3f);
        Point3f lookAtV = new Point3f();
        Vector3f upV = new Vector3f(0,0,1);
        scView.getTransform().lookAt(camL,lookAtV,upV);

        float transalteY = 0;
        float speed = 0.05f;

        frame.setVisible(true);
        long currTime = System.currentTimeMillis();
        long lastTime = currTime;
        while (frame.isVisible()) {
            scView.renderOnce();
            //--------------------
            currTime = System.currentTimeMillis();
            if (currTime - lastTime > 30) {
                lastTime = currTime;
                transalteY += speed;
                Transform3D t3d = new Transform3D();
                t3d.setTranslation(new Vector3f(0,transalteY,0));
                translateY_TG.setTransform(t3d);
                if (Math.abs(transalteY) > 3f) speed = -speed;
            }
            //--------------------
        }
        System.exit(0);
    }

    public static void main(String args[]) {
        new Bleeding_BlendingTest();
    }
}


Note, that the plane sizes, camera location, amplitude of oscilations etc - where purposly adjusted so that these problems poping up. In many other cases you will see no problems!!!

Anybody can advice on that?

Bohdan.

Offline bohdan

Junior Devvie




Java-positive...


« Reply #1 - Posted 2006-09-17 16:49:56 »

Anybody tried to run the test? I just encourage you to try it and confirm at least that you see the same as I see....

I don't mind to track the problem down myself, the only is if anybody can help and advice whose problem is it?
OGL, JOGL or Xith's? Since I have no experience with first two, if anybody can confirm that it definitely isn't OGL/JOGL problem, then I can try dig it on Xith level... I already did tried actualy, but with no luck so far....
Offline Marvin Fröhlich

Senior Devvie




May the 4th, be with you...


« Reply #2 - Posted 2006-09-17 17:17:30 »

I ran the test just as you suggested and encountered the same problems. But so far I cannot say, if this is a Xith related problem. But I guess it is Sad. When I stumble over somthing in the rendering code, that maybe is the reason, I'll tell you.

Marvin
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline bohdan

Junior Devvie




Java-positive...


« Reply #3 - Posted 2006-09-17 17:42:59 »

Thanks Marvin!

Yep, I thing it is Xith, but.. I have little of suspisious as well, that it actually might be not... because strange thing is that it seems it have something to do with relative positions (coordinates), of the objects, camera, and objects (planes in this case) sizes... How this parameters can make diference for Xith? Strange...

This is simple test, but I can post as well other test, yet even more strange, when you changing camera position so that the picture on screen become just perfectly mirrored - and it became rendered improperly, you put camera back to original position - blahhh... everything perfect... where is Xith role in this? Have no idea.. Very strange....

In other words imagine: You have two flat (all geom is on plane) shapes totaly symetrical in regards to (0,0,0). You have camera at (1, 0, 2) and looking at (0,0,0), picture is perfect as it should be, you just put you camera to (-1, 0, 2) still looking at (0,0,0) - everything looks totaly mess. And difference between to pictures should be just that they are ideally mirrored one to another... Driving you crazy, tell you...  Undecided

Bohdan.
Offline Marvin Fröhlich

Senior Devvie




May the 4th, be with you...


« Reply #4 - Posted 2006-09-17 17:57:27 »

hmm... no idea, sorry. Sad

When I've some spare time, I'll have a closer look.
Offline Amos Wenger

Senior Devvie




Everything's possible, but not everything's fun...


« Reply #5 - Posted 2006-09-18 16:37:49 »

Interesting..

With this code
1  
2  
3  
4  
Shape3D planeBOTTOM_GREEN = new Shape3D(TestUtils.
                createPlane(0, 0, -1, 5, 5), plane_BOTTOM_GREEN);
        Shape3D planeTOP_BLUE =  new Shape3D(TestUtils.
                createPlane(1, 0, -2, 5, 5), plane_TOP_BLUE);

(and the remaining, of course), the top blue plane disappear when it's near the observer.

I have no idea of what it can be but it's related to my wrong Z-buffer tests.

"Once you start working on something, don't be afraid of failure and don't abandon it. People who work sincerely are the happiest"
Offline Amos Wenger

Senior Devvie




Everything's possible, but not everything's fun...


« Reply #6 - Posted 2006-09-18 16:39:55 »

Also, SCREEN_DOOR transparency doesn't work.

"Once you start working on something, don't be afraid of failure and don't abandon it. People who work sincerely are the happiest"
Offline Amos Wenger

Senior Devvie




Everything's possible, but not everything's fun...


« Reply #7 - Posted 2006-09-18 16:44:49 »

Now that's a really really interesting one.

In the view setup just replace (-4) with (4) and the transparency is wrong when the top blue plane is far from the observer : SO this is a point-of-view related issue. Could it have something to do with view culling ? Really strange ? Is it related to the bug we fixed with appearance not being changed when it's outside from the view ?

"Once you start working on something, don't be afraid of failure and don't abandon it. People who work sincerely are the happiest"
Offline bohdan

Junior Devvie




Java-positive...


« Reply #8 - Posted 2006-09-18 17:30:16 »

Now that's a really really interesting one.

In the view setup just replace (-4) with (4) and the transparency is wrong when the top blue plane is far from the observer : SO this is a point-of-view related issue. Could it have something to do with view culling ? Really strange ? Is it related to the bug we fixed with appearance not being changed when it's outside from the view ?

Yep, that is the reason why I have little of suspection about jogl or ogl as well.... that strange coordinate related staff... hmmm...
Btw, what you mean by view culling? Frustrum culling? If so, I tried without frustrum culling - seems nothing to do with that...
Anyhow frustrum culling can just cull the whole node, but will not cause visual efects anyhow.
Just wondering, if anybody familiar with jogl can reproduce that really simple test case with jogl only, just to confirm on wich side the problem resides...
It will help a lot in localization of the problem, then we can concentrate on killing that bug in Xith, if it appeared to be Xith problem.
Pages: [1]
  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.

PocketCrafter7 (14 views)
2014-11-28 16:25:35

PocketCrafter7 (9 views)
2014-11-28 16:25:09

PocketCrafter7 (10 views)
2014-11-28 16:24:29

toopeicgaming1999 (76 views)
2014-11-26 15:22:04

toopeicgaming1999 (66 views)
2014-11-26 15:20:36

toopeicgaming1999 (15 views)
2014-11-26 15:20:08

SHC (30 views)
2014-11-25 12:00:59

SHC (28 views)
2014-11-25 11:53:45

Norakomi (32 views)
2014-11-25 11:26:43

Gibbo3771 (28 views)
2014-11-24 19:59:16
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

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

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

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

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

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

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

List of Learning Resources
by SilverTiger
2014-07-31 16: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!