Applying gradient texture to deformed volume based on Z coordinate I'm trying to apply a fog to my grass plane, which is deformed in multiple ways (plane is subdivied + waved by hand + 2x modifier: displace.
The fog is supposed to be dense at the bottom and disappear with height, based on the gradient.
But the gradient is applied to the whole object, not the local Z coordinates of the volume.
Fog is generated with Volume Shatter.

I know the description is complicated, so, IMAGES!
What I have is rendered, what I want is with those arrows.


[1]What I 'want' presented with a surface shader:

[2]What I have:

[3]This is how it looks in volume shatter:


So:
I want the effect from [1] to apply to volume.
Please help. I'm Struggling with this for days...

I hope I didn't use wrong tags.
A guy from blender IRC support channel (#blender on freenode) found the answer, so, as follows!

There are TWO methods. First one is raytracing:

It's really slow, and OSL depending. And casuses crashes, apperently ;)

Second method, much faster (bueno!) uses height maps instead of gradient texture.




Also, @JA12 simplified it even more, look at the nodes:


You can study it with the attached .blend file.
It's amazingly simple.
.blend file my mirror: mirror