PDA

View Full Version : Distance to surface for fake reflection blur?



biliousfrog
05-07-2010, 03:40 AM
Is there a way to set up a distance to surface gradient?

Why?

Well...I spotted a post by someone on here regarding fake reflection blur by using Frishluft's lens blur in post. I wasn't exactly sure how it was achieved in their example but I've got an idea for how I'd do it for stills and animations.

You wouldn't require Frishluft, Photoshop/After Effect's native lens blur would be equally sufficient. The idea is to use a pseudo depth map on the reflections to create a blur fall-off...which is where a distance to surface shader or node setup would be required.

The theory

I considered using ambient occlusion but the dark areas would affect more than just the area close to the reflective surface (any creases), this would need to work solely with the interaction between the objects to be reflected and the reflective surface itself.

The idea is to render a seperate pass with the reflective surfaces at 100% reflection and everything else using a shader/node set to go from black-white according to the distance from the reflective surface. An alpha for the reflective surfaces would act as a mask and the gradients reflected in the surfaces would be used as a depth map for the blur.

Limitations (that I know of)

Multiple reflection bouces could potentially cause problems...multiple passes would be required.

...Thoughts?

Salv8or
05-07-2010, 03:55 AM
I see your idee, and thought about something similar just a while ago. It sould work just fine in theory. But I dont know how to get the distance of a reflective ray.
Isnt there a node for rayID/raysample, or something?
In that case, a raylength node in conjuction with that.
Must have a look when I come home.

biliousfrog
05-07-2010, 04:27 AM
I see your idee, and thought about something similar just a while ago. It sould work just fine in theory. But I dont know how to get the distance of a reflective ray.
Isnt there a node for rayID/raysample, or something?
In that case, a raylength node in conjuction with that.
Must have a look when I come home.

I've no idea, I'm fairly clueless with regard to setting up node trees but my very naive thoughts are that AO shaders manage to calculate distance from their own object's and other objects surfaces so why can't we just work with seperate objects?

It's not an ideal solution but for scenes such as a classroom where you only want the floor and table tops slightly blurred it would be quite useful...especially when animated.

Salv8or
05-07-2010, 05:14 AM
There is a output in the spot info that is called bounce, wich is supposed to give you the rayrecursion number for reflection. 0 for first/direct ray, and 1 then 2 then 3 and so on..
If you could combine that with the ray length in some way.. Have no idea how, but I guess its not impossible.

Captain Obvious
05-07-2010, 08:19 AM
This node collection contain a basic 'reflection distance' setup. The distance output from the ray trace node should return the distance (in meters) to whatever the surface hits. I didn't try it, so it's possible I screwed it up. :p

biliousfrog
05-07-2010, 09:09 AM
This node collection contain a basic 'reflection distance' setup. The distance output from the ray trace node should return the distance (in meters) to whatever the surface hits. I didn't try it, so it's possible I screwed it up. :p

Something is happening but I don't think that it would work...although I haven't really played with it yet.

I've attached a render using your node setup (untouched) and another using a distance to object gradient on the objects and the reflection object at 100% reflectiveness to show what I was originally thinking.

By using a distance to object/surface you can still control the reflectance via incidence gradients because it is the objects which are shaded. It also means that you can control the backdrop colour to be black, white or whatever to match the reflected objects.

The problem with distance to object is that it works from the pivot point and you'd have to manually adjust every surface to get it working. If you could use distance from a surface's normal you could easily set up a quick render using just two surfaces - one for the gradient and another for the reflective surfaces.

Am I making sense?...I'm not sure whether I'm explaining it very well.