Archived

This topic is now archived and is closed to further replies.

InfraRed

Direct 3D 9 Problems.

Recommended Posts

InfraRed    122
hi! i'm learning Direct3D 9. i wrote an application (code attached), and those are the problems. 1. lights, as you can see in the attachment, there is a problem with the light. i'm using D3DLIGHT_DIRECTIONAL type, and it is not enough to light all the terrain, so i added another light (light one toggled by '1' key and light 2 by '2' key). 2. culling problem. when i rotating the camera around the terrain, (using Right and Left Keys, Up and Down key form zooming) the mountains sometimes look cut. i'm using IndexBuffer for rendering the terrain. (as wrote in the Andy Pike's Terrain tutorial) ScreenShot: Download Source code Thanks, InfraRed. [edited by - InfraRed on April 29, 2003 2:13:18 PM]

Share this post


Link to post
Share on other sites
thedo    124
Your not clearing your z-buffer

add this to your initialization

d3dpp.AutoDepthStencilFormat=D3DFMT_D24S8;
d3dpp.EnableAutoDepthStencil = TRUE;


and this to your refresh

g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(90,90,0), 1.0f, 0 );


Neil


WHATCHA GONNA DO WHEN THE LARGEST ARMS IN THE WORLD RUN WILD ON YOU?!?!

Share this post


Link to post
Share on other sites
InfraRed    122
Thank you Neil!
It looks great now!



do you have any idea why the lights not light all the terrain?

is it because of the Normal positioning?

Thanks

Share this post


Link to post
Share on other sites
InfraRed    122
Take a look on the screenshot in the top of this thread.

for some reason the D3DLIGHT_DIRECTIONAL doesn''t work properly.
as you can see it''s all dark in the right side.

why?
i tried to use 2 directional lights in opposite directions to cover more terrain, but only a little more light added.

why?
is this beacuse of the Normal computing?

InfraRed.

Share this post


Link to post
Share on other sites