Ladies, gentlemen and people who prefer to go by anything else, I present to you, what is quite possibly my finest work of shader code yet! I, thejinxedartist, also known as Folly, have added shadows to the fog!
OK, OK, enough with the fancy talk. But yes, I have spent quite a while re-writing the fog shader from scratch in its own shader, rather than as a custom function in shadergraph. I was planning to anyway as auto-generated code from node-based editors is generally not the fastest, but I also had no way to access lighting information where I needed it in order to add shadows. If anyone was wondering, in the raymarching loop, before I accumulate the fog density, I check if the point in space is in shadow using mainLight.shadowAttenuation.
Anyway, now that this whole thing is over, I can get back to- oh wait! The ambient sky light isn't working properly you say? Well, I can't just leave it unfinished, can I! Just leave me a few weeks and I'll have it done! (This is a joke, It'll only take 6 days ;)
[UPDATE]
So I forgot that I was rendering this at 512 samples for the screenshots and I was wondering why my my fps had dropped from ~250 to ~150 and so I spent a while adding every optimisation I could, and then I realized "Oh wait, why am I rendering this with 512 samples" so now its back to 64 samples and is running even faster.
We took the lab and rounded up the scientists, just like we were ordered. But they won’t tell us what’s in the torus. All we know is that it’s highly radioactive...
I was asked for some help making a Cherenkov radiation effect in Blender. This is what I came up with! I think the results are decent. With more time and effort spent on modelling and materials, you could definitely make a cool nuclear reactor scene like this. Details below...
The key to this is the reactor itself is not glowing. The glow comes from the volume around it, and it’s brightest near the surface of the reactor.
Physically, the reactor is producing charged particles which are faster than the speed of light in water, creating a kind of ‘sonic boom’ effect with light. These particles rapidly lose energy as they spread out into the water, so the glow is strongest by the reactor. It’s a very cool and eerie effect that occurs in nuclear reactors.
Basically, the way it works is that I calculate the signed distance field of a torus, feed it into 1/x for a nice falloff (probably not physically accurate), and use that as the emission value in a principled volume shader. On top of that you can add a principled surface shader and displacement to get something watery.
This method does have the limitation that you need to be able to compute the distance field for whatever shape you want, which means you can’t just feed it a mesh. However, it doesn’t need to be all that precise, so with a few parameterised ‘building block’ fields made out of node groups, you could make this pretty flexible I think.
Oh the joys of programming an actual volumetric fog implementation while having absolutely no clue about what you're doing... At least it looks pretty!
This is just a small post because it still needs a bit of work, but it'll be done very soon!
Um... at least there's no banding..?
Finally, raymarched volumetric fog, as far as the eye can see, and with almost no loss in framerate. Seeing as I've only just started doing volumetric stuff, this seems pretty good!