Sampling a volumes density value in a surface shader.

   3123   5   1
User Avatar
Member
117 posts
Joined: July 2005
Offline
Hi all,

I'm trying to lookup the density value of a volume in a surface shader. She surface being shaded is spatially located inside the volume. I've looked at the Volume Sample VOP but it doesn't appear to be doing anything in the shader context? I'm trying to achieve something similar to the Volume Slice SOP, except for arbitrary slicing geometry, and for it to be done efficiently at render time.

Any help appreciated.

-Drew
User Avatar
Member
117 posts
Joined: July 2005
Offline
Replying to my own post, the secret was to transform the incoming position from space:current to space:world in the shader.

But I'd like to ask a followup question, how do I now get a SOP volume to be the input to the Volume Sample VOP, instead of loading from file? I don't know how to plumb this up?
User Avatar
Member
117 posts
Joined: July 2005
Offline
Replying to my own post, the secret was to transform the incoming position from space:current to space:world in the shader.

But I'd like to ask a followup question, how do I now get a SOP volume to be the input to the Volume Sample VOP, instead of loading from file? I don't know how to plumb this up?
User Avatar
Member
7737 posts
Joined: Sept. 2011
Offline
There's a couple ways to do this. One, like you have tried so far is use volume sample vop, and feed it a volume file on disk. You can use a rest space to sample from if the geometry is deforming. I'm not sure if you can read live volumes in your scene this way, but you could try replacing the file path with op:/obj/path_to_volume_sop
Another method is to trace against an invisible volume object in the scene. I have attached an example of this. This doesn't quite work the same way, as the value is ‘accumulated’ along a short ray.
Edited by jsmack - June 14, 2017 03:50:49

Attachments:
paint_example.jpg (343.7 KB)
volume_paint_shader_example.zip (167.8 KB)

User Avatar
Member
117 posts
Joined: July 2005
Offline
Thanks Jonathan,

Studying your hip file at the moment. FYI this was what I was working towards …

-Drew
Edited by drew - June 19, 2017 19:24:29

Attachments:
radar_100m_groundplane.jpg (339.5 KB)

User Avatar
Member
7737 posts
Joined: Sept. 2011
Offline
I did a test with volumesample in my shader, and it works very well. There are a couple things needed to make the op file reference work though. The object containing the geometry referenced by the shader needs to be included (visible) in the render, and to prevent it from appearing in the image, Render Visibility (vm_rendervisiblility) should be set from ‘*’ (default all) to '' (blank).
  • Quick Links