MaterialX - direction to eye vector

   4146   9   1
User Avatar
Member
306 posts
Joined: July 2005
Offline
Hi,

Is there a way to get the I vector in materialX? I want to do ye olde |N|.|I| roll off stuff.

Using the standard Global Variable vop won't mix in the mtlx network.

Thanks!
“First things first – but not necessarily in that order”
– The Doctor
User Avatar
Member
7741 posts
Joined: Sept. 2011
Online
Use the mtlx position to get I, and the mtlx normal for N, both in camera space ("space:camera")

Attachments:
mtlx_facing_ratio_example.hip (169.2 KB)

User Avatar
Member
306 posts
Joined: July 2005
Offline
Hey - ah yeah, thanks mate! I had been trying that, but only tested with XPU where I found space:camera returns same as space:object. Doing same with CPU works as expected.

Will report bug. Cheers.
“First things first – but not necessarily in that order”
– The Doctor
User Avatar
Member
306 posts
Joined: July 2005
Offline
Also - while this actually does the trick for my use case, position in camera space is only equivalent to I for the first ray - reflections will be bung. No fresnel node either which would do the job.
“First things first – but not necessarily in that order”
– The Doctor
User Avatar
Staff
1448 posts
Joined: July 2005
Offline
There was some talk about fresnel in MaterialX on ASWF Slack:

Yes, the fresnel node was removed in 1.38 in an effort to limit the support for view-dependency in MaterialX shader graphs. When view-dependent nodes are allowed to be used anywhere in a shader graph it makes it hard to support for bidirectional rendering techniques, where reciprocity is a strict requirement. So in order to keep MaterialX as portable as possible to all different renderers we decided to remove the nodes: fresnel, viewdirection and backfacing.

In practice this restriction was introduced in MaterialX 1.38 by the MDL back-end, because MDL has no support for general view dependency, because of its requirement to support bidirectional path tracing. So fresnel, viewdirection and backfacing was not possible to implement in MDL, and any shading graph containing them would not be portable.

But I think it's a fair point to say that something like a facing-ratio node would be very useful. I think we need to discuss how something like that could be introduced without breaking portability.
User Avatar
Member
7741 posts
Joined: Sept. 2011
Online
I found using the geompropvalue to get 'I' also works, and works correctly in reflections.

Edit: it doesn't seem to work in XPU though
Edited by jsmack - Nov. 29, 2021 11:50:24

Attachments:
mtlx_facing_ratio_example2.hip (284.3 KB)

User Avatar
Member
710 posts
Joined: July 2005
Online
jsmack
I found using the geompropvalue to get 'I' also works, and works correctly in reflections.

Edit: it doesn't seem to work in XPU though

This would do the trick for me in a lot of cases, thanks jsmack. Shame about XPU, hopefully that's just the alpha blues.
User Avatar
Member
12433 posts
Joined: July 2005
Online
It would seem a bit self-limiting if the MaterialX guys scoped Mtlx to one style of rendering (bidirectional pathtracing) rather than allowing a broader implementation and potentially supporting more styles of render engines. Perhaps they could consider adding some sort of tag schema to Mtlx nodes with properties that an implementation could correlate with the abilities of their supported renderers.
Edited by jason_iversen - Nov. 30, 2021 02:33:25
Jason Iversen, Technology Supervisor & FX Pipeline/R+D Lead @ Weta FX
also, http://www.odforce.net [www.odforce.net]
User Avatar
Staff
466 posts
Joined: May 2019
Offline
jsmack
Use the mtlx position to get I, and the mtlx normal for N, both in camera space ("space:camera")

"space:camera" is not part of the MaterialX specification.
https://www.materialx.org/assets/MaterialX.v1.38.Spec.pdf [www.materialx.org] (page 29)

I'll have a chat with others at SideFX to see if XPU should support it or not.

jsmack
I found using the geompropvalue to get 'I' also works, and works correctly in reflections.

'I' is not really a property of the geometry, so I don't think it would really be valid to have it come through via the geompropvalue. (again I'll chat to others at SideFX to see if XPU should support it)


IMO a better way to get the incoming ray direction is via the MtlxDot ray-import stuff (that works in both KarmaCPU and KarmaXPU).
https://www.sidefx.com/docs/houdini/solaris/karma_xpu.html#summary [www.sidefx.com]

So to do what you're asking, I would suggest...
- have a MtlxNormal node (set space to "world")
- have a MtlxDot node (put ray:Das the note), and multiply by -1, which will produce the equivalent of "I"

See attached example + screenshot
Cheers
Edited by brians - Dec. 7, 2021 18:43:51

Attachments:
raydir.JPG (120.0 KB)
ray_import_raydir.hip (279.0 KB)

User Avatar
Staff
466 posts
Joined: May 2019
Offline
Hi guys

I have spoken to others at SideFX.
We have decided that "space:camera" and geom-prop "I" will not be supported in XPU.
reasons:
- they are not in the MaterialX standard
- we've suggested a suitable (and possibly more preferable) alternative

thanks for raising the issue in any case.
Brian
  • Quick Links