question

Francis Bievre avatar image
Francis Bievre asked ·

Shader color from camera distance

Hello :)


Is there a way to input the camera distance into a shader to control its color ?


I can't find any solution ...


Thanks for your help !


Francis

shadercameras
10 |600 characters needed characters left characters exceeded

Up to 5 attachments (including images) can be used with a maximum of 2.0 MiB each and 9.8 MiB total.

Francis Bievre avatar image
Francis Bievre answered ·

It works !! Thank you for your help Peter ! capture-decran-2021-02-18-a-152311.png


10 |600 characters needed characters left characters exceeded

Up to 5 attachments (including images) can be used with a maximum of 2.0 MiB each and 9.8 MiB total.

Francis Bievre avatar image
Francis Bievre answered ·

Thanks Peter, I'll give it a try and share my progress !

10 |600 characters needed characters left characters exceeded

Up to 5 attachments (including images) can be used with a maximum of 2.0 MiB each and 9.8 MiB total.

Peter Horvath avatar image
Peter Horvath answered ·

You can access the ray length (Rl) via a state_float shader, which is the distance from the ray origin (camera) to the shading point.

3 comments
10 |600 characters needed characters left characters exceeded

Up to 5 attachments (including images) can be used with a maximum of 2.0 MiB each and 9.8 MiB total.

I can't get it to work ... I don't get how to output a Z like render of my surface with a black and white gradient ... Any tip ?

0 Likes 0 ·

I plug the output of the RL into a ramp_float node, but all I can get is a uniform color, even when I play with the spline or the UV projection

0 Likes 0 ·

It's an absolute distance (in meters), you need to remap with a range shader.

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 5 attachments (including images) can be used with a maximum of 2.0 MiB each and 9.8 MiB total.

Welcome to the Arnold Answers community.

This is the place for Arnold renderer users everywhere to ask and answer rendering questions, and share knowledge about using Arnold, Arnold plugins, workflows and developing tools with Arnold.

If you are a new user to Arnold Answers, please first check out our FAQ and User Guide for more information.

When posting questions, please be sure to select the appropriate Space for your Arnold plugin and include the plugin version you are using.

Please include images, scene and log files whenever possible as this helps the community answer your questions.

Instructions for generating full verbosity log files are available for MtoA, MaxtoA, C4DtoA, HtoA, KtoA, and Kick.

If you are looking for Arnold Documentation and Support please visit the Arnold Support site.

To try Arnold please visit the Arnold Trial page.

Bottom No panel present for this section.