Replies: 2 comments 1 reply
|
The texture isn't actually black, it's just never bound to Here's the mechanism in
So in your loop: SetShaderValueTexture(blackhole_shader, iChannel0Loc, combinedRT.texture); // registers texture unit 1
BeginTextureMode(target); // flush #1 -> clears the registration you just made
ClearBackground(BLACK);
BeginShaderMode(blackhole_shader); // flush #2 -> still clear
DrawTextureRec(combinedRT.texture, ...); // this draw eventually flushes with activeTextureId all zero, so unit 1 never gets bound
EndShaderMode();
EndTextureMode();By the time the batch containing your Fix: call BeginTextureMode(target);
ClearBackground(BLACK);
BeginShaderMode(blackhole_shader);
SetShaderValueTexture(blackhole_shader, iChannel0Loc, combinedRT.texture); // moved here
DrawTextureRec(combinedRT.texture,
(Rectangle){ 0, 0, (float)combinedRT.texture.width, (float)-combinedRT.texture.height },
(Vector2){ 0, 0 }, WHITE);
EndShaderMode();
EndTextureMode();This needs to be done every frame (which you're already doing), just after |



The texture isn't actually black, it's just never bound to
iChannel0for that draw call. The problem is call order: you callSetShaderValueTexturebeforeBeginTextureMode/BeginShaderMode, and both of those flush the internal render batch, which wipes out the texture-unit registration you just made.Here's the mechanism in
rlgl.h:SetShaderValueTexture→rlSetUniformSampleronly setsglUniform1i(locIndex, 1+i)and stashes the texture id inRLGL.State.activeTextureId[i]. It does not bind the texture yet:raylib/src/rlgl.h
Lines 4564 to 4589 in 6ecf21f