Keep the proof cube off the graded image's texture unit.
The finish shader gained a sampler3D for ICC soft proofing, but that sampler was only assigned when proofing was on; unset it defaulted to unit 0, where the graded image is bound, and WebGL rejects a draw whose samplers mix types on one unit. Every frame then failed and photo after photo showed a black canvas with no console error. Assign the proof sampler on every draw and bind a 1x1x1 placeholder while proofing is off. 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
This commit is contained in:
+33
-1
@@ -1247,6 +1247,8 @@ export class Renderer {
|
|||||||
private srcW = 1;
|
private srcW = 1;
|
||||||
private srcH = 1;
|
private srcH = 1;
|
||||||
private proofTex: WebGLTexture | null = null;
|
private proofTex: WebGLTexture | null = null;
|
||||||
|
/** Bound to the proof sampler while soft proofing is off. */
|
||||||
|
private proofFallback: WebGLTexture | null = null;
|
||||||
private proofLutOn = 0;
|
private proofLutOn = 0;
|
||||||
/** Identity guard: the cube is uploaded once per profile, not per frame. */
|
/** Identity guard: the cube is uploaded once per profile, not per frame. */
|
||||||
private proofCube: SoftProofCube | null = null;
|
private proofCube: SoftProofCube | null = null;
|
||||||
@@ -1485,6 +1487,28 @@ export class Renderer {
|
|||||||
* approximation. Uploading happens here rather than per frame: the table is
|
* approximation. Uploading happens here rather than per frame: the table is
|
||||||
* built once from a printer profile.
|
* built once from a printer profile.
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
* The finish shader always declares a sampler3D, and an unassigned sampler
|
||||||
|
* reads as texture unit 0, where the graded image lives. WebGL rejects a
|
||||||
|
* draw whose samplers mix types on one unit, so the proof unit must always
|
||||||
|
* carry a 3D texture of its own, even when proofing is off.
|
||||||
|
*/
|
||||||
|
private proofFallbackTex(): WebGLTexture | null {
|
||||||
|
if (this.proofFallback) return this.proofFallback;
|
||||||
|
const gl = this.gl;
|
||||||
|
const tex = gl.createTexture();
|
||||||
|
if (!tex) return null;
|
||||||
|
gl.bindTexture(gl.TEXTURE_3D, tex);
|
||||||
|
gl.texParameteri(gl.TEXTURE_3D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
|
||||||
|
gl.texParameteri(gl.TEXTURE_3D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
|
||||||
|
gl.texParameteri(gl.TEXTURE_3D, gl.TEXTURE_WRAP_R, gl.CLAMP_TO_EDGE);
|
||||||
|
gl.texParameteri(gl.TEXTURE_3D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
|
||||||
|
gl.texParameteri(gl.TEXTURE_3D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
|
||||||
|
gl.texImage3D(gl.TEXTURE_3D, 0, gl.RGBA8, 1, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, new Uint8Array([0, 0, 0, 255]));
|
||||||
|
this.proofFallback = tex;
|
||||||
|
return tex;
|
||||||
|
}
|
||||||
|
|
||||||
setProofLut(lut: SoftProofCube | null) {
|
setProofLut(lut: SoftProofCube | null) {
|
||||||
if (lut === this.proofCube) return;
|
if (lut === this.proofCube) return;
|
||||||
this.proofCube = lut;
|
this.proofCube = lut;
|
||||||
@@ -1502,6 +1526,10 @@ export class Renderer {
|
|||||||
if (!tex) return;
|
if (!tex) return;
|
||||||
this.proofTex = tex;
|
this.proofTex = tex;
|
||||||
}
|
}
|
||||||
|
// The cube belongs to the proof unit only; binding it on whatever unit the
|
||||||
|
// last pass left active would put a 3D texture on the graded image's unit.
|
||||||
|
const activeUnit = gl.getParameter(gl.ACTIVE_TEXTURE) as number;
|
||||||
|
gl.activeTexture(gl.TEXTURE7);
|
||||||
gl.bindTexture(gl.TEXTURE_3D, this.proofTex);
|
gl.bindTexture(gl.TEXTURE_3D, this.proofTex);
|
||||||
gl.texParameteri(gl.TEXTURE_3D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
|
gl.texParameteri(gl.TEXTURE_3D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
|
||||||
gl.texParameteri(gl.TEXTURE_3D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
|
gl.texParameteri(gl.TEXTURE_3D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
|
||||||
@@ -1543,6 +1571,7 @@ export class Renderer {
|
|||||||
bytes,
|
bytes,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
gl.activeTexture(activeUnit);
|
||||||
this.proofLutOn = 1;
|
this.proofLutOn = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1997,7 +2026,10 @@ export class Renderer {
|
|||||||
this.finish.f('u_proofBlack', edits.proof.blackPoint);
|
this.finish.f('u_proofBlack', edits.proof.blackPoint);
|
||||||
this.finish.f('u_gamut', edits.proof.gamut ? 1 : 0);
|
this.finish.f('u_gamut', edits.proof.gamut ? 1 : 0);
|
||||||
this.finish.f('u_proofLutOn', this.proofLutOn);
|
this.finish.f('u_proofLutOn', this.proofLutOn);
|
||||||
if (this.proofTex && this.proofLutOn > 0.5) this.finish.tex3d('u_proofLut', this.proofTex, 7);
|
// Always assigned: an unset sampler3D defaults to unit 0 and collides
|
||||||
|
// with u_graded, which makes every draw fail and the view go black.
|
||||||
|
const proofTex = this.proofTex && this.proofLutOn > 0.5 ? this.proofTex : this.proofFallbackTex();
|
||||||
|
if (proofTex) this.finish.tex3d('u_proofLut', proofTex, 7);
|
||||||
this.finish.f('u_nr', edits.noise.luminance);
|
this.finish.f('u_nr', edits.noise.luminance);
|
||||||
this.finish.f('u_chroma', edits.noise.chroma);
|
this.finish.f('u_chroma', edits.noise.chroma);
|
||||||
this.finish.f('u_chromaDetail', edits.noise.chromaDetail);
|
this.finish.f('u_chromaDetail', edits.noise.chromaDetail);
|
||||||
|
|||||||
Reference in New Issue
Block a user