Sign in to follow this  

[MDX] HLSL Terrain & Mesh.DrawSubset: Inconsistant relative positions

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

I'm drawing a few different things in the same scene in 2 seperate ways: -Terrain built from a grayscale heightmap: -Positioned, Drawn, and Lit with an HLSL Effect. -Several Meshes (Tigers and a SkyBox) -Positioned with Transform.World, Drawn with Mesh.DrawSubset. Every render, I create one view matrix and one projection matrix, and I pass a copy of them off to each seperate positioning process. The terrain gets them as an effect handle and the meshes get them with Transform.World. So, it is the EXACT same view and projection matrix, and the terrain and SkyBox are both positioned on the origin, BUT: When I move the camera's position or orientation, the positions of the skybox (and other meshes) relative to the Terrain CHANGES. For instance, if I wiggle the orientation of the camera, the terrain moves before the skybox, and it looks very weird. Furthermore, If a place a tiger mesh at a fixed position on the terrain, That Position relative to the Terrain CHANGES as I move the camera around the scene. To be clear, If I move backward while looking at the terrain and mesh at the same time, the mesh moves away from me at about twice the speed of the terrain, and he exists at a different location on the terrain. I am NOT putting any variables into the mesh's position, just fixed values. My question is: Are these two pipelines intended to be mixed in the same scene or must they be seperate? In other words, If I position something with an Effect, do I have to do everything in HLSL? If I position something with Transform.World, do I have to position Everything that way and not use HLSL?? If So, that sucks, but it makes sense that two completely different ways of drawing things would end up with slightly different outputs. If Not, Where could my error lie? Tell me If I should post bits of code, And THANK YOU! Note: I have used Line.DrawTransform to draw lines on the X,Y,Z axis and the lines are locked exactly to the terrain. So It's Terrain & Lines VS Skybox & Tigers. All Meshes have the same positions relative to eachother.

Share this post


Link to post
Share on other sites
Well I figured it out the waste 3 days way...

I was using projection matrices with different max draw distances for different objects on scene. Makes sense now that I think about it. I just assumed that was how commercial games stopped drawing different object types at different distances. Now I realize that they probably use the projection matrix to set the cutoff distance for landmasses and skyboxes, but everything else they don't cutoff by vertex, they just don't draw an entire car or do draw an entire car based solely on its centerpoint.

Maybe someone knows of a way to do it right, because a little something called BUILDINGS don't fit into the landmass category OR the object category really well. I would like to draw mountains and sky out to 10,000 units by vertex, buildings out 4,000 units by vertex, and actors and objects out 1,000 units by centerpoint (don't need to draw the half of a man that is within 1,000 units).

Share this post


Link to post
Share on other sites
I am not to clear on your last question but let me try and answer to the best of my knowledge.
It's really a performance issue when you want to render objects at a distance. What people usually do is work in some fog. This allows you to reduce the distance and really increase performance. So let's say your terrain goes on for millions and millions of units. You could always place a fog from 1.0f - 1000.0f and then set the projection clipping planes at 1.0f and 1000.0f.

For the buildings it would be the same as the buildings are further away.

I hope this answers part of your question.
Take care.

Share this post


Link to post
Share on other sites

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