Skip to content

Color balance: one-sample LDR adjustment ​

A basic effect you can independently download, toggle, validate and modify using pinned public contracts.

Algorithm and visible result ​

Increase contrast by 12% around 0.5, multiply by (1.05,1.0,0.94), mix with the original using strength and clamp to [0,1]. This is an explicit artistic convention, not automatic sRGB decoding or HDR exposure. Confirm the scene color encoding before reuse; another gamma operation outside this chain can double-convert it.

Resource flow and switch ​

scene/color → [grade on: effect → post/color] → one present → screen

The three packs are independent. Each uses four BuiltIn Terrain routes and copies no host shader. practice:grade selects the full effect closure; practice:strength is a Program define and recompiles. Prerequisite: independent pack course.

Source and freshly extracted ZIP agree for every row. Counts include only active nodes; resources include the material buffer where present.

VariantOverridesResourcesCommands
default{}36
grade-off{"practice:grade":false}25
strength-max{"practice:strength":1}36
Exact active closure

default

resource:practice:post/color, resource:practice:scene/color, resource:practice:scene/depth

command:practice:grade:0, command:practice:present-grade:0, command:practice:terrain_alpha_tested:0, command:practice:terrain_opaque:0, command:practice:terrain_sorted_translucent:0, command:practice:terrain_transparent:0

program:dawnlight:scene_fallback/terrain_alpha_tested, program:dawnlight:scene_fallback/terrain_opaque, program:dawnlight:scene_fallback/terrain_sorted_translucent, program:dawnlight:scene_fallback/terrain_transparent, program:practice:post/grade, program:practice:post/present

Active services: 0

grade-off

resource:practice:scene/color, resource:practice:scene/depth

command:practice:present-raw:0, command:practice:terrain_alpha_tested:0, command:practice:terrain_opaque:0, command:practice:terrain_sorted_translucent:0, command:practice:terrain_transparent:0

program:dawnlight:scene_fallback/terrain_alpha_tested, program:dawnlight:scene_fallback/terrain_opaque, program:dawnlight:scene_fallback/terrain_sorted_translucent, program:dawnlight:scene_fallback/terrain_transparent, program:practice:post/present

Active services: 0

strength-max

resource:practice:post/color, resource:practice:scene/color, resource:practice:scene/depth

command:practice:grade:0, command:practice:present-grade:0, command:practice:terrain_alpha_tested:0, command:practice:terrain_opaque:0, command:practice:terrain_sorted_translucent:0, command:practice:terrain_transparent:0

program:dawnlight:scene_fallback/terrain_alpha_tested, program:dawnlight:scene_fallback/terrain_opaque, program:dawnlight:scene_fallback/terrain_sorted_translucent, program:dawnlight:scene_fallback/terrain_transparent, program:practice:post/grade, program:practice:post/present

Active services: 0

Nominal cost and disabled behavior ​

The effect reads scene color once per pixel, followed by one present sample. The separate RGBA8 intermediate has nominal capacity 4WH bytes. Disabling grade removes that texture, Program and command from the active closure. Scene color/depth and four BuiltIn routes remain.

WH is render pixel count. At 1920×1080, 4WH is about 7.91 MiB, excluding base color/depth, alignment and driver overhead. These are logical capacity/sample estimates, not measured VRAM or milliseconds.

Complete download and source ​

Complete ZIP, inventory and receipt. Extract into shaderpacks/w7-color-balance/ and run /switchshader w7-color-balance in a creative world. Apply settings at U → Options → Effect practice. All source is included below; no other example directory is required.

