clayjohn / godot-volumetric-cloud-demo

A demo implementing one way of drawing volumetric cloudscapes in Godot sky shaders
MIT License
306 stars 23 forks source link

A few optimisations #8

Open JohanAR opened 1 year ago

JohanAR commented 1 year ago

Skips sampling the fine detail noise texture for light, as recommended by Schneider, and adds an early exit when alpha is maxed out.

Reduces frame time by about 5-10% on my computer according to Godot's visual profiler.

clayjohn commented 1 year ago

Looks pretty good!

I wonder if we should do some energy compensation as you lose a lot of brightness by making this optimization. Since the fine detail is carved out of the base shape, the lighting samples are on-average, more dense than they ought to be. In my quick testing it makes clouds darker around the edges and the tops of the clouds are darker overall

JohanAR commented 1 year ago

Perhaps it's possible to compensate for it using a flat multiplier or something, but it requires a bit of testing.

I was actually surprised that it didn't give more performance increase, since such large part of the screen is covered by opaque clouds. An article about the Frostbite engine said that "this provided a great performance increase without noticeable visual artifacts". If I increase cloud coverage to really cover the entire sky frame time drops from 5ms to 3ms though.

Going to try your temporal upsampling branch as soon as I have time, hoping that feature will make it to Godot main in a not too distant future.