Sign in to follow this  
KristapsBaumanis

D3D lighting issue

Recommended Posts

The way I get it - if I have set an ambient light, any material that reflects ambient should be visible. Specifically the code looks like this:


D3DMATERIAL9 material;
material.Ambient.a = material.Ambient.b = material.Ambient.g = 255;
gpu->SetMaterial(&material);
gpu->SetRenderState( D3DRS_AMBIENT, D3DCOLOR_ARGB(255,255,255,255) );

But the object is still dark.
I suppose that most of the lighting setup is in order since adding

material.Emissive = material.Ambient

makes the object visible.

What could I possibly be missing?

P.S. I'm using Visual C++ 2008 Express
P.P.S. Here's the full code [url="http://snipt.org/xKT"]http://snipt.org/xKT[/url] its a bit messy, the setup starts at line 212

Share this post


Link to post
Share on other sites
I finally figured this out. The problem was that I declared the [color=#1C2837][size=2]D3DMATERIAL9 structure within a method. And later it was out of scope or something. Once I made it a global variable, ambient lighting started working. [/size][/color]
[color=#1C2837][size=2]
[/size][/color]
[color=#1C2837][size=2]Why did the emissive light work with the previous construction, I still have no idea.[/size][/color]

Share this post


Link to post
Share on other sites
There is no possible value of the R component that would make the material completely dark.

That said, I had tried it with all components set and in tens of different variations until after a long and painful process of taking a working example and transforming it step by step to what I had wrote, I noticed that where the material is declared makes the difference.

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