Jump to content
  • Advertisement
Sign in to follow this  
Dark_Light

Far away objects

This topic is 4965 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

Can anyone tell me how to force a very distant object to draw even though its way out size the zbuffer. I am turning the zbuffer of temporarily but this is not working! Sounds like such an easy thing, I can’t believe I am stuck on it.

Share this post


Link to post
Share on other sites
Advertisement
Are you sure you're turning off z-buffer comparison? Because merely turning off z-write won't help.

Alternatively, it's possible you need to disable clipping or circumvent it somehow. To be honest I don't know if this is necessary - in my game the zfar distance is infinity so it's not a problem!

Share this post


Link to post
Share on other sites
Do you have your projection matrix set up with a really big distance? What is the value for you far clipping frustrum?

Share this post


Link to post
Share on other sites
You will want to set the render state to

Compare.Always

This will force the object to always pass the Z-buffer test. After you draw your stuff you will likely want to set it back to LessEqual (ie. Default setting).
You can see the specifics of this on the MSDN link:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_m/directx/ref/ns/microsoft.directx.direct3d/e/compare/compare.asp

Edit: Forgot to mention, you want to be setting the ZBufferFunction to Compare.Always (as opposed to StencilFunction, AlphaFunction, CounterClockwiseStencilFunction)

Share this post


Link to post
Share on other sites
Hmm done all that and not having any success.
in fact i am getting really wearied results.

I have a 3D world and i am trying to make a sky.

The shy is FAR away and way beyond the limits of the Z-buffer. But i want to force it to draw then i will draw anything else over the top.

however i cant extend my Zbuffer to that size else i will Over stretch the z-buffer.

Have any of you done this type of thing before?. No matter what i do my sky only draws when i am close and stop drawing when i get VERY close.. its odd indeed.

Share this post


Link to post
Share on other sites
Some of the code i am using while testing

code is from diferent parts of the porject..

myDevice.Transform.Projection = Matrix.PerspectiveFovLH ((float)(Math.PI / 4),this.Width / this.Height ,1f,5000);

myDevice.Clear(ClearFlags.Target | ClearFlags.ZBuffer,Color.SkyBlue,1f,0);

DirectXDevice.RenderState.ZBufferFunction = Compare.Always;
SkyDome = Mesh.Sphere(DirectXDevice,8000,12,12);
DirectXDevice.RenderState.CullMode = Cull.None;
SkyDome.DrawSubset(0);
DirectXDevice.RenderState.CullMode = Cull.CounterClockwise;
DirectXDevice.RenderState.ZBufferFunction = Compare.LessEqual;

Share this post


Link to post
Share on other sites
Just turn of writing to z buffer , and draw the sky (skybox i assume) close. It doesn't have to be far like real sky, it just has to look right. And then turn on writing to z buffer, and draw your scene.

Share this post


Link to post
Share on other sites
Ah, well thats a simple solution if your just drawing a backdrop. Just draw the envirnoment sphere/box or whatever and make it just large enough to fill the camera view properly.... draw with the Zbuffer write and read turned off. Turn it back on after the draw and everything that is subsequently drawn will all be over top of that backdrop with no need to have insanely huge distances involved. (EDIT: Sorry for the repeat, but it guess the previous post was made while I was typing this)

Also, I THINK that the MeshSphere object does not have texture coordinates on it either, so it may not be showing up because of that.

Share this post


Link to post
Share on other sites
It dont work.. when you move away from the sky it stops drawing.
Even of the zbuffer is off!
somthing stop it from drawing when its far away!

Share this post


Link to post
Share on other sites
Hmm its a pain as i cant show images.

Let me get this strait.

My world is MASIVE! very large indeed. that’s all fine but even if i draw the sky at the edge of my world it going to be to far away when i am in the centre and look out at it.

If i shrink the sky surly it will look shit when i render it? plus it will have to be centred on me else i could still move away from it by to grater distance? and so if its centred in me its going to look shit?

So i am no sure i understand the solution you suggest, surely it will not work?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!