Jump to content
TomRaynor

Shadow Catching Material - no self shadows.

Recommended Posts

Calling all shader making wizards...

 

I am trying to make a simple shadow catching material like the shadowMatte material that has the option to be able to toggle on and off "enable self shadows". If this tickbox is on, then each object can cast a shadow on itself. If it is off, then each object cannot cast a shadow on itself. As a bonus it would be great to have something like an "object scope" parameter similar to the occlusion vex node, where I could pass in a list of objects that the shader would use to enable or disable self shadowing.

 

I have attached a file showing where I have got to. This works for enabling or disabling self shadows on a single object but it seems to require one shader per object to work properly if I want to apply the shadow catcher to multiple objects.

 

I would prefer to do this by wiring vops together than writing in vex but whatever works :)

 

Thanks in advance!

 

 

shadowCatchingShader_v01.hip

Share this post


Link to post
Share on other sites

Hi Tom,

You can try fastshadow or filtershadow since they have scope inputs.

 

Then make:

- inline vop and put "$objname = getobjectname();"  in the code window

- set "objname" in the Output 1 Name

- set the Type to string.

- plug result into both inputs of a compare vop, to check if objname == objname.

- plug into a switch

- add 2 string constant vops and plug into the switch

- set the first constant to scope everything "*", or make this a parameter.

- set the second to empty

- plug into scope of filter shadow.

 

Hopefully it works because I haven't tried it! :)

 

Cheers

S

Share this post


Link to post
Share on other sites

ermm... just thinking about it again, not sure my logic is sound... you might need the second input to not be empty. I think needs to be another inline vop where you composite a string attribute to give * ^getobjectname()

Share this post


Link to post
Share on other sites

Hmmm. I have tried plugging a few nodes together and am not getting too far.

Are you saying that I can use the fast/filter shadow vops mimic the behaviour of the shadowMatte vop or do I need this vop in my shader network as well.

If you get any time to throw together an example scene that would be really helpful, as I am a bit lost at the moment.

Share this post


Link to post
Share on other sites

Unfortunately I'm too busy today, but I can look at it tomorrow evening if that still works for you?

Share this post


Link to post
Share on other sites

Hi there,
My logic was laughably flawed from the outset, but its sorted now :)
Turned out more complicated than I first thought as it also needs an illuminance loop and some extra stuff to match the output of the shadow matte shader.

It could do with somebody with more advanced vex experience/time to figure out how to split a string with multiple object paths into an array or something, because at the moment it requires one field per object that you want to turn off self shadows. Its fairly obvious how to add more if you need to exclude more than the 10 I added... but that could get out of hand.

 

Hope it works for you.

 

Cheers

Sergio

shadowCatchingShader_v02.hip

Edited by Serg

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×