|
![](/i/fill.gif) |
>> vec3 CCOR = vec3(1,1,1);
>> vec3 colour = vec3(0,0,0);
>> for(int i=0;i<MAX_TRACE_DEPTH;i++)
>> {
>> isect = Raytrace();
>> colour += CCOR * isect.diffuse_colour;
>> CCOR *= isect.reflection_colour;
>> }
>
> I'm thinking about the associative/distributive property of the reals,
> though... If one object adds 4% blue and then reflects 95%, and the next
> object adds %6 yellow and reflects 50%, and the final object is green,
> you need
>
> ((green * 50%) + 6% yellow) * 95% + 4% blue
>
> but the algorithm above gives
>
> ((4% blue * 95%) + 6% yellow) * 50% + green
No, the algorithm does give the same result as you want, step through it
with your example:
CCOR = 100%
col = black
1st intersect:
col = black + (100%)*4% blue = 4% blue
CCOR = 100% * 95% = 95%
2nd intersect:
col = 4% blue + (95%) * 6% yellow
CCOR = 95% * 50%
3rd intersect:
col = 4% blue + (95%) * 6% yellow + (95%*50%) * green
CCOR = 95% * 50% * 0%
Post a reply to this message
|
![](/i/fill.gif) |