Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (499)
Games in Android Showcase (118)
games submitted by our members
Games in WIP (567)
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  
  Simple fbo question  (Read 887 times)
0 Members and 1 Guest are viewing this topic.
Offline RobinB

JGO Ninja


Medals: 44
Projects: 1
Exp: 3 years


Spacegame in progress


« Posted 2013-04-03 17:05:53 »

Hello,

Having some obvious problems again with redering.

Im having this terrain:


Now i want to make the water reflective, whats obviously done using an frame buffer object.
The world is build up with chunks, rendering max 4 chunks at the same time.

How should i render to an fbo?
- Just send the current screen to the fbo, and figure out how it must be transferred to match the right position.
- Draw every (visible) Chunk to the fbo separately?

Also im ondering how i should transform the view before rendering to an fbo, should i keep the same transformation (excluding rotation), or do i need to transform to the right psition fist (like top view).
Also wat parameters should i use for glClipPlane(GL_CLIP_PLANE0, clipbuffer);


At last im having an overall question about rendering the chunks.
Whem im rendering an whole chunk at once im getting these blending errors:


This is caused because an transparent texture blends with the green background, the chunk behind it is drawn after that.
Is there some solution for this or should i first render all ground, then trees and other objects, then water, like this:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
            for(int tx = 0; tx < 3; tx ++){
                for(int ty = 0; ty < 3; ty ++){
                    if(c[tx + ty*3] != null){
                        c[tx + ty*3].Draw();
                    }
                }
            }
           
            for(int tx = 0; tx < 3; tx ++){
                for(int ty = 0; ty < 3; ty ++){
                    if(c[tx + ty*3] != null){
                        c[tx + ty*3].DrawObjects();
                    }
                }
            }
           
            for(int tx = 0; tx < 3; tx ++){
                for(int ty = 0; ty < 3; ty ++){
                    if(c[tx + ty*3] != null){
                        c[tx + ty*3].DrawWater();
                    }
                }
            }
Offline Riven
« League of Dukes »

JGO Overlord


Medals: 801
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #1 - Posted 2013-04-04 06:12:13 »

First you render all opaque geometry, roughly front-to-back, to reduce overdraw.
Then you render all translucent geometry, strictly back-to-front, or it will show artifacts.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline RobinB

JGO Ninja


Medals: 44
Projects: 1
Exp: 3 years


Spacegame in progress


« Reply #2 - Posted 2013-04-04 09:19:57 »

Thank you, i was afraid of that, but i thought to ask it first, just to be sure.
And does anyone have an idea about the reflective water?
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline RobinB

JGO Ninja


Medals: 44
Projects: 1
Exp: 3 years


Spacegame in progress


« Reply #3 - Posted 2013-04-04 12:42:18 »

Really annoying, i dont get this transformation stuff.
Please anyone, im really clueless.

My current try (im not rendering the terrain on top, because the water would otherwise not be visible much):


As visible my problem is the needed transformation, the clip plane is not really working and my textures are only filled with an quarter of the terrain im actually rendering (to the fbo texture).

Code:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
     //Fill current fbo's without transformation:

        GL11.glPushMatrix();
           
            TiltWorld();
            for(int tx = 0; tx < 3; tx ++){
                for(int ty = 0; ty < 3; ty ++){
                    if(c[tx + ty*3] != null){
                        c[tx + ty*3].PreDraw();
                    }
                }
            }
           
        GL11.glPopMatrix();

       //Draw land / water and trees;


PreDraw:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
    public void PreDraw(){
        clipbuffer.rewind();
        fbo.Bind();
        //fbo.ClipPlane();
       
        glEnable(GL_CLIP_PLANE0);  
        glClipPlane(GL_CLIP_PLANE0, clipbuffer);  
        glPushMatrix();    
         
            glTranslatef(-x, 0, -z);
            Draw();
            DrawObjects();
           
        glPopMatrix();
        glDisable(GL_CLIP_PLANE0);  
       
        fbo.Unbind();
    }
   
    private DoubleBuffer clipbuffer = BufferUtils.createDoubleBuffer(4).put(new double[]{ 0, -1, 0, 0.0 });
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.

Pippogeek (35 views)
2014-09-24 16:13:29

Pippogeek (28 views)
2014-09-24 16:12:22

Pippogeek (17 views)
2014-09-24 16:12:06

Grunnt (40 views)
2014-09-23 14:38:19

radar3301 (23 views)
2014-09-21 23:33:17

BurntPizza (59 views)
2014-09-21 02:42:18

BurntPizza (29 views)
2014-09-21 01:30:30

moogie (34 views)
2014-09-21 00:26:15

UprightPath (47 views)
2014-09-20 20:14:06

BurntPizza (51 views)
2014-09-19 03:14:18
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

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
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!