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

Odd. But then you did say half the examples on shadertoy didn't work on 
whatever browser you had. Tried Chrome/IE?

> The difficulty is figuring out what surface was hit just from the
> intersection coordinates.

You could have an intersection struct with surface normal and material 
ID in it as well.

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

You need to keep track of a "cumulative coefficient of reflection" value 
as you go (make it a vec3 if you want coloured reflections):

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;
}


Post a reply to this message

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