Search - User list
Full Version: mtlx offscreen matte
Root » Solaris and Karma » mtlx offscreen matte
daveborck
Hi,

I need to make a shader using materialx that is white when seen in camera view and black when offscreen. So far the only way I managed to do that is using mtlxposition with camera_path:ndc plugged into texcoord of mtlximage node where I can put a white image and make everything outside black with Default Color parameter.

That sounds very awkward though. Is there more procedural way that doesn't require a white image?

Thanks for any suggestions
Dawid
Tanto
Sorry, can't upload a file, so here goes:

Separate your ndc position into three floats.

For the X and Y components: subtract 0.5, and find the absolute value of the result.

Plug that into a If greater conditional, so that if greater than 0.5, value is 0, otherwise, value is 1.

Do that for both X and Y, multiply both together, and plug the result into all inputs of a combine3.
vicvl92
Tanto
Sorry, can't upload a file, so here goes:

Separate your ndc position into three floats.

For the X and Y components: subtract 0.5, and find the absolute value of the result.

Plug that into a If greater conditional, so that if greater than 0.5, value is 0, otherwise, value is 1.

Do that for both X and Y, multiply both together, and plug the result into all inputs of a combine3.

Wow, I happened to need exactly this kind of effect — thank you so much for the tip!

Is there a way to adjust the edge sharpness without affecting the core matte?
Tanto
vicvl92
Sorry, can't upload a file, so here goes:

Wow, I happened to need exactly this kind of effect — thank you so much for the tip!

Is there a way to adjust the edge sharpness without affecting the core matte?

Sure, instead of using If greater, use a Range:

inlow: 0.5
inhigh: 0.6
outlow: 1
outhigh: 0

Adjust inhigh and gamma as needed for your desired falloff.
daveborck
Finally had time to test it and it worked very well indeed!

Thanks a lot, very clever
vicvl92
Tanto
vicvl92
Sorry, can't upload a file, so here goes:

Wow, I happened to need exactly this kind of effect — thank you so much for the tip!

Is there a way to adjust the edge sharpness without affecting the core matte?

Sure, instead of using If greater, use a Range:

inlow: 0.5
inhigh: 0.6
outlow: 1
outhigh: 0

Adjust inhigh and gamma as needed for your desired falloff.

Hi Tanto, thanks for the reply. I got one more question to ask.

I was trying to extract the matte from the backface based on the camera’s view angle. But it doesn’t seem to work as expected on single-sided geometry like the grid plane and torus inner face that shown in the screenshot — probably because it doesn’t have depth (Z coordinate). Do you know how to achieve this effect? Here’s what I’ve tried so far(not sure i am doing right or wrong):
vicvl92
Gladly, I found the solution.

Here's the workaround:
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB