1
\$\begingroup\$

I'm making a car game and doing the dashboard part. I'm trying to do the dashboard lights, i've did this changing the dashboard texture, overwriting the texture with the light image over it, example:

Texture2D dashboardTexture;
Texture2D parkingBrakeLightTexture;
Model carModel;

//when the light needs to turn on:

PutTextureOverDashboardTexture(parkingBrakeLightTexture);

//on Draw method I change the texture of dashboard mesh:

effect.Texture = dashboardTexture;
effect...

This is alright, but the lights will suffer influence from the external light if I EnableDefaultLighting() in the effect, then the dashboard lights will almost don't appear depending on what direction the car is, and of course that should not happen. So how can I make the lights of dashboard appear? I need to use another alternative? Or can I still utilize this method?

\$\endgroup\$

1 Answer 1

2
\$\begingroup\$

From what I understand from your question: You don't want your model/dashboard to have so much shadow on it from certain angles.

Here is a picture of a textured model with just the default lighting enabled: enter image description here The dark side: enter image description here

Well if you want to make it look like there is lighting coming from the model you can add Emmisive Light. Change you EnableDefaultLighting code to look like this:

        effect.EnableDefaultLighting();
        effect.EmissiveColor = Color.FromNonPremultiplied(200, 200, 200, 255).ToVector3();

Here are the results: enter image description here The dark side: enter image description here

Just for interest. This is what EnableDefaultLighting does:

        LightingEnabled = true;
        // Key light.
        light0.Direction = new Vector3(-0.5265408f, -0.5735765f, -0.6275069f);
        light0.DiffuseColor = new Vector3(1, 0.9607844f, 0.8078432f);
        light0.SpecularColor = new Vector3(1, 0.9607844f, 0.8078432f);
        light0.Enabled = true;

        // Fill light.
        light1.Direction = new Vector3(0.7198464f, 0.3420201f, 0.6040227f);
        light1.DiffuseColor = new Vector3(0.9647059f, 0.7607844f, 0.4078432f);
        light1.SpecularColor = Vector3.Zero;
        light1.Enabled = true;

        // Back light.
        light2.Direction = new Vector3(0.4545195f, -0.7660444f, 0.4545195f);
        light2.DiffuseColor = new Vector3(0.3231373f, 0.3607844f, 0.3937255f);
        light2.SpecularColor = new Vector3(0.3231373f, 0.3607844f, 0.3937255f);
        light2.Enabled = true;

        // Ambient light.
        AmbientLightColor = new Vector3(0.05333332f, 0.09882354f, 0.1819608f);

EnableDefaultLighting just sets up the Directional Lights and Ambient Light which we can already access. That is why we can make additional modifications to the lighting after we call EnableDefaultLighting as I did with the emissive lighting.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .