Skip to main content
gamedev.net
🔒 Locked

lighing problem

Started by ibelchamber Feb 17, 2005 at 9:52 AM 5 replies 900+ views
Original Post
ibelchamber
ibelchamber
I'm getting started with directx9 and I have a basic project working. I have a few test shapes, and some basic controls for lighting, etc. I am using directional light. The problem is that as I increase the size of objects, they get darker- it is as though they only pick up a fixed ammount of directional light, and spread it over the surface, so the greater the amount of surface, the lower the light concentration. Are there any common mistakes that result in this situation? I'm using a standard teapot mesh (but the same happens with boxes and cylinders) Thanks.
rjackets
rjackets
A directional light should just be a simple calculation corrolating the direction vector and the face normal (it's really not very complex lighting at all [wink]) -- a simple test you could do is to just a directional light of 0,-1,0 (directly top down) and use a box or a plane. That will show you exactly how the ligthing is changing since it is a predictable setup. If that does the same thing, then you've got me...
ibelchamber
ibelchamber
That's pretty much exactly what I'm doing. The bigger it gets, the darker it gets, whatever shape it is!

Any more ideas??
ibelchamber
ibelchamber
Many thanks, that solves it. But I notice that the code completion hint says that setting this true can be "computationally expensive"- is this true? Is there a way to make the lighting work normally without increasing cpu overhead?


Thanks
Shadx
Shadx
On the scaling of the object, you could recalculate your normal yourself. For example, if you are using a Mesh, you can use D3DXComputeNormals.

Shadx
Namethatnobodyelsetook
Namethatnobodyelsetook
It's pretty much free these days as vertex processing is quite fast, however depending on what you're doing, you can eliminate having to normalize your normals. If you're doing a constant scale, you could scale the mesh vertex positions and put them into the VB that way, leaving the normals alone, and not using a scale in your world transformation. If you're scaling dynamically, the overhead is necessary. If you scale only occasionally, you could set normalizenormals only when needed.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.