Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

nachilau

Problem when rendering a skybox

This topic is 5514 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, I have a problem when rendering a skybox. Currently, I render my skybox by disabling the zbuffer. Everything seems fine with this approach except I encounter a far clipping plane problem. The skybox appears just right after my far clipping plane. The scene doesn''t make sense when the character walks in a large open area since other objects may suddenly appear from the skybox when the character approaching those objects (because of the far clipping plane). Is there any solution of this problem... or I must used a extremely big skybox instead... but it will cause another problem since the character may never seen the skybox.... Thank for your help! Nachi

Share this post


Link to post
Share on other sites
Advertisement
I suggest moving the far clip plane so it's always behind the skybox and making the skybox big enough so that it's always behind on your scenery (assuming your scenery has some limit). For a z-buffer (as opposed to w-buffer) moving the far clip plane has much less effect on your z-buffer error distribution than moving the near clip plane (see http://groups.yahoo.com/group/opengl-gamedev-l/message/14257).

In my case I have skybox at 10,000 units, my world size is 1,000 units and my far clip plane is at 10,000,000 units. Though I don't really need to have that much room for error.

EDIT: changed 'front' to 'behind' and 'distribution' to 'error distribution'.

[edited by - soiled on November 5, 2003 9:07:30 PM]

Share this post


Link to post
Share on other sites
You should render the skybox with depth test and depth write disabled. The size of the skybox has nothing to do with your far clipping plane or objects popping into view at distance.

Share this post


Link to post
Share on other sites
Sorry, but I think your approach doesn''t really work. It is becuase I cannot set my far clipping plane to such big value. Since I am using octree to reduce number of polygons that drawn to the screen, so I need to make the far clipping plane as tight as it can.

Nachi


quote:
Original post by Soiled
I suggest moving the far clip plane so it''s always behind the skybox and making the skybox big enough so that it''s always behind on your scenery (assuming your scenery has some limit). For a z-buffer (as opposed to w-buffer) moving the far clip plane has much less effect on your z-buffer error distribution than moving the near clip plane (see http://groups.yahoo.com/group/opengl-gamedev-l/message/14257).

In my case I have skybox at 10,000 units, my world size is 1,000 units and my far clip plane is at 10,000,000 units. Though I don''t really need to have that much room for error.

EDIT: changed ''front'' to ''behind'' and ''distribution'' to ''error distribution''.

[edited by - soiled on November 5, 2003 9:07:30 PM]


Share this post


Link to post
Share on other sites
nachilau:
what do you mean by saying the far clipping plane has to do something with your octree?

you reduce the number of polygons with an octree algorithm so the number you draw is only affected by your octree (and clipper) not by your far clipping plane. If you rely on OpenGL''s clipping planes to do the culling you are doing something wrong.

Besides that setting the clipping planes to high values is not a good idea as the zbuffer gets more inaccurate the greater the distance is it has to cover.

So what fingers said is the best solution:
disable zbuffer reads&writes
draw skybox (doesn''t have to cover the whole world as the z buffer takes out the places where your world is drawn)
reenable zbuffer writes
draw your world

Share this post


Link to post
Share on other sites
Soiled> hem... my skyboxes used to be a 5 units cube and I had objects displayed more than 10000 units away... like Fingers_ said, the size absolutely doesn't matter, as long as it doesn't intersect with your _near_ clipping plane (in my case, that was 2)

edit: lousyphreak:
would be better that way:

load identity matrix
apply camera rotations
disable zbuffer reads&writes
draw skybox (doesn't have to cover the whole world as the z buffer takes out the places where your world is drawn)
load camera matrix (rotations + translations)
reenable zbuffer writes
draw your world






[edited by - sBibi on November 6, 2003 2:22:00 AM]

Share this post


Link to post
Share on other sites
quote:
sBibi wrote
Soiled> hem... my skyboxes used to be a 5 units cube and I had objects displayed more than 10000 units away... like Fingers_ said, the size absolutely doesn't matter, as long as it doesn't intersect with your _near_ clipping plane (in my case, that was 2)


Yeah I agree and that's what I used to do on my old gf1 but I had strange clipping problems so I've since just made the skybox really large (which also works fine). I should go back to the sensible way to do it though. Actually I think the clipping problems I was having were somehow due to mapping the viewport z range from [0,1] to [1,1].
quote:
LousyPhreak wrote
Besides that setting the clipping planes to high values is not a good idea as the zbuffer gets more inaccurate the greater the distance is it has to cover.


Yes, but not by much (see http://groups.yahoo.com/group/opengl-gamedev-l/message/14257).

EDIT: The problem I had with my old gf1 is described here (http://discuss.microsoft.com/SCRIPTS/WA-MSD.EXE?A2=ind0207A&L=DIRECTXDEV&P=R7394&I=-3).


[edited by - soiled on November 6, 2003 8:29:22 AM]

Share this post


Link to post
Share on other sites
Actually, for my scenario this works best (note, draw world *first* instead of *last*)...

- clear z to 1
- draw world,
- zbuffer-tests-on/zbuffer-writes-off/zbuffer-func-lessequal,
- draw skybox (either make skybox larger than world or set screen_space_z = screen_space_w in vs so that screen-space z/w is 1... ie larger than any generated by the world).

...this way the world occludes sky and saves fillrate when drawing sky (especially if using multiple passes with expensive pixel shaders to do dynamic clouds on the sky).

[edited by - soiled on November 6, 2003 8:48:23 AM]

Share this post


Link to post
Share on other sites
i personally use a small skybox of 10unit edges. Irrespective of its size compared to the world, just enable depth test but disable depth write... then render the skybox first before all else. Reenable depth writing and do everything else u need to do.

also, this way, u can disable color-buffer clearing coz ideally the skybox sorta masks the entire scene background, unless u have alpha.. hrm.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!