ultraq / redhorizon

Recreating the original 2D Command & Conquer games
Apache License 2.0
6 stars 4 forks source link

Move more graphics operations to the GPU and shaders #48

Closed ultraq closed 3 years ago

ultraq commented 3 years ago

I've got a lot of image processing methods which I think can be moved to shaders in the GPU, instead of the Groovy code run on the CPU. These include:

Trying out the first item, something I noticed was that you can't reliably use GL_LINEAR on paletted images because then it'd interpolate the palette indices which doesn't guarantee an in-between colour. So being able to create a filter in the fragment shader as well will be good, and then I can enable it on a per-material basis instead of globally via the current CLI flag (--filter).

Some prior art/resources:

ultraq commented 3 years ago

One thing I'm finding out with the scanline shaders out there: they only work if all pixels are the same height (I mean, why not? 😅), but I have the situation here where I'm adjusting texture heights for the difference in aspect ratios, so some scanlines are coming through thicker than others. And since it's not a texture, it's not getting the same hardware filtering so those thick lines aren't lightened to try reduce their apparent thickness 🤔