mtlx offscreen matte
925 6 1-
- daveborck
- Member
- 32 posts
- Joined: March 2019
- Offline
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
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
- Member
- 538 posts
- Joined: Nov. 2016
- Offline
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.
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.
Edited by Tanto - July 25, 2025 13:54:37
-
- vicvl92
- Member
- 4 posts
- Joined: Feb. 2022
- Offline
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
- Member
- 538 posts
- Joined: Nov. 2016
- Offline
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.
Edited by Tanto - July 28, 2025 11:27:16
-
- daveborck
- Member
- 32 posts
- Joined: March 2019
- Offline
-
- vicvl92
- Member
- 4 posts
- Joined: Feb. 2022
- Offline
Tantovicvl92
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):
Edited by vicvl92 - Aug. 3, 2025 22:33:26
-
- vicvl92
- Member
- 4 posts
- Joined: Feb. 2022
- Offline
-
- Quick Links