feat: add curve inputs and raise uniform limit for GLSL shader node#13158
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdds two GLSL ES 3.00 fragment shaders: 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@comfy_extras/nodes_glsl.py`:
- Around line 881-885: The loop that builds curve_luts currently filters out
None entries causing sparse inputs to shift slots; in the block that iterates
over curves.values() (building curve_luts) preserve explicit slots by appending
a placeholder for None rather than skipping them — e.g., append None (or an
appropriately sized neutral LUT) when v is None so the indices of curve_luts
align with the original u_curve0/u_curve1/... slots; ensure the later GLSL
upload logic handles these None placeholders accordingly.
- Line 851: The tooltip for the curve input (io.Autogrow.Input with
template=curve_template) is misleading: update it to state that curves are 256×1
LUTs and recommend using texelFetch with manual linear interpolation as in the
built-in Color_Curves_8.frag (e.g., "Curves are available as
u_curve0-{MAX_CURVES-1} (sampler2D, 256×1 LUT). For accurate sampling, use
texelFetch with manual linear interpolation, as shown in the built-in
Color_Curves_8 shader."). In execute() (the curve binding/filtering loop) stop
silently compacting sparse curve lists: preserve original indices by either
padding missing entries with an identity LUT or binding textures explicitly to
their slot index (u_curveN) instead of using the filtered list position so that
curves[2] continues to map to u_curve2 even when curves[1] is None.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: ed94803f-6785-49e3-9e52-9b45a89df3a0
📒 Files selected for processing (5)
blueprints/.glsl/Color_Balance_15.fragblueprints/.glsl/Color_Curves_8.fragblueprints/Color Balance.jsonblueprints/Color Curves.jsoncomfy_extras/nodes_glsl.py
74c021f to
c5c284e
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (2)
comfy_extras/nodes_glsl.py (1)
90-92: Extract the curve LUT width into a shared constant.
256is now part of the public contract in both the tooltip andto_lut(...). Naming it once will make future changes less error-prone.♻️ Proposed cleanup
MAX_UNIFORMS = 20 # u_float0-19, u_int0-19 MAX_BOOLS = 10 # u_bool0-9 MAX_CURVES = 4 # u_curve0-3 (1D LUT textures) +CURVE_LUT_WIDTH = 256 ... - io.Autogrow.Input("curves", template=curve_template, tooltip=f"Curves are available as u_curve0-{MAX_CURVES-1} (sampler2D, 256x1 LUT) in the shader code. Sample with texture(u_curve0, vec2(x, 0.5)).r"), + io.Autogrow.Input("curves", template=curve_template, tooltip=f"Curves are available as u_curve0-{MAX_CURVES-1} (sampler2D, {CURVE_LUT_WIDTH}x1 LUT) in the shader code. Sample with texture(u_curve0, vec2(x, 0.5)).r"), ... - curve_luts = [v.to_lut(256).astype(np.float32) for v in curves.values() if v is not None] if curves else [] + curve_luts = [v.to_lut(CURVE_LUT_WIDTH).astype(np.float32) for v in curves.values() if v is not None] if curves else []Also applies to: 850-851, 881-881
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@comfy_extras/nodes_glsl.py` around lines 90 - 92, Introduce a shared constant (e.g., CURVE_LUT_WIDTH = 256) in comfy_extras/nodes_glsl.py and replace hard-coded 256 occurrences in the curve tooltip text and any usages inside the to_lut(...) implementation (and related spots around MAX_CURVES) with that constant; update references where the LUT width is mentioned (tooltip strings and function logic) to use CURVE_LUT_WIDTH so the value is centralized and future changes are safe.blueprints/.glsl/Color_Balance_15.frag (1)
17-17: Use the documentedfragColor0output pattern in the blueprint shader.
GLSLShaderadvertiseslayout(location = 0) out vec4 fragColor0; using the same form here makes this built-in shader a cleaner copy/paste example and keeps it aligned with the node’s output conventions.♻️ Proposed cleanup
-out vec4 fragColor; +layout(location = 0) out vec4 fragColor0; ... - fragColor = vec4(clamp(color, 0.0, 1.0), tex.a); + fragColor0 = vec4(clamp(color, 0.0, 1.0), tex.a);Also applies to: 89-89
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@blueprints/.glsl/Color_Balance_15.frag` at line 17, The shader uses the generic output symbol "out vec4 fragColor" but the project convention and GLSLShader docs use "layout(location = 0) out vec4 fragColor0"; update the fragment outputs (e.g., the declaration at "out vec4 fragColor" and the other occurrence) to "layout(location = 0) out vec4 fragColor0" so the built-in shader matches the node output convention and is copy/paste friendly with GLSLShader.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@blueprints/.glsl/Color_Balance_15.frag`:
- Line 17: The shader uses the generic output symbol "out vec4 fragColor" but
the project convention and GLSLShader docs use "layout(location = 0) out vec4
fragColor0"; update the fragment outputs (e.g., the declaration at "out vec4
fragColor" and the other occurrence) to "layout(location = 0) out vec4
fragColor0" so the built-in shader matches the node output convention and is
copy/paste friendly with GLSLShader.
In `@comfy_extras/nodes_glsl.py`:
- Around line 90-92: Introduce a shared constant (e.g., CURVE_LUT_WIDTH = 256)
in comfy_extras/nodes_glsl.py and replace hard-coded 256 occurrences in the
curve tooltip text and any usages inside the to_lut(...) implementation (and
related spots around MAX_CURVES) with that constant; update references where the
LUT width is mentioned (tooltip strings and function logic) to use
CURVE_LUT_WIDTH so the value is centralized and future changes are safe.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 55feba84-29ec-492c-9cbe-d57ffa0259f2
📒 Files selected for processing (5)
blueprints/.glsl/Color_Balance_15.fragblueprints/.glsl/Color_Curves_8.fragblueprints/Color Balance.jsonblueprints/Color Curves.jsoncomfy_extras/nodes_glsl.py
✅ Files skipped from review due to trivial changes (2)
- blueprints/Color Curves.json
- blueprints/Color Balance.json
🚧 Files skipped from review as they are similar to previous changes (1)
- blueprints/.glsl/Color_Curves_8.frag
Uh oh!
There was an error while loading. Please reload this page.