View Full Version : Setup to detect reflected ray length?

03-12-2008, 12:25 PM
I'm trying to figure out how to use spot info or even raycast/trace to find out the ray distance from a reflective surface spot to the object spot being reflected. You could use this info to attenuate reflection based on distance such that an object on a reflective floor would have that "dieing off" reflection look which is fairly common and takes 2 seconds to do in photoshop, but would be nice to have in the render for animations for instance. You can do this cheaply with incidence angle and a gradient but it's way more finicky and of course only works for a set camera position.

03-12-2008, 01:27 PM
So I recreated the vector reflection equation with nodes R = 2(N, and with a little trickery I've got it working! Of course the raw output needs to be scaled and subtracted from 1 (otherwise the reflectivity goes up with distance). Here's it laid out for anyone else who might find this trick useful. The whole node thing is impressively powerful, and I don't know much about it all besides a little high school trig ;D

This of course will work for any reflective surface and with every other object in the scene as it works by ray! Basically you're taking the ray source (camera) angle, reflecting it manually and casting it yourself to find out the distance per reflective pixel.

Of course you can use this info to scale the contrast of the reflection as I do overall sometimes for effect, which for instance looks fantastic on black car paint.

05-01-2008, 11:27 AM
This seems to give rather erroneous results. Though close when used with some simple objects and spheres, it becomes pretty weird when used on a floor or other flat surfaces. I tried to work with it last night, but after far to long banging my head against a wall (and about 100 of the weirdest raytraced test renders I could have ever imagined) I had to give up.

This morning I found the correct reflection setup on Spinquad (http://www.spinquad.com/forums/showthread.php?t=17839&referrerid=1336). Maybe this can help? It's a quick implementation to use with your distance setup above... and should yield accurate results.

I'm using something similar now (along with RayTrace) to create fading + blurry reflections for a floor (using Y inversion instead of normals to drive the direction, since I'm still working out the correct normals based blurring - vector math is not my thing).