POV-Ray : Newsgroups : povray.off-topic : WebGL : Re: WebGL Server Time
28 Jul 2024 04:30:04 EDT (-0400)
  Re: WebGL  
From: scott
Date: 13 Jun 2016 03:13:05
Message: <575e5d01$1@news.povray.org>
>> 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

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.