Repository navigation
Render with 10 bits per color channel if the target framebuffer has more than 8 - #1079
Open
Coastrnaut wants to merge 2 commits into
Open
Coastrnaut wants to merge 2 commits into
Coastrnaut wants to merge 2 commits into
Conversation
…ore than 8 projectM renders presets into internal RGBA8 images, so the frame only had 8 bits per channel even if the application's framebuffer has more. The number of red bits of the framebuffer the frame is drawn to is now queried in each frame. If it is more than 8, the main images of a preset, its flip texture and the blur textures are created as GL_RGB10_A2, which is color-renderable in OpenGL 3.3 and OpenGL ES 3.0 and, like the 8-bit format, clamps values to 0..1. With an 8-bit framebuffer, nothing changes.
This was referenced Nov 13, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements #1024 (and the question in #895) the way the issue suggests: the internal render targets follow the color depth of the framebuffer the application passes in.
projectM renders each preset into internal RGBA8 images and draws the result to the target framebuffer at the end, so the frame only has 8 bits per channel even if the target has more.
Change
ProjectM::RenderFrame()queries the red size of the target's first color buffer in every frame (GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE, onGL_BACK_LEFT/GL_BACKfor the default framebuffer) and passes it on in the render context.GL_RGB10_A2. That format is color-renderable in OpenGL 3.3 and OpenGL ES 3.0 and stores values clamped to 0..1, like the 8-bit format, so presets that rely on clamping behave the same. Milkdrop's main image has no alpha channel, so the 2 alpha bits aren't a problem.projectm_opengl_render_frame_fbo().TextureAttachment,FramebufferandCopyTextureget a function to change the format of an existing attachment; the format choice is in the newRenderer/ColorFormat.hpp.Open for discussion: I used 10 bits for every target above 8 bits, including float targets such as
GL_RGBA16F. A float format for the internal images would change how presets behave, because values would no longer be clamped.Results
A test app renders into a framebuffer object with an
GL_RGBA8,GL_RGB10_A2orGL_RGBA16Ftexture and reads the frame back with 16 bits per channel. The presets write a horizontal gradient from 0 to 0.1 in the composite shader, in the warp shader (so it passes through the main image and the flip texture) or showGetBlur1()of it. Distinct levels in the frame at 1280×720:Feedback effects get more precise as well, which changes how some presets look on a 10-bit target. A warp shader with
ret = tex2D(sampler_main, uv).xyz * 0.98 + 0.004should settle at 0.2: with 8 bits it stops at 0.098, with 10 bits at 0.175.Testing
Windows, RTX A6000.
It merges cleanly with my other open PRs and with #1056. It conflicts with #1047 in
BlurTexture.cppandProjectM.hpp, where both add code next to each other.