Jump to content
  • Advertisement
Sign in to follow this  

Light reflects wrong way

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

I am building a white cube that rotates. I have 5 faces completed(they reflect the light the right way, etc.) but on the very bottom face, the light reflects up inside of the rest of the cube instead of reflecting down
// Other faces are defined above and have been snipped

	// Bottom face
	v[20] = Vertex(0.0, 0.0f, 0.0f, 0.0f, -1.0f, 0.0f);
	v[21] = Vertex(0.0f, 0.0f, 1.0f, 0.0f, -1.0f, 0.0f);
	v[22] = Vertex(1.0f, 0.0f, 1.0f, 0.0f, -1.0f, 0.0f);
	v[23] = Vertex(1.0f, 0.0f, 0.0f, 0.0f, -1.0f, 0.0f);

        // And then I have my directional light
        D3DLIGHT9 dir;
	::ZeroMemory(&dir, sizeof(dir));
	dir.Diffuse = white;
	dir.Specular = white;
	dir.Ambient = white;
	dir.Direction = D3DXVECTOR3(1.0f, 0.0f, 1.0f);
	Device->SetLight(0, &dir);
	Device->LightEnable(0, true);
	Device->SetRenderState(D3DRS_NORMALIZENORMALS, true);

When I make the Vertice calls, the normal Y is set to -1.0f which should make it reflect light downward but it still reflects upward even with NORMALIZENORMALS. Any help is greatly appreciated. Thanks, Carl

Share this post

Link to post
Share on other sites

struct Vertex {
Vertex() { }
Vertex(float x, float y, float z) {
_x = x; _y = y; _z = z;

Vertex(float x, float y, float z, float nx, float ny, float nz) {
_x = x; _y = y; _z = z;
_nx = nx; _ny = ny; _nz = nz;

Vertex(float x, float y, float z, D3DCOLOR c) {
_x = x; _y = y; _z = z; color = c;
float _x, _y, _z, _nx, _ny, _nz;
D3DCOLOR color;


I'm using the second constructor(obviously) and I do make a call to:

Thanks again,

Share this post

Link to post
Share on other sites
I think you need to include D3DFVF_NORMAL as part of your flexible vertex format.


Dang, too slow...

You should probably assign a colour value as well. Or at least default it to something in the vertex constructor.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!