Shader colour based on bounding box

   5883   6   2
User Avatar
Member
292 posts
Joined: 12月 2007
Offline
Good Day Houdini gurus.

I would like to change the colour of a mantra surface shader based on whether or not it is inside a bounding box. if inside, i would like the colour to be zero black, otherwise white. I need to animate the position of the bounding box. I have been thinking about this and looking through the shader for some time. It is not readily apparent to me how to approach this problem.

Any thoughts on how to start would be most appreciated

Nick
User Avatar
Member
638 posts
Joined: 6月 2006
Offline
i have made a simple example.
i don't know if it's the best way but it's a start and it works. :-)

Attachments:
ShaderGoesBlack.hipnc (456.6 KB)

User Avatar
Member
292 posts
Joined: 12月 2007
Offline
Hmmm. Maybe I haven't explained my problem well. I'll try again.
In your example scene, I would like the grid to be black wherever the sphere intersects it. The scene posted does not seem to do this.

Nick
User Avatar
Member
258 posts
Joined:
Offline
Could you not use grouping….you would “group by bounding box”. Pipe the object, or create a bounds object and pipe it into the second input of the group node. You would pre-color your object to white, then append another color that colors the group that has been created by the bounds black.

Here is a file that does that.

Attachments:
group_bounds_and_color.hip (94.7 KB)

User Avatar
Member
258 posts
Joined:
Offline
Could you not use grouping….you would “group by bounding box”. Pipe the object, or create a bounds object and pipe it into the second input of the group node. You would pre-color your object to white, then append another color that colors the group that has been created by the bounds black.

Here is a file that does that.

Attachments:
group_bounds_and_color.hip (94.7 KB)

User Avatar
Member
1391 posts
Joined: 12月 2010
Offline
I think lor's meant is to do this operation in the shader , Because doing this in the SOP Level with Group SOP is related to number of the points , If you have simple grid with only 4 point , and you put the Bounding Box in center of the grid , because we don't have any point on there , the Group SOP can't select any points , Right ?

But if we do it in the Shaders , we can use Pixels instead of Points and we can do this operation on grid with only 4 point !

We should find another way in the Shader and Rendering Process :?
https://www.youtube.com/c/sadjadrabiee [www.youtube.com]
Rabiee.Sadjad@Gmail.Com
User Avatar
Member
19 posts
Joined: 11月 2013
Offline
hi,you can turn the bounding box into volume and use the volumesamplefromfile in the shader to distinguish which part is inside or outside the volume.dont forget to change the space to “world”.
  • Quick Links