Is there a distance-based texture for Blender?

thanks. But i don’t understand. Which one is the right scripts the 1st or the 2nd (I see 2 pieces of code )?

I did the following : I copied one of the code in the script editor, gave it a name.
Then created a script node and selected my script name.
But i have an error “OSL script compilation failed, see console for error”

May be I copied the wrong code.

Can you give me the right one please.
Sorry for bothering you I am a newbie in blender.

Nice, it works without any errors now.
Thanks you very much !!!

Here is the script working with object selection:
Object Masking.osl (2.3 KB)

Make sure you are:

  1. using cycles
  2. make sure OSL Checkbox is checked
    image

Here is node tress working:

2 Likes

Nice

sad that OSL is cpu only :frowning:

1 Like

If a freelance developer is interested in implementing such feature in main, but lacks the time/money to do so, please send me a DM

3 Likes

Hello, sorry for reviving this topic, but now that we have OSL in GPU I consider it worth to revisit it.
I have been trying but I get errors when using gpu?
Maybe osl gurus can take a look again. :wink:

if there is any way to exclude/include objects from AO, or if ambient occlusion node would have an object selection input, this maybe can be workaround in some cases… blender is robust and getting stronger every day… but I cannot live without the rendertime boolean - vraydistancetex…:wink:

Hi there, is there any implementation of this in newer versions of Blender? Or at least some kind of workaround that would give similar results that work with GPU compute?

I’m not a node/math wizard so I don’t have the slightest clue how to implement this :sweat_smile:

@Secrop @Laserschwert @adamearle @BD3D

No.

And thought OSL now works with Optix, the trace function is not included, and the script above uses trace to probe the environment.

But you might be able to do something similar with GN.

1 Like

best to ask for support here

1 Like

wow this script definitely should be put somewhere on Gumroad or Blendermarket for better visibility