0
$\begingroup$

Image textures have a "Clip Cube" extension mode that sets all areas outside a cube around the image as transparent.

Is there a way to set to a default value instead of transparency, somewhat similarly to how the "Extend" mode extrapolates the nearest pixel value? It should work with modifiers.

This is both a subset of and a workaround for the behaviour that used to be possible with voxel image sequences, so if there is a way to get those back then that would also count as a solution to this problem.

$\endgroup$

1 Answer 1

2
$\begingroup$

Assuming I'm getting you correctly, it's not "clip cube"-- it's just, "clip". What this does is return 0,0,0,0 RGBA for any vectors that are out of bounds: any vectors with any components that are outside the 0,1 range.

If you want to use a specific color for anything outside of this range, almost like clip border mode does with 0 RGBA, one way to do it is to just check whether the vector is out of bounds:

enter image description here

That's just how I figured to do it with the fewest nodes (no separation nodes): we compare the length of our original vector to the length of our vector clamped to the 0,1 range, and if the original vector is longer, we're out of bounds. In this case, that means mixing with hot pink.

I said "almost like clip border mode," because there's one thing clip border mode is doing (or at least should be doing, there used to be an Eevee bug related to this) is texture filtering properly between lookup color and clip color, and doing it this way will not do any kind of texture filtering at the border: you will have a hard-edged border, no matter how little screen space the texels occupy.

Also, because "clip" border mode doesn't actually care about the Z component, only the XY component. Sending a Z = 1.2 won't clip an image texture lookup, but it will clip the nodes I show above. If this is important, it's easily fixable-- just scale vector.Z by 0 with a mapping node.

$\endgroup$
1
  • $\begingroup$ Ah, I'm using the image textures in the Texture Panel of the Properties Window, not in nodes, as I'm using this on a modifier. "Clip Cube" is like "Clip" but already automatically takes Z into account. I wish I could use Texture/Material Nodes with modifiers, but it's unfortunately not implemented and probably won't be soon (except maybe Geometry Nodes). Thanks for your answer anyway. $\endgroup$
    – Will Chen
    Commented May 20, 2021 at 21:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .