Jump to content

object proximity shader via SDF


Recommended Posts

I am trying to create a simple shader that maps the distance from an object to the red channel.

I have a plane I assign the shader to.

I have a torus converted to SDF.

In the shader I convert P to world space, then use a "volume sample from file" to sample the rendered pixel from the SDF and feed the result to the red channel of my diffuse color.

In order to specify the 'file', I use this code

op:`opfullpath("/obj/geometry/OUT_SDF")`

When I render i just get a black frame.

The geometry is there cause i can see the alpha of the plane, but apparently nothing comes out from that "volume sample from file" node.

post-1409-0-16302100-1367024973_thumb.jp

I wonder if it's possible to fetch sdf data directly into a shader.

I attached the hip file to illustrate my issue.

p.s.

I don't want to use an attribute transfer approach in SOP land cause I want to maintain the 'pixel' level resolution in my shader, and don't want to rely upon the resolution of my plane.

Any idea ?

proximity_shader_test.hip

Link to comment
Share on other sites

you cannot use op: syntax with shader

mantra will not find the path to the node

so you need to export SDF volume to actual file and read that to shader

Tomas, thank you for your answer. I did as you suggested and it works perfectly.

It's a bit of a bummer we cant use op functions on shaders.

Is there a reason for that ?

Link to comment
Share on other sites

imagine you export IFD file for mantra, it doesn't contain your houdini network so the path to the node is meaningless, even if it knew which node it was it cannot cook the geometry

the only other way would be if houdini included op: referenced geometry in the IFD which I don't think it's possible currently, that would be less efficient than keeping the geometry separated, especially if it's not time dependent, but still quite nice as it would not require user input

EDIT: it is however possible to use op: syntax to reference COPs in shaders which actually includes the image in IFD

Edited by anim
Link to comment
Share on other sites

That makes perfect sense.

But still I'd have kept the functionality.

I mean...it would be nice the following:

if the string in the "file" parameter has an op command and there is actually a node to cook then Mantra should go ahead and wait for the result as it does for cops for instance. This would even maintain the compatibility with "sample volume from file" nodes in POP or SOP vex land, instead of just return the information zero (without even erroring out).

If the string in the file field is an actual file, then better for everybody !

My philosophy in this case would be to keep the functionality as open as possible, and enforce the error reporting.

imagine you export IFD file for mantra, it doesn't contain your houdini network so the path to the node is meaningless, even if it knew which node it was it cannot cook the geometry

the only other way would be if houdini included op: referenced geometry in the IFD which I don't think it's possible currently, that would be less efficient than keeping the geometry separated, especially if it's not time dependent, but still quite nice as it would not require user input

EDIT: it is however possible to use op: syntax to reference COPs in shaders which actually includes the image in IFD

Link to comment
Share on other sites

It would be definitely possible to include any referenced geometry inside IFD file similarly to images, it is just not production wise. Half of the fields come from simulation, thus are already cached on disk, another come from sops and cook really slow, so they should be baked before ifd generation anyway. Plus, they are big, and big IFD is a secret evil, which bloats your network to depth in a least expected time (read deadline). The easiest answer isn't always the best one.

Link to comment
Share on other sites

Szymon, I am totally with you on this.

I am not an expert in Mantra, I am just expressing my logic as a 'non expert' :)

I didn't suggest to include any further data into the IFD.

What I meant is that while in interactive mode, using the UI inside Houdini, it would be cool the keep the "op" functions working even from shaders, since from Houdini UI... Mantra can access all the nodes of the hip file.

Now a question just popped in my mind...:)

Is the scene converted to IFD on the fly even during a Houdini interactive render with Mantra ?

Link to comment
Share on other sites

Is the scene converted to IFD on the fly even during a Houdini interactive render with Mantra ?

Historically it was, but with a recently introduced optimization, Mantra can share geometry with Houdini in IPR mode, which along with a partial updates makes it snappier, but still IFD is a backbone of that process afaik.

Link to comment
Share on other sites

I see now !

Thank you for the explanation Szymon and Tomas, very much appreciated :)

Historically it was, but with a recently introduced optimization, Mantra can share geometry with Houdini in IPR mode, which along with a partial updates makes it snappier, but still IFD is a backbone of that process afaik.

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...