Jump to content
  • Advertisement
Sign in to follow this  
billconan

ask for lighting tricks

This topic is 4829 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 everyone, could you please tell me some tricks to make the scene more natural which means the light is soft. here is my scene, the light gradient is too sharp. every part of the model is either black or white. and this is a screenshot from a modeller, it's just great how could i make my scene like this? i currently use a very simple lighting set: Microsoft.DirectX.Direct3D.Material mtrl = new Microsoft.DirectX.Direct3D.Material(); mtrl.Diffuse =System.Drawing.Color.White; mtrl.Ambient =System.Drawing.Color.White; device.Material = mtrl; device.Lights[0].Type = LightType.Directional; device.Lights[0].Diffuse = System.Drawing.Color.White; device.Lights[0].Range=1000; device.Lights[0].Position=new Vector3(200,200,200); device.Lights[0].Direction = new Vector3(-1,-1,-1); device.Lights[0].Enabled = true; device.RenderState.Lighting=true; device.RenderState.PointSize=3.0f; device.RenderState.Ambient = System.Drawing.Color.FromArgb(0x202020); thanks in advance

Share this post


Link to post
Share on other sites
Advertisement
my guess is that the normals aren´t the same as in your modeler?
With correct normals you should at least be seeing some different shades of grey, not only black / white like you do.

Share this post


Link to post
Share on other sites
Try computing per vertex normals for mesh. Basically :

Compute face normals
For all vertices
Find faces that use this vertex
Sum all face normals to one vector
Divide the vector by the number of faces that use this vertex
Normalize the vector
Set it to vertex normal
End

Also few tips :
- When you got object that contains meshes and all of them are connected to each other, you must have correct indices (for example neck and head meshes has some shared vertices).
- To reduce specular failures in mesh, use same normals for vertices that are very near each other.

Share this post


Link to post
Share on other sites
little note about Arex´s post: you don´t have to divide the normal by the face count, since you normalize the vector anyway, which nullifies the effect of the division. No big thing, though.

Share this post


Link to post
Share on other sites
Also, be sure to use light colors in the range of 0..1. Using light colors of (10.0f, 10.0f, 10.0f) could cause lighting which isn't soft.

Share this post


Link to post
Share on other sites
Quote:
Original post by matches81
little note about Arex´s post: you don´t have to divide the normal by the face count, since you normalize the vector anyway, which nullifies the effect of the division. No big thing, though.


hi guys, why normalize the vector, since the vector point to the same direction?

what's is the fastest way of normalizing?

thanks.

[Edited by - billconan on July 29, 2005 10:12:03 AM]

Share this post


Link to post
Share on other sites
hi, thanks guys,
i've correct the scene after calculated and normalized the normal vectors.
now the scene is perfect, thanks again.

Share this post


Link to post
Share on other sites
The reason why you have to normalize has something to do with the formula for calculating the light. If the vector N is your normal and L is a vector from the point towards the light then standard diffuse lighting is given by:

light = dot(N,L) = cos(angle) * length(N) * length(L)

So, if the N is not normalized then the lighting will be multiplied by its length. This means that if for example the length is 10 units then you will have full lighting for almost all vertices as long as their normal points just somewhat towards the light source.

- Kasper

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!