2
$\begingroup$

Is there a way to have a shader behave differently near a mesh edge?

For example, if a shader generates a checkered pattern, is it possible to detect the edge and make the squares that intersect the edge transparent?

enter image description here

Some clarifications:

  1. The solution can be for a single face. In other words if the edge can be detected on a signle face.
  2. The solution should work even if the face is not a simple shape like a circle, square, or triangle.
$\endgroup$
5
  • $\begingroup$ Sorry if my question is silly, but by "make the squares that intersect the edge transparent" in this case do you literally mean you want only the 9 squares in the middle to be opaque while the other ones that intersect the edge fully transparent? Or do you just want a smooth gradient around the edge that can be made transparent? $\endgroup$ – uvnoob Aug 23 '20 at 19:34
  • $\begingroup$ I want only the 9 squares in the center to be opaque. The squares on that intersect the eve should be transparent. $\endgroup$ – Ed Tate Aug 23 '20 at 20:23
  • $\begingroup$ blender.stackexchange.com/questions/114079/… $\endgroup$ – Ed Tate Aug 23 '20 at 23:25
  • 1
    $\begingroup$ "The solution can be for a single face. In other words if the edge can be detected on a signle face" - you mean a solution would be acceptable if the same shader turns the whole face transparent only if the face has a border edge? If that is the case, would the following work: Script that assigns UV coordinates of (0,0) to faces (their vertices) touching borders, otherwise set UV to (1,1). Then you could easily manipulate every face based on generated UV values. $\endgroup$ – uvnoob Aug 24 '20 at 7:59
  • $\begingroup$ @uvnoob I agree that this should work. You would need a very dense geometry though $\endgroup$ – Gorgious Aug 24 '20 at 8:31
0
$\begingroup$

I'm not at my pc at the moment, so I can't test it, but I can point you in the right direction, I would use a colorramp-node and mask out the dark squares so they are transparent, then use the geometry-node (docs.blender.org/manual/en/latest/render/shader_nodes/input/…) to create a mask for the position, use another colorramp to set the threshold, and then blend between the original and the transparent texture using a mix-node and the factor comes prom the mask. I hope that helps and I'm sorry that I can just be theoretical at the moment. All the best – Marco Vitale

$\endgroup$
1
  • $\begingroup$ The challenge that this is part of an animation and I only want to have the dark cell on the edge of the mesh transparent. $\endgroup$ – Ed Tate Feb 27 at 18:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.