Sign in to follow this  

directs 2.0 for c# - ambient light doesn't work - HELP!

This topic is 4300 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

After much time going in circles, I discovered the cause of my lighting problems is due to the new directx 2.0 c# libraries. I can't get ambient lighting to work at all. My objects just come out black where light isn't shining on them. I ran a sample from Tom Miller's book (chapter5) for mesh boxes and it worked fine. I then upgraded the sample to .Net 2005 - and it worked fine. I then reset the reference to directx2.0 and made a few minor code adjustments to get it to compile - the boxes appeared but they're all black. The only varible that changed there was the directx 2.0 libraries. Has anyone else come across this? I'm too new to this to figure it out on my own. Thanks, Len.

Share this post


Link to post
Share on other sites
"My objects just come out black where light isn't shining on them."

umm. this is what happens in real life :)

perhaps you want to set the emmisive prop of the material.. that way the mesh will be at least that color regardless of weather light is shining on it :)

Diffuse = Ma * La + Me + Md * Att * NdL * Lc

thats ~ the diffuse light equation from:
http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/dnardir3d/html/d3dlight3.asp

Me (Material Emmisive) is added

Share this post


Link to post
Share on other sites
Hi,

Thanks for such a fast response. I tried what you suggested but it didn't work.

Right now I am looking through code from "Chad's Homepage." He gives a large tutorial on direct x and he has it all working with 2.0. His chapter 13 has a light sample that seems to successfully use ambient light. I'll post back if I find anything.

(chad's home page: http://www.c-unit.com/tutorials/mdirectx/)

Share this post


Link to post
Share on other sites
I got it!

I can't say I'm too impressed with how many changes Microsoft (ie, Tom Miller) has made to the interface from one version of DirectX to the next. It seems pretty unprofessional to make haphazard changes to method names just because they conform better to various naming conventions, etc. Interfaces are supposed to be immutable so you don't go breaking everyone's code with a new release.

Anyhow, venting aside, when setting colours on a material, you must use the ColorValue, not the Color property...

was:
boxMaterial.Ambient = Color.White;

now:
boxMaterial.AmbientColor = ColorValue.FromColor(Color.White);

Share this post


Link to post
Share on other sites
Quote:
Original post by Len
I can't say I'm too impressed with how many changes Microsoft (ie, Tom Miller) has made to the interface from one version of DirectX to the next. It seems pretty unprofessional to make haphazard changes to method names just because they conform better to various naming conventions, etc.
It's almost certainly too late now, but you should get yourself into the beta program if you want to make them aware of any concerns or suggestions you might have.

Quote:
Original post by Len
Interfaces are supposed to be immutable so you don't go breaking everyone's code with a new release.
Well it is MDX 2 - a different major version to the original MDX 1. Yes, within minor versions (1.1, 1.2, 1.3..) they shouldn't really introduce breaking changes, but for a whole new version it shouldn't be so bad.

Cheers,
Jack

Share this post


Link to post
Share on other sites

This topic is 4300 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.

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