Jump to content
• Advertisement

Public Group

# Disappearing Images

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

Hi All I have noticed after I have draw my level to the screen that some parts go black if you are too far away. I am using DirectX, and C++ code. Is there a way to stop this from happening? regards Steven Marshall

#### Share this post

##### Share on other sites
Advertisement
Sounds like you've discovered the Z-Buffer. Nothing you can do about that. Increase the distance of the Z-Buffer, but this will also decrease the accuracy of it.

#### Share this post

##### Share on other sites
When creating a camera, you use a view frustum to dictate the perspective distortion that may occur. Anything outside of the frustum is not drawn. When displaying graphics on screen, you give 3d coordinates to display. If the distance is too far into the scene, it can go past the far plane of the view frustum, and will not be drawn. The same is true, when it gets too close. The reason why we need a near and far plane is to dictate use of the depth buffer.

Just like onscreen you use an RGBA Buffer to draw to, the depth buffer can consist of varying bit depths. If we were to have a distance say, that starts at 1 foot away (remember distance is completely arbitrarily defined in linear algebra), and ends 10 miles into the scene, unless the depth buffer has enough bits in it, it may not be able to differentiate drawing an object that is 10000 feet away, and one that is 10001 feet away. They would appear onscreen at the same distance, and would arbitrarily clip through each other. Picking a good near and far distance can be difficult depending on the precision you might want, as the distance that the depth buffer is able to differentiate gets larger at further distances depending on the field of view. So at one foot away, the buffer can differentiate an object drawn at z of 10 feet 1 inch and another at 10 feet 2 inches but as you get to 100 feet, there's a 4 inch gap.

Without an extremely large bit depth buffer, not currently supported for example, you would not be able to draw in the same scene a table one foot away with a piece of paper a quarter millimeter thick on it, and small branch detail on a tree that is a half a mile away, without getting clipping artifacting on one or the other.

#### Share this post

##### Share on other sites
You could also use a light fog so that objects sort of fade away in the distance before they disappear completely.

#### Share this post

##### Share on other sites
Quote:
 Original post by Dancin_FoolSounds like you've discovered the Z-Buffer. Nothing you can do about that. Increase the distance of the Z-Buffer, but this will also decrease the accuracy of it.

Hi There

Thanks for thisinfo. I have the following settings in my engine:

D3DPRESENT_PARAMETERS d3dpp;
ZeroMemory( &d3dpp, sizeof(d3dpp) );
d3dpp.Windowed = TRUE;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;
d3dpp.EnableAutoDepthStencil = TRUE; //Z-Buffer
d3dpp.AutoDepthStencilFormat = D3DFMT_D16; //Z-Buffer

So what do I need to change to make the z-buffer bigger?

regards
Steve

#### Share this post

##### Share on other sites

• Advertisement

### Announcements

• Advertisement

• ### Popular Contributors

1. 1
2. 2
3. 3
Rutin
19
4. 4
khawk
14
5. 5
frob
12
• Advertisement

• 9
• 11
• 11
• 23
• 12
• ### Forum Statistics

• Total Topics
633659
• Total Posts
3013209
×

## 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!