JiffyRob / Treds-Adventure-v2

Refactoring (and completion?) of a top-down game
https://jiffyrob.github.io/Treds-Adventure-v2/
MIT License
0 stars 0 forks source link

OpenGL shading? #3

Closed JiffyRob closed 1 year ago

JiffyRob commented 1 year ago

This is an issue to debate the necessary-ness of implementing OpenGL GPU shaders in the game. This would allow for fast processing of effects to the screen and other surfaces. Some examples of what we could do would be:

I'm kind of leaning toward yes, because bush was meant to be reusable, and not just specific to this game. If we decide not to use it now, we could still use it later.

At any rate, we should probably do this last, as most of the things listed above are either optimizations of current features or fancy eye-candy that leaves game play unchanged.

JiffyRob commented 1 year ago

This video is good if you want to know how to implement it: https://www.youtube.com/watch?v=LFbePt8i0DI

JiffyRob commented 1 year ago

As far as learning GLSL, the basics are not terrible. It is a wee bit impossible to debug though. I managed to make a colored lighting sphere with minimal pain. image

JiffyRob commented 1 year ago

It also broke pygame.image.get_surface() which previously was used for screenshots. Instead you have to take the OpenGL context and send a buffer from it to a pygame surface. Then you can save that.

JiffyRob commented 1 year ago

Maybe this ought to be implemented sooner rather than later. This would replace a lot of code - particle effects(?), camera scrolling, weather cycle, camera shake, fancy map transitions, etc.

JiffyRob commented 1 year ago

Just found a downside: We very likely would not be able to make a web build if we used ModernGL. There is another library called ZenGL which allegedly works better on the web, but I don't know for sure.

JiffyRob commented 1 year ago

I've been working on particles and am not overly impressed with the performance I am getting. I house my benchmark program at this repo. Currently it is private, so you may not see it, but once it is successfully web built, it will be made public. I currently get about 4300 cows on desktop, and less on web. ZenGL looks to support the web platform, so I may try to get that to work.

JiffyRob commented 1 year ago

As of now zengl shading will not be added to the game due to the inherent constraints of the library. We'll see if pygbag can do another library or zengl improves down the line.