shaderpack.json
json
{
  "manifestVersion": 5,
  "sceneAbiVersion": 2,
  "expectedCatalogSha256": "4bc28c17beffea2311a422fff9f633d2e4f03784460d0254adda8af2e766d84c",
  "id": "practice:color-balance",
  "name": "Practice color-balance",
  "version": "1.0.0",
  "author": "EltanceX",
  "description": "Independent LDR color-balance example. Static and runtime evidence are recorded separately.",
  "shaderRoot": "shaders",
  "options": [
    {
      "id": "practice:grade",
      "type": "boolean",
      "default": true,
      "impact": [
        "pipeline",
        "resources"
      ]
    },
    {
      "id": "practice:strength",
      "type": "number",
      "default": 0.65,
      "min": 0,
      "max": 1,
      "impact": [
        "program"
      ]
    }
  ],
  "resources": [
    {
      "id": "practice:scene/color",
      "kind": "texture2D",
      "lifetime": "persistent",
      "size": {
        "mode": "viewport"
      },
      "format": "rgba8"
    },
    {
      "id": "practice:scene/depth",
      "kind": "texture2D",
      "lifetime": "persistent",
      "size": {
        "mode": "viewport"
      },
      "format": "depth24"
    },
    {
      "id": "practice:post/color",
      "kind": "texture2D",
      "lifetime": "persistent",
      "size": {
        "mode": "viewport"
      },
      "format": "rgba8"
    }
  ],
  "programs": [
    {
      "id": "practice:post/grade",
      "kind": "graphics",
      "vertex": "fullscreen.vsh",
      "fragment": "grade.psh",
      "compileMode": "manifestDriven",
      "defines": {
        "GRADE_STRENGTH": {
          "option": "practice:strength"
        }
      }
    },
    {
      "id": "practice:post/present",
      "kind": "graphics",
      "vertex": "fullscreen.vsh",
      "fragment": "present.psh",
      "compileMode": "manifestDriven"
    }
  ],
  "frameTarget": {
    "targets": {
      "colors": [
        {
          "location": 0,
          "resource": "practice:scene/color",
          "loadOp": "clear",
          "storeOp": "store",
          "clearValue": [
            0,
            0,
            0,
            1
          ]
        }
      ],
      "depth": {
        "resource": "practice:scene/depth",
        "loadOp": "clear",
        "storeOp": "store",
        "clearValue": 1
      }
    }
  },
  "passes": [
    {
      "id": "practice:terrain_opaque",
      "enabled": true,
      "stage": {
        "template": "dawnlight:command_list",
        "version": 1,
        "target": "world",
        "phase": "opaque"
      },
      "services": [],
      "programs": [],
      "commands": [
        {
          "type": "engineDraw",
          "sceneProvider": {
            "id": "dawnlight:scene_draw/terrain_opaque",
            "version": 2
          },
          "targets": {
            "colors": [
              {
                "location": 0,
                "resource": "practice:scene/color",
                "loadOp": "load",
                "storeOp": "store"
              }
            ],
            "depth": {
              "resource": "practice:scene/depth",
              "loadOp": "clear",
              "storeOp": "store",
              "clearValue": 1
            }
          },
          "state": {
            "blend": "opaque",
            "depth": "default",
            "rasterizer": "cullCounterClockwiseScissor"
          },
          "viewport": {
            "source": "target",
            "restore": "frame",
            "synchronizeScissor": true
          }
        }
      ],
      "inputs": [
        "practice:scene/color",
        "practice:scene/depth"
      ],
      "outputs": [
        "practice:scene/color",
        "practice:scene/depth"
      ]
    },
    {
      "id": "practice:terrain_alpha_tested",
      "enabled": true,
      "stage": {
        "template": "dawnlight:command_list",
        "version": 1,
        "target": "world",
        "phase": "opaque",
        "ordering": {
          "after": [
            "practice:terrain_opaque"
          ]
        }
      },
      "services": [],
      "programs": [],
      "commands": [
        {
          "type": "engineDraw",
          "sceneProvider": {
            "id": "dawnlight:scene_draw/terrain_alpha_tested",
            "version": 2
          },
          "targets": {
            "colors": [
              {
                "location": 0,
                "resource": "practice:scene/color",
                "loadOp": "load",
                "storeOp": "store"
              }
            ],
            "depth": {
              "resource": "practice:scene/depth",
              "loadOp": "load",
              "storeOp": "store"
            }
          },
          "state": {
            "blend": "opaque",
            "depth": "default",
            "rasterizer": "cullCounterClockwiseScissor"
          },
          "viewport": {
            "source": "target",
            "restore": "frame",
            "synchronizeScissor": true
          }
        }
      ],
      "inputs": [
        "practice:scene/color",
        "practice:scene/depth"
      ],
      "outputs": [
        "practice:scene/color",
        "practice:scene/depth"
      ]
    },
    {
      "id": "practice:terrain_transparent",
      "enabled": true,
      "stage": {
        "template": "dawnlight:command_list",
        "version": 1,
        "target": "world",
        "phase": "transparent"
      },
      "services": [],
      "programs": [],
      "commands": [
        {
          "type": "engineDraw",
          "sceneProvider": {
            "id": "dawnlight:scene_draw/terrain_transparent",
            "version": 2
          },
          "targets": {
            "colors": [
              {
                "location": 0,
                "resource": "practice:scene/color",
                "loadOp": "load",
                "storeOp": "store"
              }
            ],
            "depth": {
              "resource": "practice:scene/depth",
              "loadOp": "load",
              "storeOp": "store"
            }
          },
          "state": {
            "blend": "alphaBlend",
            "depth": "default",
            "rasterizer": "cullCounterClockwiseScissor"
          },
          "viewport": {
            "source": "target",
            "restore": "frame",
            "synchronizeScissor": true
          }
        }
      ],
      "inputs": [
        "practice:scene/color",
        "practice:scene/depth"
      ],
      "outputs": [
        "practice:scene/color",
        "practice:scene/depth"
      ]
    },
    {
      "id": "practice:terrain_sorted_translucent",
      "enabled": true,
      "stage": {
        "template": "dawnlight:command_list",
        "version": 1,
        "target": "world",
        "phase": "transparent",
        "ordering": {
          "after": [
            "practice:terrain_transparent"
          ]
        }
      },
      "services": [],
      "programs": [],
      "commands": [
        {
          "type": "engineDraw",
          "sceneProvider": {
            "id": "dawnlight:scene_draw/terrain_sorted_translucent",
            "version": 2
          },
          "targets": {
            "colors": [
              {
                "location": 0,
                "resource": "practice:scene/color",
                "loadOp": "load",
                "storeOp": "store"
              }
            ],
            "depth": {
              "resource": "practice:scene/depth",
              "loadOp": "load",
              "storeOp": "store"
            }
          },
          "state": {
            "blend": "alphaBlend",
            "depth": "default",
            "rasterizer": "cullCounterClockwiseScissor"
          },
          "viewport": {
            "source": "target",
            "restore": "frame",
            "synchronizeScissor": true
          }
        }
      ],
      "inputs": [
        "practice:scene/color",
        "practice:scene/depth"
      ],
      "outputs": [
        "practice:scene/color",
        "practice:scene/depth"
      ]
    },
    {
      "id": "practice:grade",
      "enabled": true,
      "stage": {
        "template": "dawnlight:command_list",
        "version": 1,
        "target": "afterDraw",
        "phase": "afterDraw"
      },
      "services": [],
      "programs": [
        "practice:post/grade"
      ],
      "commands": [
        {
          "type": "fullscreen",
          "program": "practice:post/grade",
          "bindings": [
            {
              "kind": "sampler2D",
              "symbol": "u_sceneColor",
              "binding": 0,
              "resource": "practice:scene/color"
            }
          ],
          "state": {
            "blend": "opaque",
            "depth": "disabled",
            "rasterizer": "cullNoneScissor"
          },
          "viewport": {
            "source": "target",
            "restore": "frame",
            "synchronizeScissor": true
          },
          "targets": {
            "colors": [
              {
                "location": 0,
                "resource": "practice:post/color",
                "loadOp": "dontCare",
                "storeOp": "store"
              }
            ]
          }
        }
      ],
      "inputs": [
        "practice:scene/color"
      ],
      "outputs": [
        "practice:post/color"
      ],
      "enabledWhen": [
        {
          "option": "practice:grade",
          "equals": true
        }
      ]
    },
    {
      "id": "practice:present-grade",
      "enabled": true,
      "stage": {
        "template": "dawnlight:command_list",
        "version": 1,
        "target": "afterDraw",
        "phase": "screenOutput",
        "ordering": {
          "after": [
            "practice:grade"
          ]
        }
      },
      "services": [],
      "programs": [
        "practice:post/present"
      ],
      "commands": [
        {
          "type": "present",
          "program": "practice:post/present",
          "bindings": [
            {
              "kind": "sampler2D",
              "symbol": "u_postColor",
              "binding": 0,
              "resource": "practice:post/color"
            }
          ],
          "state": {
            "blend": "opaque",
            "depth": "disabled",
            "rasterizer": "cullNoneScissor"
          },
          "viewport": {
            "source": "frame",
            "restore": "none",
            "synchronizeScissor": true
          }
        }
      ],
      "inputs": [
        "practice:post/color"
      ],
      "outputs": [],
      "enabledWhen": [
        {
          "option": "practice:grade",
          "equals": true
        }
      ]
    },
    {
      "id": "practice:present-raw",
      "enabled": true,
      "stage": {
        "template": "dawnlight:command_list",
        "version": 1,
        "target": "afterDraw",
        "phase": "screenOutput"
      },
      "services": [],
      "programs": [
        "practice:post/present"
      ],
      "commands": [
        {
          "type": "present",
          "program": "practice:post/present",
          "bindings": [
            {
              "kind": "sampler2D",
              "symbol": "u_postColor",
              "binding": 0,
              "resource": "practice:scene/color"
            }
          ],
          "state": {
            "blend": "opaque",
            "depth": "disabled",
            "rasterizer": "cullNoneScissor"
          },
          "viewport": {
            "source": "frame",
            "restore": "none",
            "synchronizeScissor": true
          }
        }
      ],
      "inputs": [
        "practice:scene/color"
      ],
      "outputs": [],
      "enabledWhen": [
        {
          "option": "practice:grade",
          "equals": false
        }
      ]
    }
  ],
  "sceneCategories": [
    {
      "id": "dawnlight:scene/terrain_opaque",
      "version": 1,
      "mode": "builtin"
    },
    {
      "id": "dawnlight:scene/terrain_alpha_tested",
      "version": 1,
      "mode": "builtin"
    },
    {
      "id": "dawnlight:scene/terrain_transparent",
      "version": 1,
      "mode": "builtin"
    },
    {
      "id": "dawnlight:scene/terrain_sorted_translucent",
      "version": 1,
      "mode": "builtin"
    }
  ],
  "settings": "settings.json"
}
settings.json
json
{
  "schemaVersion": 1,
  "defaultLocale": "en-US",
  "translations": {
    "zh-CN": {
      "page.amber": "效果实践",
      "practice:grade": "效果",
      "practice:strength": "效果强度(重新编译)"
    },
    "en-US": {
      "page.amber": "Effect practice",
      "practice:grade": "Effect enabled",
      "practice:strength": "Effect strength (recompile)"
    }
  },
  "pages": [
    {
      "id": "amber",
      "title": "page.amber",
      "groups": [
        {
          "id": "look",
          "controls": [
            {
              "id": "grade",
              "option": "practice:grade",
              "widget": "toggle",
              "label": "practice:grade"
            },
            {
              "id": "strength",
              "option": "practice:strength",
              "widget": "slider",
              "label": "practice:strength",
              "min": 0,
              "max": 1,
              "step": 0.05,
              "format": "0.00",
              "enabledWhen": [
                {
                  "option": "practice:grade",
                  "equals": true
                }
              ]
            }
          ]
        }
      ]
    }
  ]
}
shaders/fullscreen.vsh
glsl
#version 320 es
precision highp float;
out vec2 v_uv;
void main() {
    const vec2 corners[4] = vec2[4](vec2(-1.0, -1.0), vec2(1.0, -1.0), vec2(-1.0, 1.0), vec2(1.0, 1.0));
    vec2 position = corners[gl_VertexID & 3];
    v_uv = position * 0.5 + 0.5;
    gl_Position = vec4(position, 0.0, 1.0);
}
shaders/grade.psh
glsl
#version 320 es
precision highp float;
uniform sampler2D u_sceneColor;
in vec2 v_uv;
layout(location = 0) out vec4 o_color;
void main() {
    vec3 c = texture(u_sceneColor, v_uv).rgb;
    vec3 balanced = (c - 0.5) * 1.12 + 0.5;
    balanced *= vec3(1.05, 1.0, 0.94);
    o_color = vec4(clamp(mix(c, balanced, float(GRADE_STRENGTH)), 0.0, 1.0), 1.0);
}
shaders/present.psh
glsl
#version 320 es
precision highp float;
uniform sampler2D u_postColor;
in vec2 v_uv;
layout(location = 0) out vec4 o_color;
void main() {
    o_color = texture(u_postColor, v_uv);
}

