mightcouldb1 Posted November 17, 2014 Share Posted November 17, 2014 Hey guys, I understand the refract function returns a refraction vector. The refractlight function returns a color. I would like to store the number of refraction bounces as the final surface color, or perhaps the length the ray traveled. Can anyone help me understand how this works for multiple bounces? Best,Jason Quote Link to comment Share on other sites More sharing options...
rsd Posted November 17, 2014 Share Posted November 17, 2014 Try to set Cf = getraylevel(). Quote Link to comment Share on other sites More sharing options...
mightcouldb1 Posted November 18, 2014 Author Share Posted November 18, 2014 Awesome thanks for that! Can anyone post a snippet of code for multiple bounce refraction? Say I had an complex surface that had multiple refractions and I wanted to know the distance that the 6th ray bounce traveled. I'm assuming I would have to handle this with the rayhittest()? Thanks! Quote Link to comment Share on other sites More sharing options...
rsd Posted November 18, 2014 Share Posted November 18, 2014 (edited) There is simple shader. By default it shows the number of bounces of last hit. Toggle raylength on to show length of the last ray. Play with refract limit to get desired level. #pragma hint last invisible #pragma hint raylength toggle surface bounces(float ior = 1.46; int raylength = 0; export float last = 0) { if (raylength) last = length(I); else last = getraylevel(); vector ni = normalize(I); vector nn = normalize(N); vector tdir = refract(ni, nn, 1./ior); Cf = 0; float imported; if (trace(P, tdir, Time, "samplefilter", "closest", "last", imported)) last = imported; Cf = last; } bounce_test1.hiplc Edited November 18, 2014 by rsd 1 Quote Link to comment Share on other sites More sharing options...
mightcouldb1 Posted November 19, 2014 Author Share Posted November 19, 2014 Thank you, this is very helpful. Very much appreciated! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.