Sign in to follow this  
soft903

[.net] VB2005 DirectX Light Setting

Recommended Posts

Hi, My program is simulate a ball free fall to ground. Using VB 2005 with .X file I set all the light by VB coding, not in the .X file I tried using 3 point light or 3 spot light But those lights given ugly result. Seem like the moon, as 1 light can only on half of the ball Example, only 1 spot light top-down, topper half is fine, but the bottom part is totally dark. So either half-dark and half-bright, or "cut" a cake into few pieces(>1 lights). I would like to ask what be the common practice of light setting by VB coding. Links would be ok. (I googled, but nothing useful) Thanks

Share this post


Link to post
Share on other sites
Generally, in addition to point lights, you will have some ambient light. This will allow the parts of the object not directly lit by a point light to be visible. Also, setting a material and using some specular light will generally improve the appearance of the ball.

Take a look at the lighting tutorial in the DirectX SDK.

Share this post


Link to post
Share on other sites
Hi,

Thanks for reply.

Here's my setting:

MyDevice.SetRenderState(RenderStates.Lighting, True)
MyDevice.SetRenderState(RenderStates.ZEnable, True)
MyDevice.SetRenderState(RenderStates.CullMode, True)
MyDevice.SetRenderState(RenderStates.Ambient, Color.Black.ToArgb())
MyDevice.SetRenderState(RenderStates.FillMode, FillMode.Solid)
MyDevice.SetRenderState(RenderStates.SpecularEnable, True)
MyDevice.SetRenderState(RenderStates.NormalizeNormals, True)
MyDevice.SetRenderState(RenderStates.ShadeMode, ShadeMode.Gouraud)

MyDevice.Lights(0).Type = LightType.Spot
MyDevice.Lights(0).Diffuse = Color.White
MyDevice.Lights(0).Ambient = Color.Black
MyDevice.Lights(0).Specular = Color.White
MyDevice.Lights(0).Position = New Vector3(0, 10, 0)
MyDevice.Lights(0).Range = 20.0F
MyDevice.Lights(0).Falloff = 1.0F
MyDevice.Lights(0).Direction = New Vector3(0, -1, 0)
MyDevice.Lights(0).OuterConeAngle = Math.Atan(2 / 13) * 2
MyDevice.Lights(0).InnerConeAngle = Math.Atan(2 / 13) * 2
MyDevice.Lights(0).Attenuation0 = 0.9F
MyDevice.Lights(0).Attenuation1 = 0.06F
MyDevice.Lights(0).Attenuation2 = 0.0F
MyDevice.Lights(0).Enabled = True
MyDevice.Lights(0).Update()

The light is fine for the top-half of ball.
Result Picture
In theory, the bottom part should be dark, but that's not what I want

If I add 2 more spot light from bottom-right and -left direct to center of the ball
Result Picture
It is what I mean like "cut a cake into pieces".

I have tried for few different setting of lights, but same outcome.

The ball have material, I think, with just pink in color

I don't need a very fantasy or realistic result, I just want it to be a little smoother.

Can you give me a little more help?

Thanks

Share this post


Link to post
Share on other sites
You have ambient lighting set to black. That's why nothing shows up except where the point lights hit. Try using a medium gray for the ambient setting.

I'm not sure what else you are talking about because both of the links you provided point to the same picture.

Share this post


Link to post
Share on other sites
Hi,

Updated link for 2nd result
Result Picture

I have set the ambient color to gray, but same result
I have tried both
MyDevice.SetRenderState(RenderStates.Ambient, Color.Gray.ToArgb())
and
MyDevice.Lights(0).Ambient = Color.Gray

I have also tried for point and directional light, but same result

Any other suggestions??

Thanks

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this