OSL question

Hi,

I need to write a shader where I can construct an arbitrary ray and fire it in the scene and return the color of the shaded result of the hit. Is that at all possible with OSL?

I basically need to get the shaded result of a different point in the scene.

R

Hey @Dubbie99 ,

Devs are telling me there’s a trace() function that can tell you whether a ray intersects anything in the scene or not - it doesn’t return any further information but there are other methods that can be used to obtain information regarding the point of ray<->geometry intersection. Surface color isn’t available though.

Essentially, we’re trying to figure out the exact goal you’re trying to achieve so hopefully we can come up with something.

My understanding so far is that you’re trying to contsruct a ray from an arbitrary location in the scene, i.e. not the camera, and then give it a direction → then look up the shading at the intersection point between that ray and some surface in the scene. Is that correct?

Best regards!

Thanks for the reply!
yes you’re right about my goal. I’m developing an NPR effect where I want to render an object (picture a blade of grass) a constant color based on the shading of the point it is stuck to. So if a shadow falls on the root, the whole blade of grass would darken. Right now I have the effect working by rendering a pass of the scene without the “grass” and then rendering a deep pass of the grass that has the uv coordinates baked into it. Then in Nuke I wrote a deepSTMap node that looks up the colors from the unrwrapped shaded scene and applies them.

it would be so much more efficient to do this in a shader.