rikardolajos / clouds

12 stars 4 forks source link

Need help for performance improvement #3

Closed superamc2018 closed 3 years ago

superamc2018 commented 5 years ago

Hi Rikard,

I am making some changes into shaders to make clouds more realistic. I've made several changes in resolve_noise.frag shader. Now these clouds look extremely beautiful :-) But it is affecting performance seriously. The FPS drops to 7. Do you have any suggestions for how can I improve performance? Attached is the screenshot of output and modified shaders. Thank you very much..!! screenshot

resolve_noise.frag.txt sky.frag.txt

rikardolajos commented 5 years ago

Hi,

It does look really nice! I liked what you did with desaturating the blue channel explicitly. Gives it a very powerful twilight feeling.

Performance is always tricky. You might want to see if the HDR is really necessary. If you turn it of you should save some computational time. Otherwise I'm afraid you need to do a bigger investment. I think that currently the coarse stepping (i.e. the steps in the ray marcher which are outside the clouds) is taking more computational power than it needs to. If you had a analytical solver instead for finding the "cloud boxes", it would be better.

Peter Shirley has a ray-tracing series where he goes through the steps for finding different geometries in the scene: http://www.realtimerendering.com/raytracing/Ray%20Tracing%20in%20a%20Weekend.pdf http://www.realtimerendering.com/raytracing/Ray%20Tracing_%20The%20Next%20Week.pdf http://www.realtimerendering.com/raytracing/Ray%20Tracing_%20the%20Rest%20of%20Your%20Life.pdf

Sebastian Lague recently posted a video on YouTube where he does this. And the rest of the setup is really similar to my implementation. Definitely worth a watch: https://www.youtube.com/watch?v=4QOcCGI6xOU

superamc2018 commented 5 years ago

Thank you very much Rikard..!! The resources you have provided will be helpful for sure. I really appreciate that. Could you please clarify what is analytical solver for finding the "cloud boxes"?

rikardolajos commented 5 years ago

Yes, in my implementation I have a low resolution version of the cloudscape, allowing me to do the coarse stepping without worrying about missing any cloud puffs. It is explained on page 24 of my master's thesis: http://lup.lub.lu.se/luur/download?func=downloadFile&recordOId=8893256&fileOId=8893258

This means that all pixels on the screen get raymarched until the ray either hits the ground or the maximum draw distance. If we instead define some boxes where the clouds are situated we can easier and cheaper find if the current ray will ever intersect one of these boxes, and if not don't do any ray marching at all. This is basically what Sebastian Lague discusses around the 3:59 mark in his video: https://youtu.be/4QOcCGI6xOU?t=239

But as I said it will take a bit more effort and is basically a rewrite of how the clouds are placed in the scene.

superamc2018 commented 5 years ago

That's certainly a good idea. I will try to implement boxes in sky. Thank you Rikard!