How to render realistic planets in love2d
How to render realistic planets in love2d
I stumbled across a Russian article on how to render realistic 2D planets (https://habrahabr.ru/post/248381/). I couldn't find an english version of the article and had to read the google translated version and it took some time to understand, so I thought I might implement it and share it with you all. I hope you will find this useful.
Github URL:
https://github.com/meric/renderplanet/
Please ask any questions you might have!
Last edited by appleide on Mon Feb 13, 2017 2:37 pm, edited 4 times in total.
- MicroMacro
- Citizen
- Posts: 92
- Joined: Fri May 30, 2014 2:30 am
- Location: Boston, MA, USA
- Contact:
Re: How to render realistic planets in love2d
This is awesome! Great work!
https://github.com/ebernerd- where you can find all my work.
Re: How to render realistic planets in love2d
absolutly great. I don't know the impact on the performance though. How hard, performance wise, would it be to render more than 10 of those?
Re: How to render realistic planets in love2d
It's a very simple shader so I imagine very little. It creates a matrix in runtime instead of using one through a uniform, so that can be optimized.
Re: How to render realistic planets in love2d
Thanks!
After these optimisations I think rendering 10 or 12 is fine, but before, there was no more room performance-wise for rendering other assets. Thanks to raidho36 for his suggestion.
I updated the attachments in the first post.
Your suggestion led me to cache the atmosphere in the canvas to greatly improve performance - it was capped at 30 fps for 12 planets with highdpi = false, now performance is more than doubled.
With the atmosphere caching optimisation, on a 2016 MacBook it can do 80-90 frames per second for 12 earths, highdpi=false, and 60-70 frames per second for 12 earths, highdpi=true, each earth with its own shader.
After these optimisations I think rendering 10 or 12 is fine, but before, there was no more room performance-wise for rendering other assets. Thanks to raidho36 for his suggestion.
I updated the attachments in the first post.
Re: How to render realistic planets in love2d
Wow! Nice stuff! Great work!
p.s. here is a similar solution with more precise colours, author use 16-bit adresses to code colour grades, not sure is it suitable for LOVE 2D, but provide more variety in colour grades (up to 512 in total number of grades, if i not mistake)
sorry, still from Habr and in Russian, but with lots of code
link
p.s. here is a similar solution with more precise colours, author use 16-bit adresses to code colour grades, not sure is it suitable for LOVE 2D, but provide more variety in colour grades (up to 512 in total number of grades, if i not mistake)
sorry, still from Habr and in Russian, but with lots of code
link
Re: How to render realistic planets in love2d
23 fps on 10 year old pc.
Earth still rotating the wrong direction.
Earth still rotating the wrong direction.
Re: How to render realistic planets in love2d
Also I think you can compute planet coordinates programmatically, that would reduce texture bandwidth. May be more expensive though. Texture maps to flattened sphere by sine and cosine, reverse would be arcsine and arccosine.
Re: How to render realistic planets in love2d
Yep! If you save them in a mesh it's probably faster for initial load and per render. I haven't benchmarked but I have created a 2d mesh with spherish uvs. https://gist.github.com/TannerRogalsky/ ... 01aa646d29
Who is online
Users browsing this forum: No registered users and 5 guests