Far away objects

Started by
20 comments, last by Dark_Light 19 years, 5 months ago
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.
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!
The Trouble With Robots - www.digitalchestnut.com/trouble
Do you have your projection matrix set up with a really big distance? What is the value for you far clipping frustrum?
Sean Henley [C++ Tutor]Rensselaer Polytechnic Institute
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)
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.
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;
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.
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.
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!
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?

This topic is closed to new replies.

Advertisement