Jump to content

Shadow Catching Material - no self shadows.


TomRaynor

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

Link to comment
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

Link to comment
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()

Link to comment
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.

Link to comment
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
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...