I have a volume with a Volume Absorption node, and the density is based on the distance to the camera (the further away, the denser). But I would like to have a density per color channel so that the color is absorbed differently based on the distance, e.g. red channel density 1*z, blue 2*z, and green 3*z, with z being the distance to the camera.

How can this be done with Blender shader nodes?

  • $\begingroup$ Never tried changing the density with camera distance (because density is cumulative and appears more dense the further apart anyway), but since you already implemented that wouldn't you mind to share your setup with us? It would be easiest to see what you already have to give you tips on how to change it to get what you want, instead of letting us build it from scratch. At first glance it appears to me as if you have to create three absorption shaders, one for each color, and plug the differently calculated densities in there, then add those absorption shaders together...? $\endgroup$ Apr 12 at 6:05
  • $\begingroup$ You already accepted my answer, but I'm not sure if you really just wanted to know how to give the absorption a color...? So I added another setup at the bottom of the question where I use the distance to change the color. $\endgroup$ Apr 12 at 6:41

1 Answer 1


What you did not tell us is what the base color of the absorption should be for the R, G and B channels which you want to multiply with $z$ and different factors? I suspect you are starting off with R = G = B, so some greyscale value. Let's call this value $x$. The result you want is $(zx, 3zx, 2zx)$ or

$$z(x, 3x, 2x).$$

Now choose any arbitrary value for $x$ (preferably one that is within the 0 to 1 range when multiplied by 3), for example $\frac{1}{3}$. Place it in the term above instead of $x$ and you get


So you just give the Volume Absorption node a color of (0.333, 1, 0.667) and plug the distance $z$ in the Density like before. To change the density overall without changing the realtions of the colors to each, you can multiply or divide $z$ with some value.

That is the simple version - but that's basically just giving the Volume Absorption a fixed color. Although this is what you are asking for, I'm not sure if you thought of it to be intensifying the three colors differently from each other.

To do this and have a visible effect it would be better to start off with some different color and multiplying this with the $(x, 3x, 2x)$ greenish color using the distance as mix factor, like the example below: there I start off with some violet absorption and the green intensifies with distance from camera.

changing color with distance


You must log in to answer this question.

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