Archived

This topic is now archived and is closed to further replies.

Some strange behaviour...

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

hi, i have a problem, i hope anyone can help me... my lightmap code makes this strange black rings, look at it: can anyone tell me what causes this ugly pheonomena? thanks Gammastrahler

Share this post


Link to post
Share on other sites
Look like you are overestimating the light component incoming from the lightsource, what kind of algo are you using,a ray caster or a radiosity ? , try to look if a value goes over range, the circles look like a 2d function of the type
u=a*sin( omega*t+phi ) , v=b*cos( oemga*t+phi ) , thus giving an elliptical look, also chek in your light model for light attenuation due to distance,i hope it helps
byez.

Share this post


Link to post
Share on other sites
here is some source code, i use the lambertian cosine law for the lighting (function of angle between light and lumel, and distance)

as you can see, i check already that the color values don´t exceed 255.


  
// for each lumel

resultColor.Set(0, 0, 0);
for (int k = 0; k < nLights; k++)
{
light = I_MAP->GetLight(k);
lightpos = light->GetPos();
if (lightpos.Front(v0, N)
{
L.Subtract(lightpos, curlumel);
d = lightpos.Distance(curlumel);
L.Normalize();
a = L.Dot(N);
intensity = ((float)light->GetIntensity() * a) / d;

resultColor[0] += light->GetColor()[0] * intensity;
resultColor[1] += light->GetColor()[1] * intensity;
resultColor[2] += light->GetColor()[2] * intensity;
}
}
if (resultColor[0] > 255) resultColor[0] = 255;
if (resultColor[1] > 255) resultColor[1] = 255;
if (resultColor[2] > 255) resultColor[2] = 255;

Share this post


Link to post
Share on other sites
This sounds crazy but it almost looks like integer wraparound? Light is getting above 255 and wrapping back to 0? Make sure it is clamped; it looks like you might not being doing it right.

You might do this instead:
if ( resultColor[0] + light->GetColor()[0] * intensity < 255 )
resultColor[0] += light->GetColor()[0] * intensity;
else
resultColor[0] = 255;

Ugly code, but I''m not entirely conscious right now. Anyway, try that. Just a weird idea.

Share this post


Link to post
Share on other sites