Jump to content
  • Advertisement
Sign in to follow this  
risingdragon3

Why don't lights work in MDX?

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

Working on a C# program (cloth simulation). Lights don't work right in MDX!!! This is really pissing me off. Here's an screenshot: Anyone have any ideas? Here's the relevant renderstates:
cloth.mesh.material.AmbientColor = new ColorValue(255,0,0);
            cloth.mesh.material.DiffuseColor = new ColorValue(255, 0, 0);
            s.material.EmissiveColor = new ColorValue(0, 0, 0);
            s.material.SpecularColor = new ColorValue(0, 0, 0);
            
            cloth.scene = scene;

            device.Lights[0].Type = LightType.Point;
            device.Lights[0].Direction = new Vector3(1, 1, 0);
            device.Lights[0].Position = new Vector3(0, 50, 0);
            device.Lights[0].Range = 55;
            device.Lights[0].AmbientColor = new ColorValue(0,0,0);
            device.Lights[0].DiffuseColor = new ColorValue(55, 55, 55);
            device.Lights[0].SpecularColor = new ColorValue(0, 0, 0);
            device.Lights[0].Enabled = true;
            device.Lights[0].Update();
            

            
            device.RenderState.Ambient =  Color.Black;
            device.RenderState.ShadeMode = ShadeMode.Gouraud;
            updateCamera();


PS: anyone know how to make it stop zfighting? :D:D Thx all

Share this post


Link to post
Share on other sites
Advertisement
First off,
Lights do work and it's all in the way you set it up and how you understand them that makes them work.

Pointers to some Point lights.
1. Point lights don't have any single direction
2. Point lights are affected by range and attenuation

Simple setup to a point light

Device.Lights[0].Type = LightType.Point;
Device.Lights[0].Position = new Vector3(0.0f, 0.0f, -10.0f);
Device.Lights[0].Attenuation1 = 0.5f;
Device.Lights[0].Range = 100.0f;
Device.Lights[0].Enabled = true;




ZFighting can be resolved by creating a Depth Buffer and appropriately setting your near and far clipping planes of your projection matrix. Usually the approach taken is creating a AutoDepthStencilBuffer


PresentParams.AutoDepthStencilFormat = DepthFormat.D24S8;
PresentParams.EnableAutoDepthStencil = true;
//Now you should also create/define simple view and projection matrices for your device
device.Transform.Projection = Matrix.PerspectiveFovLH((float)Math.PI/4, 1.0f, 1.0f, 1000.0f);
device.Transform.View = Matrix.LookAtLH(new Vector3(0.0f, 10.0f, -50.0f), new Vector3(0.0f, 0.0f, 0.0f), new Vector3(0.0f, 1.0f, 0.0f));




That shoule about cover it.

I hope this helps.
Take care.

[Edited by - Armadon on May 7, 2006 2:18:06 PM]

Share this post


Link to post
Share on other sites
I went ahead and changed to shaders because i wanted perpixel lighting anyway :D :D MDX is pretty nice for prototyping code fast...

But to reply: zfighting is not "fixed by using a zbuffer". I'm talking about the stuff you get when you have decals on polygons, except non planer. zbuffer just orders things correctly. turning on a zbuffer won't fix zfighting.

Share this post


Link to post
Share on other sites
Quote:
Original post by risingdragon3
I went ahead and changed to shaders because i wanted perpixel lighting anyway :D :D MDX is pretty nice for prototyping code fast...

But to reply: zfighting is not "fixed by using a zbuffer". I'm talking about the stuff you get when you have decals on polygons, except non planer. zbuffer just orders things correctly. turning on a zbuffer won't fix zfighting.


Z-fighting is when the increments in the depth buffer are larger than the increments between objects. This can be caused by a variety of things including:

- Too little precision in the depth buffer
- Too large of a gap in the near and far planes
- Too small of a distance between objects

How are you trying to place the decals? You are going to have to offset them slightly in order for them the show correctly.

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!