-
Notifications
You must be signed in to change notification settings - Fork 162
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AGS 4: reimplement custom Blend Modes using shaders #1885
Comments
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. |
After a brief discussion with @AlanDrake we are brought back to this idea, that maybe reimplementing blend modes as shaders will make things work better and/or implementing blend modes easier. The problem is, I do not have an accurate picture of how do you replace blending with a shader. The shader runs over a input texture and produces an output, which is then rendered to the destination. But if we want to substitute blending to dest with a shader, then we'd need to have a shader that has both sprite texture and render target on input, and then the result of this shader still goes onto the render target. Trying to imagine this logically, the result of a shader should be a "patch" for the render target that can be plain copied there without further alpha blending.
The shader outputs:
After this shader we use blend mode that plain copies values instead of mixing, that is: (GL_FUNC_ADD, GL_ONE, GL_ZERO). Does this make a sense? Or is it done differently? EDIT: I may make a test, but so far this idea seems questionable. |
I will close this, because this idea might have been a mistake. |
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.
The text was updated successfully, but these errors were encountered: