Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (539)
Games in Android Showcase (132)
games submitted by our members
Games in WIP (603)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1]
1  Java Game APIs & Engines / Java 3D / Re: Offscreen render target slowdown on: 2007-07-10 12:39:14
Well, we made no progress with this problem so we side-stepped it. I put an nVidia card in my machine and it runs just fine, but now there's another problem.

I use a frame buffer object as a render target. It has a texture attached for both depth and pixels as I need to use both in post-processing. I then render a quad to the screen, and my pixel buffer renders just fine. However my depth buffer is solid white - it's as if it was never written to. Yet my pixel buffer wouldn't render correctly without depth information (and it does). So what the heck is going on?

This is the business end of my FBO wrap:

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  
    private void createBuffers()
    {
        int [] params = new int [1];
        gl.glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, frameBufferID );        
       
        if ( (flags & PIXEL_BUFFER) != 0 )
        {  
            // Create a colour pixel texture.
            gl.glGenTextures( 1, params, 0 );
            pixelBufferID = params[0];
            gl.glBindTexture( GL_TEXTURE_2D, pixelBufferID );
            gl.glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA8,  width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, null );
           
            // Default and user setup.
            gl.glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
            gl.glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );                        
            setUpPixelBuffer( gl );        
           
            // Attach to the frame buffer.
            gl.glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, pixelBufferID, 0 );                
        }
        else        
        {
            // No pixel drawing required do shut down the read / write channels.
            gl.glDrawBuffer( GL_NONE );
            gl.glReadBuffer( GL_NONE );
        }

        if ( (flags & DEPTH_BUFFER) != 0 )
        {
            // Create a depth texture.
            gl.glGenTextures( 1, params, 0 );
            depthBufferID = params[0];          
            gl.glBindTexture( GL_TEXTURE_2D, depthBufferID );
            gl.glTexImage2D( GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, width, height, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, null );                            
           
            // Set the texture quality
            gl.glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
            gl.glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
            gl.glTexParameterf( GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE, GL_INTENSITY );
           
            setUpDepthBuffer( gl );
           
            // Attach depth buffer to the frame buffer.
            gl.glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, depthBufferID, 0 );
        }
                   
        int status = gl.glCheckFramebufferStatusEXT( GL_FRAMEBUFFER_EXT );
        if ( status != GL_FRAMEBUFFER_COMPLETE_EXT )
        {
            String errorMsg = getErrorMessage( status );
            throw new Error( "Could not create offscreen render target - " + errorMsg );
        }        

        gl.glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, 0 );        
    }


To use it I bind, render the scene, unbind - and I should have a useable pixel and depth texture. *Should*! Can anyone help?
2  Java Game APIs & Engines / Java 3D / Offscreen render target slowdown on: 2007-07-04 15:17:56
In our app, we are wanting to implement some post-render effects that use both pixel data and z-depth. We generally run at high res, with screen dims ~ 1500 x 1000 (ie big and not a power of 2). In order to do this, I first implemented a Frame Buffer Object, rendered our scenes into that, and copied the result onto a visible quad. This resulted in a MASSIVE slowdown on my 256MB ATI card. On a 512MB nVidia card, it ran fine, however.

Conclusion: either I'm running out of card memory (though a quick calculation of how much space might be required for one of our scenes comes to about 50MB); OR something within ATI is broken. I want to test on a 256MB nVidia card but we don't have one here   Sad

So I tried a few experiments. First, I changed it so that I rendered to the screen again (frame rate around 40-50) but then copied the pixels and z into two auxiliary textures using glCopyTexture2D(). That was quicker - but only by a shade over the FBO case. Then I shrunk the size of the window (to less than 1024 x 768 and then 640 x 480) ; if it was running out of vRAM, you might expect to see a sudden speed-up, but instead there was just a very gradual increase. If I take the copying code out, it runs at normal speed again.

So I'm baffled now. Has anyone got any bright ideas as to what might be going on, or how to work around this?

