Pseudocode:
bool inshadow = false;
for(int i = 0 ;i<numberoflights; i++){
lightDirection =normalise( light[i] - intersectionPoint);
lightOrigin = intersectionPoint;
lightDist = 100000.0f;
for(int j = 0; j<numberOfObjects; j++){
if( i != j && object[i]->intersect(lightorigin,lightdirection,lightDist)){
inshadow = true;
}
}
if(!inshadow){
calculateColors;
}
}
Problems: The problem which I faced generating shadows was that there was an object at the position of light and hence, that was coming in between the light and the other objects. Hence the shadow was not perfectly generated.
Wrong shadow image:
Corrected Image:
No comments:
Post a Comment