# Lighting problems

This topic is 4907 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi all, I am trying to write a 3D model making software like MilkShape. I am having trouble getting the lighting to work properly though. At the moment I have 6 lights to illuminate the model. This works fine but is not the look i'm after. Ideally what I would like is for the model to be lit ambiently, then for only one or two lights to be present. i.e. the model to have a uniform level of light with specular highlights in one or two places. here is the code i'm using so far.
Dim presentParams As New PresentParameters()
presentParams.Windowed = True

' for lighting
presentParams.EnableAutoDepthStencil = True
presentParams.AutoDepthStencilFormat = DepthFormat.D16
device = New Device(0, DeviceType.Hardware, Me.DirectXScreen, CreateFlags.SoftwareVertexProcessing, presentParams)
device.RenderState.Lighting = True

device.RenderState.ZBufferEnable = True
device.RenderState.CullMode = Cull.CounterClockwise


device.Lights(0).Type = LightType.Point
device.Lights(0).Diffuse = Me.Colour_LightTop
device.Lights(0).Attenuation0 = 0.0
device.Lights(0).Attenuation1 = Me.single_LightTop_Intensity / (Me.Tab_Model_NumericScaleY.Value * Me.Tab_Model_NumericScaleY.Value)
device.Lights(0).Attenuation2 = 0.0
device.Lights(0).Range = 999999999999999999


Is it a case of setting the mesh's ambient and colour to be brighter, and turning device.RenderState.Lighting off. It seemed that when I did this the image appeared flat. Any advice would be gratefully received. Cheers DRB2k2 [Edited by - Coder on September 16, 2004 2:48:23 PM]

##### Share on other sites
Your questions is vague and I don't understand completly what the problem is. Your model looks "flat" because there is no directional lighting. If you post some picture of the problem you're more likely to get some good answers.

##### Share on other sites
If you want ambient lighting turn it on with SetRenderState then set the ambient color.

Like this:
pD3DDevice->SetRenderState(D3DRS_LIGHTING, TRUE);
pD3DDevice->SetRenderState(D3DRS_AMBIENT, D3DCOLOR_XRGB(255, 255, 255);

Then you can put in your one or two point lights.