Sorry if the question is a little confusing
There are some similar questions like How can I make an object only visible through certain material and Material that's only visible if seen through another material but they both involve surface materials and I can't seem to translate the answers to volumetric materials.
Suppose I have a volumetric cube, and an object inside it:
To start the volume is uniformly zero density, and I want the object to not be visible:
But as I increase the density, I want the areas where the dense parts of the volume and the object inside it intersect to be the only place where the object is visible:
So here the dense volume is red and the star shows up, but where the less dense volume is pink, the object should still not be visible.
I tried playing with the Light Path node but I can't find a light path that I can use to compare the density of the volume for this.