Jump to content
• Advertisement

#### Archived

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

# Some strange behaviour...

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

##### Share on other sites
Advertisement
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

##### 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 lumelresultColor.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

##### 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

##### Share on other sites
My guess: resultColor is a char array. Make it an int.

#### Share this post

##### Share on other sites
thanks, that was the bug. it works now!!

#### Share this post

##### Share on other sites

• Advertisement
• Advertisement

• ### Popular Contributors

1. 1
2. 2
Rutin
21
3. 3
4. 4
A4L
15
5. 5
khawk
14
• Advertisement

• 13
• 26
• 10
• 11
• 44
• ### Forum Statistics

• Total Topics
633742
• Total Posts
3013634
×

## Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!