Author Topic: Fogging problems  (Read 6930 times)

Offline Zyphuris55

  • byte
  • *
  • Posts: 30
    • View Profile
Fogging problems
« on: June 12, 2012, 08:10:54 am »
I think this is a bug because it happens without any apparent logic.
In the game play part of my game, I have the game objects rendered in one world and the hud objects rendered in another world (so they would stay static while the rest of the game move). The game objects have transparency, while the hud objects don't.

On the first render frame, it renders the scene for both worlds and then draws the worlds (game then hud), but it's not displaying the fog on the game play's world objects. When I disable the rendering/ drawing of the hud world, the first render has the fog enabled.
With the hud world enabled and the scene incorrectly displaying, after touching the screen, the fog re-enables.

I tried using the framebuffer's clearZBufferOnly() before the hud's render/ draw line, but that didn't do anything. Then I played with some code which would render/ draw the worlds twice on only the first render frame, but that also did nothing. I also tried to disable the fog in the HUD's world (not sure how that would be helped)....but it also didn't do anything. Lastly, I disabled all the lighting in the HUD's world, both ambient light and any other lights added to the world, but the only thing that did was make the hud objects black.

= Gameplay code
Code: [Select]
boolean firstR = true;
public void Render(FrameBuffer fb)
{
/*
if(firstR)
{// attempted fix, which does nothing
world.renderScene(fb);
world.draw(fb);
fb.clearZBufferOnly();

hud.Render(fb);
}
*/

if((Touching || resetting) || firstR)
world.renderScene(fb);
firstR = false;

world.draw(fb);
//fb.clearZBufferOnly();
hud.Render(fb);
}


= HUD render code
Code: [Select]
private boolean render = true;
void Render(FrameBuffer fb)
{
if(render)
world.renderScene(fb);
render = false;

world.draw(fb);
}



Note: the renderScenes are linked to bool requirements so the worlds won't be needlessly rendering every frame (it made my phone hot and the fps slow).


The HUD currently only has 1 thing, which is the bottom left

= Pre-touch


= Post-touch (ignore the half-lighted/half-darked block, the picture was taken between render frames)

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11769
    • View Profile
    • http://www.jpct.net
Re: Fogging problems
« Reply #1 on: June 12, 2012, 08:27:16 am »
Which OpenGL version are you using? 1.x or 2.0?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11769
    • View Profile
    • http://www.jpct.net
Re: Fogging problems
« Reply #2 on: June 12, 2012, 08:41:05 am »
Have you tried to use another color than black as fog color?

And could you please set the log level in Logger to debug, set Config.glDebugLevel=1 and post the ouput for the first two frames (might be a bit large...)?

Offline Zyphuris55

  • byte
  • *
  • Posts: 30
    • View Profile
Re: Fogging problems
« Reply #3 on: June 12, 2012, 09:31:32 am »
I'm using OpenGL 2.0

...it was REALLY hard to get the logs, lol. I had to remove the 80,000 limit and be quick on the pause button. Even still, they are pretty lengthy.

Loga: Starts as soon as I clicked the button to go to the game play and paused after the first image was visible.
Logb: (cleared the first log first). Touched the screen which re-enabled the fogging, then paused it after the image what changed.

I haven't tried anything besides using "world.setFogParameters(20, 60, 0, 0, 0);". I didn't feel a fog of other than black would look good.

[attachment deleted by admin]

Offline Zyphuris55

  • byte
  • *
  • Posts: 30
    • View Profile
Re: Fogging problems
« Reply #4 on: June 12, 2012, 09:46:01 am »
I went through both logs now, looking for any differences...and I couldn't find any :-/. Does being an engine developer give you a more detailed eye than a normal coder would? lol

Anyway, if the log's aren't too helpful, I'd gladly send you the project for you to check out yourself.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11769
    • View Profile
    • http://www.jpct.net
Re: Fogging problems
« Reply #5 on: June 12, 2012, 10:30:39 am »
These logs don't look complete to me. Neither of them contains output about setting the fog values nor a call to glClear. Anyway, i'll try to create a test case for this myself this evening. If that doesn't work out, i'll need your project to track this down.

Offline Zyphuris55

  • byte
  • *
  • Posts: 30
    • View Profile
