Sign in to follow this  

Object disappears after setting Projection

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

Hey, I'm trying to create a skybox. In my game, my meshes render just fine. But when I create a skybox (6 textured quads) nothing appears. So I tried messing around with quads(loading textures onto vertex buffers and rendering). When I render my quad at 0,0,1 it appers fine. But when I render my quat at 0,0,1.000001, it dissappears (a little exxaguration, but you know what I mean, any Z > 1, it disappears) Yes, I'm clearing my ZBuffer, and Yes, i'm setting a ZDepth of 1 D3Ddev.Clear(ClearFlags.Target Or ClearFlags.ZBuffer, Color.FromArgb(0, 0, 225), 1.0, 0) (1.0 is the max it can go). So I thought it had to do with the Projection matrix. When i set up the projection matrix: D3Ddev.Transform.Projection = Matrix.PerspectiveFovLH(System.Convert.ToSingle(Math.PI) / 4, mDisplaymode.Width / mDisplaymode.Height, 1.0F, 1000.0F) the object disappears altogether! even when the Z is set to 1. Does anyone know how to fix these problems? All i want to do is use that same projection matrix, and a matrix LookAtLH to render my meshes as well as quads. For some reason any quad with a Z > 1 disappears. Thanks pent

Share this post


Link to post
Share on other sites
what is your world and view matrix set to?
paste the code that you use to position your quad. Are you rendering using the ID3DXSprite interface? That requires a worldview transform to be set..
Also check the normals of the skybox, if you turn off culling and can see it then your problem is inverted normals.

Share this post


Link to post
Share on other sites
My object is centered (by default) at 0,0,0.
Its height,depth,and width are 512. so the backleft coordinate is (-256,-256,-256), its far right coordinate is (256,256,256)

My World is set to Identity.

My View is set to:
D3Ddev.Transform.View = Matrix.LookAtLH(new Vector3(0,0,0), New Vector3(0, 0, 1), New Vector3(0, 1, 0))

My Projectoin is set to:
D3Ddev.Transform.Projection = Microsoft.DirectX.Matrix.PerspectiveFovLH(CSng(Math.PI) / 4, 800.0F / 600.0F, 0.0F, 300.0F)

Nah, I'm not using a d3dxsprite, i created my own class (using CustomVertex.PositionTextured)

I turned Culling and I can't see it :).;

Share this post


Link to post
Share on other sites
Never set your nearZ to 0. It's recommended to make it as large as possible. Also, it's recommended to keep the ratio of farZ to nearZ less than 1000.

Setting nearZ to 0 totally messes up the z-buffer (if you look into how perspective projection matrices are formed, you'll find that there are divisions by nearZ in more than one place).

Share this post


Link to post
Share on other sites
Thanks,
But unfortunately, it didn't work

D3Ddev.Transform.Projection = Microsoft.DirectX.Matrix.PerspectiveFovLH(CSng(Math.PI) / 4, 800.0F / 600.0F, -300.0F, 300.0F)

didn't work

D3Ddev.Transform.Projection = Microsoft.DirectX.Matrix.PerspectiveFovLH(CSng(Math.PI) / 4, 800.0F / 600.0F, 1.0F, 300.0F)

also didn't work

edit:
D3Ddev.Transform.Projection = Microsoft.DirectX.Matrix.PerspectiveFovLH(CSng(Math.PI) / 4, 800.0F / 600.0F, 1000, 8000.0F)

didn't work either.

pent

Share this post


Link to post
Share on other sites
Someone told me it was becuase the winding order of my vertices was ccw, so he told me to do scale by (-1,-1,-1)

I tried:
D3Ddev.Transform.World = Matrix.Multiply(D3Ddev.Transform.World, Matrix.Scaling(New Vector3(-1, -1, -1)))

and

D3Ddev.Transform.World = Matrix.scaling(New Vector3(-1, -1, -1)))

Share this post


Link to post
Share on other sites

This topic is 4867 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this