2
$\begingroup$

I am trying to create a shader in Blender that uses a mask of a specific shape to displace and warp another texture around it, effectively creating a distortion effect where the masked shape pushes the surrounding texture aside. The goal is to make the texture appear as if it’s being distorted or stretched around the masked area, sort of like how a blackhole distorts space around it. What would be the best approach to achieve this using Blender shader nodes?

Here is my attempt at the problem: Node setup

This is close to what I want. However, the streamlines currently go through the shape. I want the streamlines to distort around the shape such that each line remains continuous/uncut. The shape should create a perfect void for itself while minimally distorting the surrounding texture.

$\endgroup$

2 Answers 2

2
$\begingroup$

Starting with a simple wave texture and preparing ground for maths with separate/combine:

Imgur mirror (SE image hosting has problems)

Now you want to stretch the texture. The simplest way to stretch a normalized value (0..1 range) is to raise it to a power, as the output stays normalized. Just remember it won't work for negative values so you need to remove and restore the sign:

Imgur mirror

And now base this effect on the x coordinate:

Imgur mirror

You can move the hole by moving the origin, but notice how there was an assumption that y coordinate is normalized and so bigger values than 1 fail:

Imgur mirror

You can use simple math shenanigans to e.g. clamp the effect to normalized range, and restore the cut off offset:

Imgur mirror

And you can further work on that, for example you might not want the falloff to depend only on x, then you can use "Vector Math: Length" instead:

Imgur mirror

And maybe you don't want to modify only y component of the coordinate:

Imgur mirror

$\endgroup$
1
$\begingroup$

This is not perfect math, but you could add a power to the sphere warping factor:

enter image description here

$\endgroup$

You must log in to answer this question.

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