spot light problem

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Alleycat
Posts: 6
Joined: Mon Jun 11, 2007 5:14 pm

spot light problem

Post by Alleycat »

Im trying to create spot lights to simulate car headlights.
I added spot light using DX but the lighting doesn't look good.
I attached a Screen shot - the light pos is at the center of the car.

for testing I use the arena from one of the samples which has big polygons. if the lighting goes through but dont intersect the vertex its not lit at all.

If ill use for the floor a cube with texture with only 2 polygons for face the problem would get worse.
- Do I need a arena with lots of small polygons?
- I found in the forums a trick using a transparent cone but I dont think it will be good enough.
- I have to use a pixel shader for this or there's another solution ?
(I have little experience with PS)

The params I used:

Code: Select all

	m_lightInfo = new D3DLIGHT9;
	ZeroMemory( m_lightInfo, sizeof(*m_lightInfo) );

	m_lightInfo->Type = D3DLIGHT_SPOT;
	//m_lightInfo->Ambient.r = 1.0f;
	//m_lightInfo->Ambient.g = 1.0f;
	//m_lightInfo->Ambient.b = 1.0f;
	//m_lightInfo->Ambient.a = 1.0f;
	m_lightInfo->Diffuse.r = 1.0f;
	m_lightInfo->Diffuse.g = 0.7f;
	m_lightInfo->Diffuse.b = 0.7f;
	m_lightInfo->Diffuse.a = 1.0f;
	m_lightInfo->Specular.r = 1.0f;
	m_lightInfo->Specular.g = 1.0f;
	m_lightInfo->Specular.b = 1.0f;
	m_lightInfo->Specular.a = 0.0f;
	m_lightInfo->Range = 500.0f;
	m_lightInfo->Falloff = 1.0f;
	m_lightInfo->Phi   = irr::core::PI/8.0f;
	m_lightInfo->Theta = irr::core::PI/16.0f;
	m_lightInfo->Attenuation0 = 0;
	m_lightInfo->Attenuation1 = 1.0f / m_lightInfo->Range;
	m_lightInfo->Attenuation2 = 0;
Image
Image
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

Change the material type. The EMF_SOLID material type does per vertex lighting. If you use one of the normal mapped or parallax mapped material types, they do per-pixel lighting. If necessary, you could write or copy/paste a shader that does per-pixel lighting without requiring a normal map.

Travis
Alleycat
Posts: 6
Joined: Mon Jun 11, 2007 5:14 pm

Post by Alleycat »

I dont understand how to do this.
I changed the material type and then needed to create tangents
for the room as in example 11 but the light still no good lighting the vertex.

Then I tried differently working inside example 11:
I removed all the lights and added the spot light but seen nothing except the fog.

Do I need different normal map?
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

Sorry, I totally missed the fact that you're using D3D lights directly. The material renderers get their light information from the lights that are registered with the IVideoDriver.

If you search for D3DLIGHT_SPOT, you'll find some old code that enabled spotlights in Irrlicht. It may require some tweaking, but that should get the light working. Once you have that working, you'll probably need to modify the normal mapped and parallax mapped shaders to work with spotlights.
Alleycat
Posts: 6
Joined: Mon Jun 11, 2007 5:14 pm

Post by Alleycat »

Is it the shader in CD3D9NormalMapRenderer.cpp?
its low level, too much for me, I have a book about HLSL..

Just wondering, how this effect created in games before pixel shader was available?
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

Just wondering, how this effect created in games before pixel shader was available?
I don't know. That was before my time in this area. I'd assume they just used more polygons.

Travis
belfegor
Posts: 383
Joined: Mon Sep 18, 2006 7:22 pm
Location: Serbia

Post by belfegor »

You need more polygons (faces) on model for spot light to look correct,
also try to play with Aten0, Atten1, Atten2 values more.
Small FPS demo made using Irrlicht&NewtonDEMO
InfoHERE
Its at very early stage but i think im crazy enough to finish it all alone.
Post Reply