0
$\begingroup$

I would like to create an object with a custom gradient in opacity.

I start with a curve (or more generally, a function of all three coordinates) that contains opacity values for the object I want to display. So for e.g. a cube extending from 0 to 1 in all three dimensions, that function would spit out the opacity value I want for each point in the cube. That way, I can model a cube with exponentially falling opacity or even an opacity that falls and rises again when going away from the center.

Does anyone have an idea how to achieve this? Thank you!

$\endgroup$
  • 1
    $\begingroup$ Should be perfectly possible by expressing your function in shader nodes, or, if necessary, OSL.. could you give an example function for demonstration? $\endgroup$ – Robin Betts Feb 28 at 14:15
  • $\begingroup$ Something like this? blender.stackexchange.com/a/65382/1853 $\endgroup$ – cegaton Feb 28 at 16:02
  • $\begingroup$ @RobinBetts To test it, I would've gone for something nice and simple like exp(-x^2 - y^2 - z^2). In the end, I'll probably have some kind of data set that I describe with a more complicated polynomial fit. $\endgroup$ – nsnfn Mar 1 at 8:42
1
$\begingroup$

I expect you want more than this.. but it's a start ..

In principle, you can just make the color or density of a volume absorption shader a function of your chosen texture space. Here, Object Space is used. Its origin is at the object's origin, and is measured in Blender units along the object's local axes. So this default cube has 0 a its center and runs from -1 to 1 in all directions.

enter image description here

The function here is e^ -(x^2 + y^2 + z^2)..

enter image description here

Instead of mapping to a gradient, you could put in a threshold, map to Alpha instead.. all sorts, it depends exactly what you want..

$\endgroup$

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.