adventuregamestudio / ags

AGS editor and engine source code
Other
697 stars 159 forks source link

AGS 4: reimplement custom Blend Modes using shaders #1885

Open ivan-mogilko opened 1 year ago

ivan-mogilko commented 1 year ago

For Direct3D / OpenGL renderers the custom blend modes were implemented using standard alpha-blend operations, which seem to have two problems:

The latter is now a real problem, after #1874: as the textures used as render targets for the group of sprites must be blended using very particular blend ops.

The proposed solution is to reimplement these Blend Modes using shaders.

My understanding is that in OpenGL shaders must include transparency, because it's currently done through a shader, although I cannot remember why that was made so (afaik this was a part of switching to a more contemporary OpenGL style). Existing shaders may be used as example.

Besides that, we need to decide whether Tint and LightLevel effects should apply along with the BlendMode or not. This decision will affect the complexity of this task.

ericoporto commented 1 year ago

My understanding is that in OpenGL shaders must include transparency, because it's currently done through a shader, although I cannot remember why that was made so

I am not 100% sure, but it may be when the OpenGL ES2 version of the renderer was written, because OpenGL ES2 has a lot less things in its API.

Edit: we could move to OpenGL ES3, It may have a bit more things and is available in most devices - Apple added support to WebGL 2.0 in Safari in 2021 which mean it could be used in the Emscripten emulation nowadays.