multiple worlds and clipping planes

Started by dutch_delight, September 24, 2011, 09:21:28 PM

Previous topic - Next topic

dutch_delight

Hi all

Just a quick question about multiple worlds and clipping planes.

I've got 2 worlds, one is my terrain and skydome and has a large clipping plane (200000) and I have a second world for my scenery objects with a clipping plane of 5000. The terrain object is about 4000 polygons and is my entire playing world.

My objects sit on top of the scenery but when my objects get in range, they seem to slowly emerge from beneath the terrain and visa versa if I move away from them, they look like they sink beneath the terrain.
I am not sure what is happening, if i have all my terrain and objects in the same world, they are fine but putting them in the second world it looks like they are moving in the Y axis.

I know, I know, I probably shouldnt use a clipping plane that large but I need the world to be as big as possible. And I dont want to draw all my objects in the same world because they would all be drawn even if they're miles away.

If there is no solution to this, is there perhaps another way to cull objects when they are a certain distance from the camera without having to loop through all of them?


Thanks for any suggestion and help
Rich

EgonOlsen

I'm not sure what the exact problem is...might be a zbuffer accuracy issue. IIRC, my own tried with such a far away clipping plane weren't very successful von Android either. Maybe a screen shot will help...

dutch_delight

Sorry for the late reply. doing stupid overtime at work so had no time to work on my game.

And sorry for the poor screenshot but here it is:
http://www.richterdesigns.co.uk/stuff/clipping.jpg

The ground surface has a large clipping plane and the objects are in a different world with a much lower clipping plane.
The building on the left is nearby but when i move backwards, it looks like it's sinking into the surface object. (the right image)
If i put all objects into the surface world, it's all fine and visa versa if i put everything into the objects world.


K24A3

If you change the FOV does that make a difference?

Are you changing the origins of the objects or translating everything from 0,0,0?

EgonOlsen

#4
Honestly, i'm not really sure what i'm seeing in this screenshot... ??? Anyway, it might be related to different scalings of the zbuffer. If that's the case, there's no other option than using one clipping plane for both worlds. Does it work if you set them both equal?

Edit: If you want to cull objects on your own, there's no other way than looping through all of the. That's not a big deal though. I'm doing this for the terrain scene in An3DBenchXL too, where i'm only rendering tress in view and at a limited distance. At that visibility border, the trees fade in softly.

dutch_delight

Sorry to open an old thread but I found out some more info.
My helicopter has a model with a transparant texture for the rotor blades. When I don't draw the blades the drawing order is fine. But when I do draw them. The problem occurs. Its like the building sinks into the landscape the further it gets from the camera. But it happens quite nearby so its quite obvious.
Its the same on my nexus s and archoid tablet.

K24A3

If you set the sort distance of the rotor blades to 100000 directly after loading the 3D file, does that make any difference?

myrotorblades.setSortOffset(100000);

EgonOlsen

If the problem persists, i need a test case to see what's going on...i can't tell from that screen shot as i've no idea what it actually shows. Is the ground actually transparent (if that brown stuff is a ground texture...)?

dutch_delight

Offset doesnt make a difference.

The brown stuff is the landscape and the dark grey box is a building. On this first screenshot it's sitting on top of the landscape. On the right screen, i've moved backwards so the building is further away and only the top half of the building is above ground. Nothing is transparant on the screenshots.


I'll get a test case done this weekend.


dutch_delight

Well, its nothing to do with transparancies i think.
here is my testcase. had to adjust it a bit to set it up like my game.
Move up and down to move away from the object. further it gets, the more it 'sinks'

www.richterdesigns.co.uk/stuff/ModelViewer.zip

thanks for looking into this.

EgonOlsen

#10
This comes from differences in the resolution of the zbuffer when using different far clipping planes. There's nothing you can do about this, except not to do it or, if the plane is always below the objects and doesn't interact with them in any way, you can change the render-calls to this:


fb.clear(back);
world.renderScene(fb);
world.draw(fb);
fb.clearZBufferOnly();
world_objects.renderScene(fb);
world_objects.draw(fb);
fb.display();


That will clear the depth buffer between rendering the two worlds.

dutch_delight