fraa
04-15-2004, 10:35 AM
While browsing Jeremy Birn's website, i found his tutorial about "Chromatic Aberrations" (http://www.3drender.com/light/lens.htm). I tried to achieve the same effect with a shader ... here's the result of my empirical study :)
http://fra.planet-d.net/work/research/09_dispersion_10.jpg
http://fra.planet-d.net/posts/dispersion.mpg
The whole thing is a trick, so it is physically unaccurate. The shader just fires 3 rays (instead of one) with a slight IOR offset and re-comp' them with a RGB filter.
It looks interesting enough, though any comments about the render or the method would be warmly welcomed. I'n not really happy about the shadows (they looks completely wrong), but i've still a lot of things to learn about shading language ...
the shader source is here (http://fra.planet-d.net/shaders/PoorDispersion.zip)
... and here is it for those who don't want do download it :
surface
PoorDispersion(float ior = 1.5; float dispersion_iota = 0.25;)
{
point R, T, Nn, Ni;
float krefl, ktran,
eta;
Nn = normalize(N);
Ni = normalize(I);
fresnel(Ni, Nn, 1.0 / ior, krefl, ktran, R, T);
if (isshadowray() != 0)
{
Oi = (1.0 - ktran);
}
else
{
eta = ior;
Oi = Os;
eta += (dispersion_iota * float random());
T = refract(Ni, Nn, 1 / eta);
Ci = trace(P, T) * color(1,0,0) * ktran;
eta += (dispersion_iota * float random());
T = refract(Ni, Nn, 1 / eta);
Ci += trace(P, T) * color(0,1,0) * ktran;
eta += (dispersion_iota * float random());
T = refract(Ni, Nn, 1 / eta);
Ci += trace(P, T) * color(0,0,1) * ktran;
}
Ci += trace(P, R) * krefl;
}
edit :
a same approach can be found here : http://animus.brinkster.net/stuff/plg_diffraction/plg_diffraction.html
using xsi. the shader looks really complex to me, i guess it handles far more many cases than my hawfull hack :)
http://fra.planet-d.net/work/research/09_dispersion_10.jpg
http://fra.planet-d.net/posts/dispersion.mpg
The whole thing is a trick, so it is physically unaccurate. The shader just fires 3 rays (instead of one) with a slight IOR offset and re-comp' them with a RGB filter.
It looks interesting enough, though any comments about the render or the method would be warmly welcomed. I'n not really happy about the shadows (they looks completely wrong), but i've still a lot of things to learn about shading language ...
the shader source is here (http://fra.planet-d.net/shaders/PoorDispersion.zip)
... and here is it for those who don't want do download it :
surface
PoorDispersion(float ior = 1.5; float dispersion_iota = 0.25;)
{
point R, T, Nn, Ni;
float krefl, ktran,
eta;
Nn = normalize(N);
Ni = normalize(I);
fresnel(Ni, Nn, 1.0 / ior, krefl, ktran, R, T);
if (isshadowray() != 0)
{
Oi = (1.0 - ktran);
}
else
{
eta = ior;
Oi = Os;
eta += (dispersion_iota * float random());
T = refract(Ni, Nn, 1 / eta);
Ci = trace(P, T) * color(1,0,0) * ktran;
eta += (dispersion_iota * float random());
T = refract(Ni, Nn, 1 / eta);
Ci += trace(P, T) * color(0,1,0) * ktran;
eta += (dispersion_iota * float random());
T = refract(Ni, Nn, 1 / eta);
Ci += trace(P, T) * color(0,0,1) * ktran;
}
Ci += trace(P, R) * krefl;
}
edit :
a same approach can be found here : http://animus.brinkster.net/stuff/plg_diffraction/plg_diffraction.html
using xsi. the shader looks really complex to me, i guess it handles far more many cases than my hawfull hack :)
