Coyote_Actual Posted April 20, 2018 Share Posted April 20, 2018 I hope the title is clear enough, essentially what I am trying to do is create a custom image plane that will output an rgb matte for objects being refracted by another object. (in my case objects inside a glass sphere) lets say i give an object inside the glass sphere a vector attribute of green {0,1,0} is it possible to output an image plane that displays that attribute through the refraction of the outer sphere? I've been searching for a while all over google and OD but have yet to find exactly what I'm after.. I feel like Trace() is about the closest thing I could find, but not sure how that would work for what I'm trying to accomplish.. Perhaps my approach is wrong as well, if anyone knows hows to accomplish something like this, I'm all ears. Ideally I'd like to accomplish this with image planes if possible and avoid having to create separate takes and what not.. Thanks!, -C Quote Link to comment Share on other sites More sharing options...
StepbyStepVFX Posted April 20, 2018 Share Posted April 20, 2018 Why don’t you apply a constant shader to your objects with the color you want them to have in the matte ? For the shader of your sphere just keep the refraction and kill the specular, and it should work, isn’t it ? Quote Link to comment Share on other sites More sharing options...
Coyote_Actual Posted April 20, 2018 Author Share Posted April 20, 2018 @StepbyStepVFX, thanks for the reply... you are correct in that I can do something like this (e.g. create another mantra ROP and associate a 'take' with it, and apply constants etc..) I was more curious if there was a 'smarter' way to do this. Something to the effect of using a ray to capture the attribute and drawing it on a ROP image plane without having to change any render settings or material assignments! -C Quote Link to comment Share on other sites More sharing options...
toadstorm Posted April 20, 2018 Share Posted April 20, 2018 (edited) Your `trace()` instinct is about right, but personally I'd use `gather()`. You need to provide `gather()` with a position P and a direction T. The Fresnel VOP can get you T based on N, I (the camera ray) and an IOR (called eta here). Then tell `gather()` to sample the value of the exported AOV attribute (multimatte RGB or whatever) you want to be refracting in this shader: vector temp = 0; vector hit; gather($P,$T,”bias”,0.01,”samples”,1,”name_of_aov_attribute”,hit) { temp += hit; } $out = temp; then you can bind that output to any export you like. i'm only doing one sample here, but if you needed smoother samples you could increase that number, then divide `temp` by the number of samples after your gather loop is done. i used an Inline VOP for that code, but it'd probably work in a snippet if you changed from $ style variables to snippet syntax. Edited April 20, 2018 by toadstorm Quote Link to comment Share on other sites More sharing options...
Coyote_Actual Posted April 22, 2018 Author Share Posted April 22, 2018 @toadstorm I really appreciate this response as well.. this was definitely more in line with what I was thinking.. I can picture conceptually of what I would need to do to retrieve that data, but finding the correct functions and what not become a little daunting.. So, I attempted you use your code in a test scene.. but I'm unsure if I'm putting it in the proper place / feeding it the correct data.. If I were to go the inline VOP route. I would put that in the mat context, yeah? then I would use your code and plug in the outputs of a fresnel to get T. I'm a little confused about what position I'd feed it.. I think in general my understanding of setting something like this up in the mat context confuses me.. i.e. in an attribute vop (on geo for instance) the position's source is already implied by the pipe that is plugged into the node.. I hate asking this.. but i feel like I'm more of a visual learner.. is there anyway you could throw together a quick scene that has this laid out.. or perhaps just elaborate a little more on the inputs and output on the inline VOP? Cheers, -C Quote Link to comment Share on other sites More sharing options...
toadstorm Posted April 23, 2018 Share Posted April 23, 2018 here you go! The teapot is exporting a "matte" AOV, which is a solid red color. This is handled inside the teapot's shader. To get the glass sphere to refract this AOV, we include the code I posted above in an Inline VOP in the sphere's shader. It uses gather() to look for this same export from other objects in the scene, then writes back to that same "matte" AOV. refract_aov.hip 2 Quote Link to comment Share on other sites More sharing options...
Coyote_Actual Posted April 24, 2018 Author Share Posted April 24, 2018 AWESOME! @toadstorm, Thank you for doing that! Funny thing is, I had something wired up almost exactly the way yours was.. but it's the almost that got me.. Again, thanks, I'm one step closer to understanding all the different contexts and ways to accomplish things in houdini! -C Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.