# Problems with light culling

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

## Recommended Posts

Hi, I'm developing a game, and have to resort to vertex lighting for now. (Ugh :( ) I noticed that something is wrong with the FFP lights. I use point lights only, and cull them using their bounding sphere. Once I started the whole thing, I noticed some very nasty flickering. Apparently, the lights affect vertices that are *outside* of their range, which is quite bad, since this means that vertices outside of the bounding sphere are lit by it, and once the bounding sphere is no longer visible, these vertices suddenly turn black. I do set the D3DLIGHT9.Range parameter to the radius of the sphere, and still get this problem. But *why*? Also, I noticed some flickering even when the lights are in the frustum. I perform multipass lighting when more than 8 lights are visible (8 being the maximum of the card). Artificially setting the lights per pass to 1 solves this. But I'm not sure why. Here's some code:
// Set for first pass
blending(false);
zwrite(true);
blendfunc(video::BlendFunc_One,video::BlendFunc_One);

// Setting lightsperpass to 1 solves the problem, but is less efficient
uint32 lightsperpass=videodevice()->fixedMaxLights();

for (uint32 l=0;l<lightlist.numLights();l+=lightsperpass) {
uint32 numL=lightlist.numLights()-l;
if (numL>lightsperpass) numL=lightsperpass;

for (uint32 j=0;j<lightsperpass;++j) {
if (j<numL) {
video::FFLightProperties fflprops;

const Light *pLight=lightlist.light(l+j);
fflprops.m_Position=pLight->transform().position();
fflprops.m_Direction=pLight->direction();
fflprops.m_Color=pLight->color();
fflprops.m_ConstantAttenuation=pLight->constantAttenuation();
fflprops.m_LinearAttenuation=pLight->linearAttenuation();
fflprops.m_Range=pLight->range();
fflprops.m_Lighttype=pLight->lighttype();
fflprops.m_Falloff=pLight->falloff();
fflprops.m_InnerConeAngle=pLight->innerConeAngle();
fflprops.m_OuterAngle=pLight->outerAngle();

fixedSetLightEnabled(j,true);
fixedSetLightProperties(j,fflprops);

} else fixedSetLightEnabled(j,false);
}

drawIndexedPrimitives(
primitivestype(),vertexstream(),indexstream(),
indexOffset(),numElements());

if ((l==0) && (lightlist.numLights()>lightsperpass)) {
blending(true);
zwrite(false);
}

}

if (lightlist.numLights()>lightsperpass) {
blending(false);
zwrite(true);
}


1. 1
2. 2
JoeJ
16
3. 3
4. 4
5. 5
frob
11

• 13
• 16
• 13
• 20
• 12
• ### Forum Statistics

• Total Topics
632178
• Total Posts
3004607

×