Static checks and runtime scope ​

powershell
shaderpack-analyzer.exe pack validate . --format json
shaderpack-analyzer.exe scene explain . --include-inactive --format json
shaderpack-analyzer.exe graph dump . --contract 2 --include-inactive
shaderpack-analyzer.exe program interface . --program practice:post/grade --contract 2
shaderpack-analyzer.exe program interface . --program practice:post/present --contract 2

Default, grade-off and strength-max were checked on source and fresh ZIP. The CLI graph command above checks defaults only; branch graphs use explicit JSON-RPC inputs.options.

Actual game observations · W7 · features/color-balance

Three option branches, same-pack reload, actual window resize and return to BuiltIn passed. Linked Programs match the static active closure and framebuffers are complete. This covers one Windows device/world/main view, with no performance or numeric readback claim.

fa54b90617955a1d0a257f9e234bdb4135ce35a8d637227bf329292fb4fb3ba7

Branch and lifecycle summary

Actual isolated game window with this effect enabled

Exercise and troubleshooting ​

Change one algorithm constant, save and reload the same pack, recording the new source identity. Compare the toggle with strength=0. If output turns black, disable the effect and follow symptom diagnosis. Retain /switchshader builtin as the recovery path.

Author documentation · Manifest v5 / Scene ABI v2