Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (106)
games submitted by our members
Games in WIP (533)
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  
  MultiPass & Rendering Order  (Read 6194 times)
0 Members and 1 Guest are viewing this topic.
Offline bohdan

Junior Member




Java-positive...


« Posted 2006-07-14 21:07:40 »

Hi!

I have tried to use multipass rendering to render two BranchGroups: A & B, so that group B is rendered on top of A, but with no luck...  Undecided
Is it possible to achieve? Should I know something specific about usage of MultiPassView etc..?

My problem is that I actually can achive the order but strangly only when I set to render B in PARALLEL_PROJECTION.
If I set A to render in parallel - then A would be rendered on top..

And finaly, when I set both to perspective - they are rendered just as there are no multipass (or probably I'm putting different meaning to multipass Huh). For example if I have cube and sphere in the same location - I can see how they overlap as in normal rendering... (See the picture), though they are in different rendering passes. Is it correct behaviour?

Bohdan.

Offline Marvin Fröhlich

Senior Member




May the 4th, be with you...


« Reply #1 - Posted 2006-07-14 21:58:44 »

Please post your code, so that we can track the problem. It seems that you have done everything correctly.
Offline Amos Wenger

Senior Member




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


« Reply #2 - Posted 2006-07-14 22:30:29 »

Hey I had this "problem" but you know it's not a bug, it's features ^^

Actually I think it's because of the Z-Buffer which isn't cleared between different passes but.. I may be wrong.

"Once you start working on something, don't be afraid of failure and don't abandon it. People who work sincerely are the happiest"
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Marvin Fröhlich

Senior Member




May the 4th, be with you...


« Reply #3 - Posted 2006-09-15 00:10:27 »

Now I also seem to have a strange problem with the MultiPassView. It seems to ignore the rendering order, which I simply can't understand, since the passes are rendered step by step.

Please have a look at the (redesigned) HUD3DTest and you'll see the problem.

Does anyone have a clue?

Marvin
Offline Amos Wenger

Senior Member




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


« Reply #4 - Posted 2006-09-15 16:27:53 »

Now I also seem to have a strange problem with the MultiPassView. It seems to ignore the rendering order, which I simply can't understand, since the passes are rendered step by step.

Please have a look at the (redesigned) HUD3DTest and you'll see the problem.

Does anyone have a clue?

Marvin
Did you look at the rendering code yet ?

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

JGO Ninja


Medals: 38



« Reply #5 - Posted 2006-09-15 16:31:33 »

Quote
Now I also seem to have a strange problem with the MultiPassView. It seems to ignore the rendering order, which I simply can't understand, since the passes are rendered step by step.

Have you checked the Z-buffer thingy? I suspect the multi pass rendering is correct. Is there possibly a flag to clear the depth-buffer after finishing a pass (or before starting the next)?

Mathias - I Know What [you] Did Last Summer!
Offline Marvin Fröhlich

Senior Member




May the 4th, be with you...


« Reply #6 - Posted 2006-09-15 17:46:21 »

Did you look at the rendering code yet ?

Not yet. I was really tired yesterday evening. I'll hopefully do it the next hours.

Have you checked the Z-buffer thingy? I suspect the multi pass rendering is correct. Is there possibly a flag to clear the depth-buffer after finishing a pass (or before starting the next)?

Unfortunately I haven't used the z-buffer things before. I'll have to search through the code and collect information on it. Any hints?
Offline Amos Wenger

Senior Member




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


« Reply #7 - Posted 2006-09-15 17:51:11 »

Have you checked the Z-buffer thingy? I suspect the multi pass rendering is correct. Is there possibly a flag to clear the depth-buffer after finishing a pass (or before starting the next)?

Unfortunately I haven't used the z-buffer things before. I'll have to search through the code and collect information on it. Any hints?
Well Z-buffer is easy : it's used to check that polygons are rendered in the correct (perspective order). It must be cleared (or ignored) if you want to render object each on top on each other by rendering order, not Z order.

"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 Marvin Fröhlich

Senior Member




May the 4th, be with you...


« Reply #8 - Posted 2006-09-15 17:58:13 »

Well Z-buffer is easy : it's used to check that polygons are rendered in the correct (perspective order). It must be cleared (or ignored) if you want to render object each on top on each other by rendering order, not Z order.

Yes, thnks, I do know the principle of z-buffering Wink. The thing is that I don't know how ot is implemented in Xith.
Online cylab

JGO Ninja


Medals: 38



« Reply #9 - Posted 2006-09-15 18:25:23 »

Unfortunately I haven't used the z-buffer things before. I'll have to search through the code and collect information on it. Any hints?

search for glEnable([GL.]GL_DEPTH_TEST) and glClear([GL.]GL_DEPTH_BUFFER_BIT)

Mathias - I Know What [you] Did Last Summer!
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Marvin Fröhlich

Senior Member




May the 4th, be with you...


« Reply #10 - Posted 2006-09-15 18:29:45 »

Unfortunately I haven't used the z-buffer things before. I'll have to search through the code and collect information on it. Any hints?

search for glEnable([GL.]GL_DEPTH_TEST) and glClear([GL.]GL_DEPTH_BUFFER_BIT)

Thanks.
Offline Amos Wenger

Senior Member




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


« Reply #11 - Posted 2006-09-15 19:04:16 »

1  
2  
3  
4  
5  
6  
7  
8  
9  
public void renderOnce()
    {
        int i = 0;
        for (RenderPass pass: listRenderPasses)
        {
            renderOnce(pass, (i == 0), (i == listRenderPasses.size() - 1));
            i++;
        }
    }

1  
2  
3  
4  
5  
6  
7  
8  
9  
/**
     * This renders just the given pass, overriding the clearBuffer and
     * swapBuffer states.
     *
     * @param pass the pass to render
     * @param forceClearBuffer
     * @param forceSwapBuffers
     */

    protected void renderOnce(RenderPass pass, boolean forceClearBuffer, boolean forceSwapBuffers)

should it be
1  
renderOnce(pass, true, (i == listRenderPasses.size() - 1));

?

"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 Marvin Fröhlich

Senior Member




May the 4th, be with you...


« Reply #12 - Posted 2006-09-15 19:16:55 »

should it be
1  
renderOnce(pass, true, (i == listRenderPasses.size() - 1));

?

Hmm... no. With these values the HUD3DTest end in an unrendered main scene. But thank you very much for helping me to find the clue. Please keep on searching Smiley.
Online cylab

JGO Ninja


Medals: 38



« Reply #13 - Posted 2006-09-15 19:17:27 »

No, I don't think so. It might be a desired behaviour to have correct z-buffering drawing while multi pass rendering. There should be a flag to control this behaviour.

On a sidenote, it should be possible to specify a texture as target of the rendering (using FBOs) except for the last pass, so you could refer to the pixels of a preceding render pass.

Mathias - I Know What [you] Did Last Summer!
Offline Marvin Fröhlich

Senior Member




May the 4th, be with you...


« Reply #14 - Posted 2006-09-15 19:19:51 »

No, I don't think so. It might be a desired behaviour to have correct z-buffering drawing while multi pass rendering. There should be a flag to control this behaviour.

On a sidenote, it should be possible to specify a texture as target of the rendering (using FBOs) except for the last pass, so you could refer to the pixels of a preceding render pass.

hmm... if that didn't hit the performance. I guess one shouldn't be able to grab directly into the frame buffer (too fragile).
Online cylab

JGO Ninja


Medals: 38



« Reply #15 - Posted 2006-09-15 19:24:03 »

hmm... if that didn't hit the performance. I guess one shouldn't be able to grab directly into the frame buffer (too fragile).

That's what FBOs are for. It's a nice thing and not too difficult to implement (if it is supported by the driver). Maybe I'll find the time and prototype this.

Quote
But thank you very much for helping me to find the clue. Please keep on searching

I think the place is right. The problem is, that the forceClearBuffer flag clears the color buffer, too. I think the implementation of renderOnce has to be extended to allow for depth buffer clearing only.

Mathias - I Know What [you] Did Last Summer!
Offline Marvin Fröhlich

Senior Member




May the 4th, be with you...


« Reply #16 - Posted 2006-09-15 19:34:09 »

hmm... if that didn't hit the performance. I guess one shouldn't be able to grab directly into the frame buffer (too fragile).

That's what FBOs are for. It's a nice thing and not too difficult to implement (if it is supported by the driver). Maybe I'll find the time and prototype this.

OK. Than it's good Smiley.

Quote
But thank you very much for helping me to find the clue. Please keep on searching

I think the place is right. The problem is, that the forceClearBuffer flag clears the color buffer, too. I think the implementation of renderOnce has to be extended to allow for depth buffer clearing only.

I'll check that.
Online cylab

JGO Ninja


Medals: 38



« Reply #17 - Posted 2006-09-16 00:16:35 »

Where do you guys put the tests and demos? The cvs repository did not contain anything like that. All demos seem to be deleted some months ago.  Huh

Mathias - I Know What [you] Did Last Summer!
Offline Marvin Fröhlich

Senior Member




May the 4th, be with you...


« Reply #18 - Posted 2006-09-16 00:20:29 »

Where do you guys put the tests and demos? The cvs repository did not contain anything like that. All demos seem to be deleted some months ago.  Huh

You probably checked out xith3d CVS. All tests and demos now resist in xith-tk.

Marvin
Online cylab

JGO Ninja


Medals: 38



« Reply #19 - Posted 2006-09-16 00:24:38 »

Ah, thanks Roll Eyes

Mathias - I Know What [you] Did Last Summer!
Online cylab

JGO Ninja


Medals: 38



« Reply #20 - Posted 2006-09-16 01:37:20 »

I took a quick look in the source. To configure the CanvasPeer to draw the render passes on top of each other, you have to call

1  
2  
3  
4  
// clear the buffer...
canvasPeer.setDisableClearBuffer(false);
// ...but specify, that depth-buffer clearing is not necessary
canvasPeer.setFullOverpaint(true);


The MultiPassView however only calls the first in it's prepareRenderOnce() method:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
// MultiPassView:195 ...
prepareRenderOnce(RenderPass pass, boolean forceClearBuffer, boolean forceSwapBuffers, Canvas3D canvas3D)
{
        // (...)
       if (canvas3D.get3DPeer() instanceof com.xith3d.render.jsr231.CanvasPeerImpl)
        {
            com.xith3d.render.jsr231.CanvasPeerImpl canvasPeerImpl = (com.xith3d.render.jsr231.CanvasPeerImpl)(canvas3D.get3DPeer());
            // set clear buffer state
           canvasPeerImpl.setDisableClearBuffer(!forceClearBuffer);
            // set force swap state
           canvasPeerImpl.setForceNoSwap(!forceSwapBuffers);
        }
        else if (canvas3D.get3DPeer() instanceof com.xith3d.render.lwjgl.CanvasPeerImpl)
        {
            com.xith3d.render.lwjgl.CanvasPeerImpl canvasPeerImpl = (com.xith3d.render.lwjgl.CanvasPeerImpl)(canvas3D.get3DPeer());
            // set clear buffer state
           canvasPeerImpl.setDisableClearBuffer(forceClearBuffer);
            // set force swap state
           //canvasPeerImpl.setForceNoSwap(!forceSwapBuffers);
       }
}


which results in either no clearing at all or full clearing including the color buffer.

So to solve this, a new property - named "layered" for example - should be added to MultiPassView. If this is set to true, the two canvasPeer-properties should be set like the code at the top of this post for all render passes but the first one.

I'll try this tomorrow, maybe Wink

Mathias - I Know What [you] Did Last Summer!
Online cylab

JGO Ninja


Medals: 38



« Reply #21 - Posted 2006-09-16 02:13:36 »

Ha!... just tested it and it seems to work. The only drawback is, that you also loose the stencil buffer in "layered-mode", but I don't know, if someone might miss it in this context...

Mathias - I Know What [you] Did Last Summer!
Offline Marvin Fröhlich

Senior Member




May the 4th, be with you...


« Reply #22 - Posted 2006-09-16 02:21:34 »

I took a quick look in the source. To configure ...

Great! Great!  Grin Thank you very much.

So to solve this, a new property - named "layered" for example - should be added to MultiPassView. If this is set to true, the two canvasPeer-properties should be set like the code at the top of this post for all render passes but the first one.

Isn't multipass rendering always layered? At least it should be the default. What is the effort of multipass rendering when it's not layered?

Marvin
Online cylab

JGO Ninja


Medals: 38



« Reply #23 - Posted 2006-09-16 02:35:37 »

Isn't multipass rendering always layered? At least it should be the default. What is the effort of multipass rendering when it's not layered?

Dunno... maybe to better organize your scene by using multiple independent scene graphs!? Anyway, making the layered variant the default is a good idea as long as there are no compatibility concerns to change the default behaviour of the MultiPassView...

Mathias - I Know What [you] Did Last Summer!
Offline Amos Wenger

Senior Member




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


« Reply #24 - Posted 2006-09-16 10:50:45 »

cylab, great to see you contribute !

When I saw "clearBuffers" I also had suspicion that it may be not only the depth buffer.

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

JGO Ninja


Medals: 38



« Reply #25 - Posted 2006-09-16 13:37:35 »

Quote
cylab, great to see you contribute !

How to proceed? Should I send a patch or can I have write access to the cvs rep?

I might contibute a little (render-to-texture in MultiPassView and terrain maybe), but I have little time due to work and am not always very motivated to code after a 10hour day with J2EE Wink

Mathias - I Know What [you] Did Last Summer!
Offline Amos Wenger

Senior Member




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


« Reply #26 - Posted 2006-09-16 14:11:44 »

Quote
cylab, great to see you contribute !

How to proceed? Should I send a patch or can I have write access to the cvs rep?

I might contibute a little (render-to-texture in MultiPassView and terrain maybe), but I have little time due to work and am not always very motivated to code after a 10hour day with J2EE Wink
Please register at xith-tk and I'll give you Developer access as soon as possible.

"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 Member




Java-positive...


« Reply #27 - Posted 2006-09-16 15:11:28 »

Great work cylab, I was waiting for multy-pass to really start working  Wink So looking forward to try it out when fix is comitted.
Thanks!
Offline Marvin Fröhlich

Senior Member




May the 4th, be with you...


« Reply #28 - Posted 2006-09-16 16:05:49 »

I might contibute a little (render-to-texture in MultiPassView and terrain maybe), but I have little time due to work and am not always very motivated to code after a 10hour day with J2EE Wink

The I'd suggest you to further concentrate on terrain. It is a frequently requested feature.
Online cylab

JGO Ninja


Medals: 38



« Reply #29 - Posted 2006-09-16 16:20:40 »

I thought about porting this, but haven't analysed it's source yet.

Mathias - I Know What [you] Did Last Summer!
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.

pw (26 views)
2014-07-24 01:59:36

Riven (25 views)
2014-07-23 21:16:32

Riven (19 views)
2014-07-23 21:07:15

Riven (22 views)
2014-07-23 20:56:16

ctomni231 (51 views)
2014-07-18 06:55:21

Zero Volt (46 views)
2014-07-17 23:47:54

danieldean (37 views)
2014-07-17 23:41:23

MustardPeter (40 views)
2014-07-16 23:30:00

Cero (56 views)
2014-07-16 00:42:17

Riven (55 views)
2014-07-14 18:02:53
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
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!