I need to do a fog that's dense at the bottom and gradually disappears to the top of the box. I adjusted a gradient texture with mapping, but is there a more straighforward way?
Asked
Active
Viewed 1,275 times
2
-
for me that is straight forward ;) i would have done it the same way – Chris Jul 09 '21 at 07:46
-
you can also use the Converter > Separate XYZ and its Z output socket – moonboots Jul 09 '21 at 07:53
-
Does the Z output go from 0 to 1 relative to the bottom and top of the mesh? – francois gibon Jul 09 '21 at 08:01
-
@francoisgibon it does in generated texture coordinate. – Markus von Broady Jul 09 '21 at 08:42
1 Answers
4
As moonbots pointed out, you can use Z coordinate to get a gradient. You can also raise it to some power for nonlinear falloff (normalized 0..1 range raised to some power is still normalized, which is pleasant), then multiply to change the maximum value:
Markus von Broady
- 36,563
- 3
- 30
- 99
-
1This question has made me curious. I wonder whether there's a way of combining some kind of World Z pass with a Mist pass to approximate this in compositing, without using volumetrics? Somebody must have done this. – Robin Betts Jul 09 '21 at 09:06
-
2@RobinBetts You can do a worldpos AOC, but there are a number of reasons why a mist pass is not going to give the same results as renderered fog (volumetric lighting, variable density, scattering, many more.) You can get the integral of a very simple height-based mist pass function, which is even better than volumetric sampling, at least for raw, rasterizer absorption, but it's easy to get mist functions that can only be sampled iteratively; it's possible to sample in composting, but tedious and slow and not what compositing is good at. – Nathan Jul 09 '21 at 12:54
-
Thank you @Nathan! I think that nails it. My comment should have been a question :) – Robin Betts Jul 09 '21 at 12:58
-
How do you change where the volume begins? By default, this starts at the top, I want it to start from the bottom up. – no_name Dec 17 '22 at 17:28
-
@no_name you can use Map Range node to map from 0..1 to 1..0 for example. Or use a color ramp, or just do Math: subtract: $1-x$. – Markus von Broady Dec 18 '22 at 09:54
-
I've tried using the math node and the color ramp and neither one changes where the volume starts – no_name Dec 18 '22 at 16:19

