|
![](/i/fill.gif) |
On 10/06/2016 07:59 AM, scott wrote:
>> In summary, it appears that implementing reflection is mathematically
>> impossible. I may perhaps still be able to realise my dream of rendering
>> depth of field effects realistically. (Although without a nice detailed
>> scene to look at, it might be rather disappointing...)
>
> Obviously it's not, because there are plenty of shadertoy examples
> showing it:
>
> https://www.shadertoy.com/view/4ssGWX
Interesting. On my browser, that just crashes.
> Surfaces that reflect *OR* refract are trivial:
>
> for(i=0;i<MAX_TRACE_DEPTH;i++)
> {
> intersect = Trace( ray );
> if( REFLECT(intersect) ) ray = ReflectRay(ray , intersect);
> if( REFRACT(intersect) ) ray = RefractRay(ray , intersect);
> }
The difficulty is figuring out what surface was hit just from the
intersection coordinates. And perhaps a perfect reflection isn't so
hard, but I wanted to have the colour change slightly on each
reflection... but I can't figure out how to stack up the colour changes
until you get to the end of the reflection chain, and then unstack them
again.
> To do surfaces that do both you need to choose randomly at each
> intersection which ray to follow (weighted appropriately depending on
> the material) and then average over a larger number of samples. You can
> either do many samples per frame (but obviously this gets slow for
> complex scenes), or what is commonly done is to average over many frames
> (and reset the average if the camera is moved). Or both.
Still trying to work out how you "average over several frames".
ShaderToy is great fun, but so *utterly* undocumented... it's quite hard
to figure out how to do anything.
Post a reply to this message
|
![](/i/fill.gif) |