#### Archived

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

# Problems with terrain generation

This topic is 6273 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi, I''m trying to get some terrain generation code working in DX8. I''ve basically ported the code from OpenGL Game Programming which generates terrain from a 32x32 bitmap lightmap. I can get the terrain to render (sort of) in the view, but it''s just completely black. I''ve tried lighting, ambient lighting, materials, etc, and it just stays black. Other polgygons or x files I import into the scene work fine, so I don''t understand what''s going on. Any ideas? Cheers, Manteau

##### Share on other sites
I would hazard a guess and say that it''s because your vertex normals are facing the wrong way. DX lights only those surfaces that facing the light source, and it uses the VN to determine which way the surface is facing so... if your VN is facing the wrong direction, the surface has no light on it at all. Try changing the order in which you create your polygon vertices...

A....B
. . .
. . .
C....D

You should be using a clock-wise thingy, so you create your vertex data like so:

V1 = A
V2 = B
V3 = C
V4 = D
(if you''re using Triangle Strips, the even numbered triangles are automatically expected to be Anti-clockwise, so the second tri is made from B, C and D)
or
V1=A
V2=B
V3=C
V4=C
V5=B
V6=D
(if you''re using Triangle Lists).

A neat way to check if this is your problem is to put your light-sources ''underneath'' your terrain and then move your camera underneath and look upwards... if you see stuff, then it''s your vector normals pointing the wrong way. If you aren''t using VN''s at all then I think (but I could be wrong) that you will always get a black surface because DX gets sticky about unlit surfaces without them.

I have plenty of talent and vision, I just don''''t give a damn.

##### Share on other sites
Thanks.

I tried setting my normals for each vertex to (0,1.0f,0) - (pointing up for the Y axis) and there was no difference however.

I''ve had problems with normals before, and if the normals were wrong, shapes wouldn''t display at all until you rotated them, so maybe this isn''t the problem...

Wouldn''t the ambient light also cause objects to be lit regardless of normals?

Thanks,
Manteau

1. 1
2. 2
3. 3
4. 4
Rutin
11
5. 5

• 12
• 19
• 10
• 14
• 10
• ### Forum Statistics

• Total Topics
632665
• Total Posts
3007724
• ### Who's Online (See full list)

There are no registered users currently online

×