Update: it now seems that it's the z-buffer copy that's really dragging, the pixel copy seems  fine. I've tried fixing the buffer to be 512 x 512 and there's no change, so it's nothing to do with not being a power-of-2 size. Bizarrely, our old shadow mapping code used this exact same technique with no drop in frame rate. So maybe it's something to do with state?  Undecided
3  Java Game APIs & Engines / JOGL Development / Re: Using a depth buffer as a texture on: 2007-05-31 15:55:28
Bah, I went ahead and wrote a CG shader, which was an education for me. Works nicely now (though I'd still like to know what was missing  from the above Huh )
4  Java Game APIs & Engines / JOGL Development / Re: Using a depth buffer as a texture on: 2007-05-31 14:29:17
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  
            GL gl = view.getGL ();
            GLU glu = view.getGLU ();
           
        /* 2D setup */
            gl.glPushAttrib( GL_ALL_ATTRIB_BITS );
            gl.glPushClientAttrib( (int)GL_CLIENT_ALL_ATTRIB_BITS );
            gl.glDisable( GL_LIGHTING );
            gl.glDisable( GL_DEPTH_TEST );
            gl.glDepthMask( false );
            gl.glMatrixMode( GL_PROJECTION );
            gl.glPushMatrix();
            gl.glLoadIdentity();
           
            int width = view.getDrawable().getWidth();
            int height = view.getDrawable().getHeight();
            glu.gluOrtho2D( 0, width, 0, height );
            gl.glEnable( GL_TEXTURE_2D );
           
            gl.glMatrixMode( GL_MODELVIEW );
            gl.glPushMatrix();
            gl.glLoadIdentity();
            gl.glDisable( GL_TEXTURE_COMPARE_MODE );
                       
        /* Render */
            int depthBufferID = frameBuffer.getDepthBufferID();
            gl.glBindTexture( GL_TEXTURE_2D, depthBufferID );
            gl.glBegin( GL_QUADS );
            //gl.glColor3f( 1.0f, 0.0f, 0.0f );
            gl.glTexCoord2f( 0.0f, 0.0f );
            gl.glVertex2f( 0, 0 );
            //gl.glColor3f( 0.0f, 1.0f, 0.0f );
            gl.glTexCoord2f( 1.0f, 0.0f );
            gl.glVertex2f( 256, 0 );
            //gl.glColor3f( 0.0f, 0.0f, 1.0f );
            gl.glTexCoord2f( 1.0f, 1.0f );
            gl.glVertex2f( 256, 256 );
            //gl.glColor3f( 1.0f, 1.0f, 0.0f );
            gl.glTexCoord2f( 0.0f, 1.0f );
            gl.glVertex2f( 0, 256 );
            gl.glEnd();
           
        /* 2D teardown */
            gl.glMatrixMode( GL_PROJECTION );
            gl.glPopMatrix();
            gl.glMatrixMode( GL_MODELVIEW );
            gl.glPopMatrix();
            gl.glDepthMask( true );
            gl.glEnable( GL_DEPTH_TEST );            
            gl.glPopClientAttrib();
            gl.glPopAttrib();            
5  Java Game APIs & Engines / JOGL Development / Using a depth buffer as a texture on: 2007-05-31 12:12:34
Hi

What's the best way to use a (texture configured as a) depth buffer as an actual texture? Preferably without having to write a shader!

I tried just binding and using, but I get a uniform grey rectangle.

Cheers

IA
6  Java Game APIs & Engines / JOGL Development / JOGL and Frame Buffer Objects on: 2007-05-30 14:20:01
I'm getting an error when creating my frame buffer object:

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  
        GL gl = new DebugGL( drawable.getGL() );
        int [] params = new int [1];
        gl.glGenFramebuffersEXT( 1, params, 0 );
        frameBufferID = params[0];        
        gl.glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, frameBufferID );        
       
        if ( (flags & PIXEL_BUFFER) != 0 )
        {  
            pixelBufferID = bind( drawable );
            gl.glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA8,  width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, null );                
            gl.glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, pixelBufferID, 0 );                
        }
        else        
        {
            gl.glDrawBuffer( GL_NONE );
            gl.glReadBuffer( GL_NONE );
        }

        if ( (flags & DEPTH_BUFFER) != 0 )
        {
            gl.glGetIntegerv( GL_DEPTH_BITS, params, 0 );
            int depthBits = params[0];        
            int depthFormat = (depthBits == 16) ? GL_DEPTH_COMPONENT16_ARB : GL_DEPTH_COMPONENT24_ARB;
           
            gl.glGenTextures( 1, params, 0 );
            depthBufferID = params[0];          
            gl.glBindTexture( GL_TEXTURE_2D, depthBufferID );
            gl.glTexImage2D( GL_TEXTURE_2D, 0, depthFormat,  width, height, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, null );                
            gl.glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, depthBufferID, 0 );
           
            // Set the texture quality
            gl.glTexParameterf( GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST );
            gl.glTexParameterf( GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST );
            gl.glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER );
            gl.glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER );
            gl.glTexParameterfv( GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, new float[] {1f,1f,1f,1f}, 1 );            
            gl.glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB, GL_COMPARE_R_TO_TEXTURE );
            gl.glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC_ARB, GL_LEQUAL );
        }
                   
        int status = gl.glCheckFramebufferStatusEXT( GL_FRAMEBUFFER_EXT );
        if ( status != GL_FRAMEBUFFER_COMPLETE_EXT )
        {
           System.out.println( "*** Error: OffScreenRenderTarget did not set up frame buffer object correctly (" + status + ")" );
        }        

        gl.glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, 0 );


The return code from glCheckFramebufferStatusEXT() is GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT but it looks fine to me. Can anyone here spot my bad? (I'm running Windows XP, with ATI Radeon X1900 GT).
Pages: [1]
 

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

The first screenshot will be displayed as a thumbnail.

rwatson462 (33 views)
2014-12-15 09:26:44

Mr.CodeIt (24 views)
2014-12-14 19:50:38

BurntPizza (51 views)
2014-12-09 22:41:13

BurntPizza (84 views)
2014-12-08 04:46:31

JscottyBieshaar (46 views)
2014-12-05 12:39:02

SHC (60 views)
2014-12-03 16:27:13

CopyableCougar4 (61 views)
2014-11-29 21:32:03

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

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

toopeicgaming1999 (32 views)
2014-11-26 15:20:08
Resources for WIP games
by kpars
2014-12-18 10:26:14

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
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!