adjustments to control and stack saving
This commit is contained in:
49
shaders/white-balance-correction/shader.json
Normal file
49
shaders/white-balance-correction/shader.json
Normal file
@@ -0,0 +1,49 @@
|
||||
{
|
||||
"id": "white-balance-correction",
|
||||
"name": "White Balance Correction",
|
||||
"description": "Operator-friendly tint, color balance, and exposure correction intended to pair with the white match probe.",
|
||||
"category": "Color",
|
||||
"entryPoint": "shadeVideo",
|
||||
"parameters": [
|
||||
{
|
||||
"id": "warmCool",
|
||||
"label": "Warm / Cool",
|
||||
"type": "float",
|
||||
"default": 0.0,
|
||||
"min": -1.0,
|
||||
"max": 1.0,
|
||||
"step": 0.001,
|
||||
"description": "Moves the image cooler at negative values and warmer at positive values."
|
||||
},
|
||||
{
|
||||
"id": "greenMagenta",
|
||||
"label": "Green / Magenta",
|
||||
"type": "float",
|
||||
"default": 0.0,
|
||||
"min": -1.0,
|
||||
"max": 1.0,
|
||||
"step": 0.001,
|
||||
"description": "Moves the image toward magenta at negative values and toward green at positive values."
|
||||
},
|
||||
{
|
||||
"id": "exposure",
|
||||
"label": "Exposure",
|
||||
"type": "float",
|
||||
"default": 0.0,
|
||||
"min": -4.0,
|
||||
"max": 4.0,
|
||||
"step": 0.01,
|
||||
"description": "Exposure offset in stop units, using a Blender-style 2^exposure brightness scale."
|
||||
},
|
||||
{
|
||||
"id": "strength",
|
||||
"label": "Strength",
|
||||
"type": "float",
|
||||
"default": 1.0,
|
||||
"min": 0.0,
|
||||
"max": 1.0,
|
||||
"step": 0.01,
|
||||
"description": "Blends the correction with the original image."
|
||||
}
|
||||
]
|
||||
}
|
||||
35
shaders/white-balance-correction/shader.slang
Normal file
35
shaders/white-balance-correction/shader.slang
Normal file
@@ -0,0 +1,35 @@
|
||||
float3 applyWhiteBalanceOnly(float3 color)
|
||||
{
|
||||
float warmAmount = clamp(warmCool, -1.0, 1.0);
|
||||
float tintAmount = clamp(greenMagenta, -1.0, 1.0);
|
||||
|
||||
// Warm/cool pivots red against blue while keeping green more stable.
|
||||
float3 warmCoolGain = float3(
|
||||
exp2(warmAmount * 0.35),
|
||||
exp2(-abs(warmAmount) * 0.08),
|
||||
exp2(-warmAmount * 0.35));
|
||||
|
||||
// Green/magenta pivots green against the average of red and blue.
|
||||
float3 tintGain = float3(
|
||||
exp2(-tintAmount * 0.22),
|
||||
exp2(tintAmount * 0.35),
|
||||
exp2(-tintAmount * 0.22));
|
||||
|
||||
return color * warmCoolGain * tintGain;
|
||||
}
|
||||
|
||||
float3 applyExposureLikeBlender(float3 color)
|
||||
{
|
||||
// Match the compositor-style exposure model: every +1.0 stop doubles the
|
||||
// image and every -1.0 stop halves it.
|
||||
return color * exp2(exposure);
|
||||
}
|
||||
|
||||
float4 shadeVideo(ShaderContext context)
|
||||
{
|
||||
float4 source = context.sourceColor;
|
||||
float3 balanced = applyWhiteBalanceOnly(source.rgb);
|
||||
float3 corrected = applyExposureLikeBlender(balanced);
|
||||
source.rgb = lerp(source.rgb, corrected, saturate(strength));
|
||||
return source;
|
||||
}
|
||||
Reference in New Issue
Block a user