5
$\begingroup$

I'm trying to make a fake AO shader using nodes, which gives the color of the AO rather than a closure.

I thought it would be pretty easy to get the ray length of reflection rays and map that to 0-1 for use as the surface color, however it seems shaders mixed based on is reflection ray only affect reflection rays and can't affect the object as seen from the camera.

enter image description here

The above node setup affects the color of the object as "seen" by rays reflected off the floor plane, but not for camera rays.

I'd like to use the length of the the reflection ray in the example below to set the color of the object as seen by direct camera rays:

enter image description here

Is this even possible?

$\endgroup$
6
  • $\begingroup$ Could you be a bit more clear on what you want :). $\endgroup$ Jul 26, 2014 at 19:31
  • $\begingroup$ @GiantCowFilms Is that clearer? $\endgroup$
    – gandalf3
    Jul 26, 2014 at 19:45
  • $\begingroup$ Yes, much clearer :) $\endgroup$ Jul 26, 2014 at 19:59
  • $\begingroup$ I don't think it is possible, not without scripts at least; Because Blender calculates each ray type separately, so a ray can never be both reflection and camera ray. $\endgroup$ Jul 27, 2014 at 12:38
  • $\begingroup$ @someonewithpc You might be right, but I don't see why the ray needs to be both a reflection and a camera ray.. Getting the length of the reflection ray is easy, but using that to set the color of the direct camera ray seems to be impossible. $\endgroup$
    – gandalf3
    Jul 28, 2014 at 19:19

3 Answers 3

4
$\begingroup$

Wow, I'm happy you thought of doing this. Baking AO using Cycles is problematic since none of the available scripts bake properly.

I still have not thought of a way to use the Ray Length node to adjust the results of the Reflection Ray but this basic setup looks good enough to suit my needs.

On the left is the Reflection Node used to control two shaders(or use 2 colors for 1 shader). On the right is a default Diffuse shader.

Beautiful, thanks!

enter image description here

EDIT: Here is a modified setup that may or may not be attenuating based on ray length.(I'm not totally sure that the setup isn't just behaving like a Color Ramp and squashing brightness/brightness)

The colors values for the Diffuse node and the Sky are all (1.0, 1.0, 1.0).

enter image description here

enter image description here


UPDATE: using direct lighting should give the darkest effect without any color mix node setup. Otherwise, what was done here cancels global illumination bounces to exaggerate the AO which is normally washed out from bounced lighting.

$\endgroup$
4
  • $\begingroup$ This is almost like what I want, except I was hoping for the shader to give the occlusion effect on the object it was assigned to, not the objects near it.. I'm just about at the point of thinking it's not possible currently, so this could be a okay workaround in some cases. It doesn't really give more control than built in cycles AO though.. $\endgroup$
    – gandalf3
    Jul 29, 2014 at 6:16
  • $\begingroup$ That helps to come up with a solution. At least it helps to know if a solution is working or not. "Self-shadowing" is key here. I added a long thin protrusion coming up from one of the faces so if AO starts to work, it will show up on nearby geometry. If the protrusion does not show up then the settings are still just producing something more like Diffuse lighting. $\endgroup$ Jul 30, 2014 at 3:50
  • $\begingroup$ I think that part of what needs to be done here is the Camera distance has to be taken out of the equation. Corrosion on the crevices of silver will not be affected by the viewers distance and from what I can see, Ray Length includes Camera info so this should be nullified somehow. $\endgroup$ Jul 30, 2014 at 4:18
  • $\begingroup$ I've posted a separate question to help get this solved. blender.stackexchange.com/questions/14518/… $\endgroup$ Jul 30, 2014 at 4:53
1
$\begingroup$

I don't think this is possible, as shaders can only operate on one incoming ray at a time.

To do what I want to do, I would have to store the length of incoming reflection rays, and give that to incoming camera rays.

$\endgroup$
0
$\begingroup$

I think this is what you want:

Node Setup

It gives this result:

Render Result

The plane bellow only has a Glossy shader, with Roughness of 0,05.

The idea is that you use the value for "Ray Length" that comes with the Light Path node, the I multiply it by like 500, because that's green in terms of Wavelength, but you can generate a color using a Combine RGB node. Then just use the Is Reflection Ray as the factor for a Mix shader, so it only shows up for that ray.

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .