Hi!
I'm trying to create a layered material for Mantra (Material Builder / Asset). I need to use the rest position, which works fine when using the material on its own (non-layered). But as soon as I pipe the output-layer into a layer mix, the binding of the rest pos gets lost.
The layer and mixing itself works perfectly fine. Just the rest position suddenly is not defined anymore (while in the SOP stream of course still being present).
It seems that binding to geo attributes in a layered material either does not work at all or needs some special magic.
Any idea anyone?
Regards
Johannes
Rest position not defined in layered material
1776 5 1-
- DeepwellAT
- Member
- 21 posts
- Joined: Sept. 2018
- Offline
-
- jsmack
- Member
- 8177 posts
- Joined: Sept. 2011
- Online
-
- tamte
- Member
- 9384 posts
- Joined: July 2007
- Offline
do you have an example?
this doesn't seem like it should be happening, binding rest to geo is the same as binding uv or any other attribute
especially if all your network with layers and layer mix is in the same Material Builder
(unless you are talking about exporting the rest variable from the shader for mantra using Bind Export per layer, in which case the rest value would need to be passed through layer struct so that it gets layered correctly and then exported out at the end
but obviously with rest that would most likely not need to be layered so it can be exported as independent branch directly)
this doesn't seem like it should be happening, binding rest to geo is the same as binding uv or any other attribute
especially if all your network with layers and layer mix is in the same Material Builder
(unless you are talking about exporting the rest variable from the shader for mantra using Bind Export per layer, in which case the rest value would need to be passed through layer struct so that it gets layered correctly and then exported out at the end
but obviously with rest that would most likely not need to be layered so it can be exported as independent branch directly)
Edited by tamte - Oct. 5, 2021 15:10:13
Tomas Slancik
CG Supervisor
Framestore, NY
CG Supervisor
Framestore, NY
-
- DeepwellAT
- Member
- 21 posts
- Joined: Sept. 2018
- Offline
Hey jsmack & tamte - many thx for your replies!
I threw together a reduced example (attached).
The custom shader ("myshader") has a parameter "use_rest". With that you can switch it from using the usual P to using the rest position instead. You can assign the "myshader" material directly to the sphere (everything works fine with both, P and rest) or assign the "layermix" to it (only works with P but not rest).
@tamte: Yes, the situation in my case is that I need to access a point attribute from inside a Mantra shader.
So if I understand correctly I would need to somehow pass the rest pos through the layer struct to the shader.
@jsmack: Not sure what is meant by "the layering shader". Would that in my little example be the layermix node? That would mean that I would need to create my own layermix shader that does that "passing along the rest attribute"?
I threw together a reduced example (attached).
The custom shader ("myshader") has a parameter "use_rest". With that you can switch it from using the usual P to using the rest position instead. You can assign the "myshader" material directly to the sphere (everything works fine with both, P and rest) or assign the "layermix" to it (only works with P but not rest).
@tamte: Yes, the situation in my case is that I need to access a point attribute from inside a Mantra shader.
So if I understand correctly I would need to somehow pass the rest pos through the layer struct to the shader.
@jsmack: Not sure what is meant by "the layering shader". Would that in my little example be the layermix node? That would mean that I would need to create my own layermix shader that does that "passing along the rest attribute"?
-
- tamte
- Member
- 9384 posts
- Joined: July 2007
- Offline
DeepwellVFXno, that was only if you want to pass a variable from shader to Mantra as an AOV
So if I understand correctly I would need to somehow pass the rest pos through the layer struct to the shader.
DeepwellVFXlong story short, you can change Bind node to Parameter VOP node and make sure Has Corresponding Connector is checked
I threw together a reduced example (attached).
attached
short story long, your Material is not built inside a single Material Builder where you would mix just layers
in case like that where you have free floating connected nodes and using just one of them as a material, Houdini will create automatic shader that wraps around the whole connected branch, so it's just important that the rest is an input connector on your myshader node so that it can be promoted to the auto shader and be still bindable
this is due to unfortunate architecture that breaks a lot of functioning shaders as soon as they are used not within new Material Builder, at least I find the auto materials breaking stuff all the time
if you keep things this way you may run into many issues like texture path expression being expanded and hardcoded to specific frame, etc...
so I'd advise always wrap your network to Material Builder and handle binds and inputs yourself
Edited by tamte - Oct. 6, 2021 11:12:31
Tomas Slancik
CG Supervisor
Framestore, NY
CG Supervisor
Framestore, NY
-
- DeepwellAT
- Member
- 21 posts
- Joined: Sept. 2018
- Offline
Hey @tamte,
works like a charm! Not in many days I would have discovered that. Many thx!!!
Weirdly one also needs to set the "Invisible" checkbox on the parameter node.
When viewing the VEX code generated for the wrapping shader (the layermix node) one can clearly see the difference:
Before:
mat_myshader("use_rest", _use_rest, "layer", layer, ...
After:
mat_myshader("use_rest", _use_rest, "rest", _rest, "layer", layer, ...
Yea, when wrapping it all in a material builder I could handle the binding myself. For one specific material that definitely would be possible (and preferable if I can avoid issues down the line).
But what I am trying to create is a set of nodes that can by combined by a "user" (a triplanar shader that can be augmented with decals). I would like to get to the point where the user just needs to layer-mix the nodes together and should ideally not need to worry about bindings.
I will see how far I get that way...
Thx again!
J.
works like a charm! Not in many days I would have discovered that. Many thx!!!
Weirdly one also needs to set the "Invisible" checkbox on the parameter node.
When viewing the VEX code generated for the wrapping shader (the layermix node) one can clearly see the difference:
Before:
mat_myshader("use_rest", _use_rest, "layer", layer, ...
After:
mat_myshader("use_rest", _use_rest, "rest", _rest, "layer", layer, ...
Yea, when wrapping it all in a material builder I could handle the binding myself. For one specific material that definitely would be possible (and preferable if I can avoid issues down the line).
But what I am trying to create is a set of nodes that can by combined by a "user" (a triplanar shader that can be augmented with decals). I would like to get to the point where the user just needs to layer-mix the nodes together and should ideally not need to worry about bindings.
I will see how far I get that way...
Thx again!
J.
-
- Quick Links