Re: Fogging problems
« Reply #6 on: June 12, 2012, 11:06:13 am »
Previously, the game had the "Config.glDebugLevel=1;" line in the creation of the render (which currently renders the menu and gameplay, I'm working on switching them to different activities). So I switched the line to be in onDrawFrame part of the render.

Code: [Select]
public void onDrawFrame(GL10 gl)
{
if(Screen == 1 && Screens.size() == 1)
{
Config.glDebugLevel=1;
Screens.put(1, new Gameplay());
}

fb.clear(back);

Screens.get(Screen).Render(fb);

//FPS(fb);
       
        fb.display();
}

but, the log seems to show nothing besides loading the objects and compiling them. There isn't even any gl calls like in the previous 2 logs.

I also changed the gameplay render function so it would draw the objects every frame...and nothing :-/

Code: [Select]
boolean firstR = true;
public void Render(FrameBuffer fb)
{
if((Touching || resetting) || firstR)
world.renderScene(fb);
firstR = false;

world.draw(fb);
//fb.clearZBufferOnly();
hud.Render(fb);
}

note: the renderer doesn't contain a world, only a framebuffer which it sends to the menu and gameplay classes. The creation of the gameplay/ menu class makes a new world just for that class.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11769
    • View Profile
    • http://www.jpct.net
Re: Fogging problems
« Reply #7 on: June 12, 2012, 08:34:55 pm »
I tried to create a test case, but i can't reproduce the problem. I created a fogged main world and a non-fogged additional world, rendered them in that order in GL 2.0 mode and everything looked fine even for the first frame. I need to project or a simplified test case to track this down...

Offline Zyphuris55

  • byte
  • *
  • Posts: 30
    • View Profile
Re: Fogging problems
« Reply #8 on: June 13, 2012, 12:35:35 am »
Hmm...ok. Well, currently, I don't have a stable release. Last night I started converting the project from one activity to multiple activities and the process isn't complete yet. I can't even give the classes in question because I've already changed them for the activity conversion. But, as soon as it's at a stable spot, I'll send the project.
What email can I send it to when it's ready (if the problem still persists)?


Edit: The game is at a stable release now and the problem is still there
« Last Edit: June 13, 2012, 04:00:45 am by Zyphuris55 »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11769
    • View Profile
    • http://www.jpct.net
Re: Fogging problems
« Reply #9 on: June 13, 2012, 07:03:15 am »
Just send it to info@jpct.net. I'll look at it this evening.

Offline Zyphuris55

  • byte
  • *
  • Posts: 30
    • View Profile
Re: Fogging problems
« Reply #10 on: June 13, 2012, 07:23:13 am »
Ok, it's sent. And thank you for helping me with the problems.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11769
    • View Profile
    • http://www.jpct.net
Re: Fogging problems
« Reply #11 on: June 13, 2012, 09:11:41 pm »
The problem is caused by the way you are dealing with the calls to renderScene(). If nothing in the scene has changed, you simply omit them. That this works is more by chance than intended... ;) The actual idea was to call both (or neither) every frame. However, i see the idea behind this...i've uploaded a jar that should fix this particular problem: http://jpct.de/download/beta/jpct_ae.jar

Anyway, i'm not 100% sure that this is the only part that might cause problems if you do it this way. So in case of doubt, try to call renderScene()/draw() for each frame and see if that helps.

Offline Zyphuris55

  • byte
  • *
  • Posts: 30
    • View Profile
Re: Fogging problems
« Reply #12 on: June 13, 2012, 11:26:51 pm »
I'm a bit confused on your reply. Currently I have it so it renders only the first scene or when the models are being changed, and on every frame it draws the scene (because it's parent class clears the framebuffer). I changed it from rendering every scene to only when needed to help prevent the phone from over-heating.
From what I can guess in your reply, your saying that the world.draw(fb) after the world.renderScene(fb) is a redundant call?

I'll try the jar as soon as I can.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11769
    • View Profile
    • http://www.jpct.net
Re: Fogging problems
« Reply #13 on: June 14, 2012, 08:19:12 am »
From what I can guess in your reply, your saying that the world.draw(fb) after the world.renderScene(fb) is a redundant call?
No, what i tried to say was that every call to draw() should be preceded by a call to renderScene(). However, with the new jar, this shouldn't be a problem. At least not in this case.

Offline Zyphuris55

  • byte
  • *
  • Posts: 30
    • View Profile
Re: Fogging problems
« Reply #14 on: June 14, 2012, 08:26:05 am »
Oh...now I can see of why you said it was surprising that it actually worked, lol.

I still haven't tried the jar yet, I've been busy with other things that are for this weekend.