@@ -86,7 +86,16 @@ bool VROAVRecorderAndroid::onRenderedFrameTexture(std::shared_ptr<VRORenderTarge
8686 _recorderDisplay->setViewport ({0 , 0 , input->getWidth (), input->getHeight ()});
8787
8888 driver->bindRenderTarget (_recorderDisplay, VRORenderTargetUnbindOp::Invalidate);
89- _recordingPostProcess->blit ({ input->getTexture (0 ) }, driver);
89+
90+ // In linear color mode (HDR enabled) the scene framebuffer holds linear RGB values;
91+ // gamma-encode them before the encoder reads the surface, otherwise recorded video
92+ // is noticeably darker than the live view. In non-linear mode the framebuffer is
93+ // already sRGB-encoded and can be blit straight through.
94+ if (driver->getColorRenderingMode () == VROColorRenderingMode::Linear) {
95+ getGammaPostProcess (driver)->blit ({ input->getTexture (0 ) }, driver);
96+ } else {
97+ _recordingPostProcess->blit ({ input->getTexture (0 ) }, driver);
98+ }
9099 }
91100
92101 if (_scheduledScreenShot) {
@@ -156,11 +165,16 @@ std::shared_ptr<VRORenderTarget> VROAVRecorderAndroid::bindScreenshotLDRTarget(i
156165
157166std::shared_ptr<VROImagePostProcess> VROAVRecorderAndroid::getGammaPostProcess (std::shared_ptr<VRODriver> driver) {
158167 if (!_gammaPostProcess) {
159- std::vector<std::string> samplers = { " hdr_texture" , " tone_mapping_mask" };
168+ // The sampler name in `samplers` must match the uniform name in the shader
169+ // code below — VROImagePostProcess uses `samplers` to locate and bind the
170+ // input texture(s) to the corresponding shader uniform(s). A name mismatch
171+ // leaves the sampler unbound and the shader reads from texture unit 0 with
172+ // no texture attached, producing a black frame.
173+ std::vector<std::string> samplers = { " hdr_texture" };
160174 std::vector<std::string> code = {
161175 " const highp float gamma = 2.2;" ,
162- " uniform sampler2D srgb_texture ;" ,
163- " highp vec4 srgb_color = texture(srgb_texture , v_texcoord);" ,
176+ " uniform sampler2D hdr_texture ;" ,
177+ " highp vec4 srgb_color = texture(hdr_texture , v_texcoord);" ,
164178 " highp vec3 gamma_color = pow(srgb_color.xyz, vec3(1.0 / gamma));" ,
165179 " frag_color = vec4(gamma_color, srgb_color.a);" ,
166180 };
0 commit comments