Repository navigation
Conversation
…RGB values With the linear pipeline on (the default), the fragment shader decodes vertex colors and texture samples from sRGB to linear light, but the output stage re-encodes to sRGB only for 3D geometry (coordinateFlag==1). Geometry added in COORDINATES_WINDOW_NORMALIZED (an image overlay through addRectangleByCenter() with a texture file, a colored 2D rectangle) was therefore decoded and never re-encoded, and drawn too dark: a uniform sRGB 128 texture came out as 55. The three decode sites now apply only to coordinateFlag==1, the same condition as the output stage, so 2D geometry passes through in display space. 3D geometry is unchanged. Adds a selfTest that draws a uniform sRGB 128 texture in window coordinates headless and checks the captured center pixel. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…t are not a multiple of 4 Visualizer::readOffscreenPixels() read the offscreen framebuffer as GL_RGB into a tightly packed buffer without setting GL_PACK_ALIGNMENT. At the default alignment of 4, glReadPixels pads each row to a multiple of 4 bytes, so for any width not divisible by 4 it wrote up to 3 bytes per row past the end of the buffer (corrupting the heap; a 381-pixel-wide capture aborted in malloc) and read every row skewed. The pack alignment is now set to 1 before the read, as the other readback paths already do. Adds a selfTest that captures a uniform background headless at a width of 381 as JPEG and checks it reads back uniform.
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.
Hello,
This PR fixes two Visualizer bugs. Each has a new selfTest;
visualizer_testspasses 196/196 on Linux (WSL2, aarch64, GCC 15.2, Release).1. Images added in window coordinates are drawn darker than the original
When I add an image to the Visualizer window as an overlay (
addRectangleByCenter(..., "image.jpg", Visualizer::COORDINATES_WINDOW_NORMALIZED)), it looks much darker than the image file. The inset at the top right is a rendered camera image:To check, I drew a uniform gray image (sRGB 128) the same way and read it back with
printWindow(): it comes out as 55, which is exactly 128 converted to linear light. A photo shows the same darkening (Helios' ownSkyDome_field.jpg; mean pixel value 119 in the file, 60 on master, 119 with this fix):Cause: with the linear pipeline on (the default),
primaryShader.fragconverts colors and textures from sRGB to linear, but converts back to sRGB only for 3D geometry (coordinateFlag==1). Window-coordinate geometry is converted to linear and never converted back.Fix: the sRGB-to-linear conversion now also applies only when
coordinateFlag==1, matching the output stage. 3D geometry is unchanged.The default background gradient (
textures/gradient_background.jpg) is drawn the same way, so it was also darker than its file. The fix brings it back to the file's colors (bottom row: file (100, 150, 199), master (32, 78, 146), with this fix (100, 150, 199)). In the comparison below, only the overlay and the background change; the 3D plants are identical:2. Headless
printWindow()crashes at a width that is not a multiple of 4readOffscreenPixels()reads the image asGL_RGBinto a tightly packed buffer without settingGL_PACK_ALIGNMENT, so for a width that is not a multiple of 4,glReadPixelswrites past the end of the buffer. On master, a headless 381 x 64 capture aborts withfree(): invalid next size (normal). The fix setsglPixelStorei(GL_PACK_ALIGNMENT, 1)before the read, as the other readback paths already do. The new test captures a uniform background at 381 x 64 and checks that every pixel reads back unchanged.