-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2ac70a5
commit 70bd4a4
Showing
4 changed files
with
150 additions
and
332 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
Gizmo { | ||
name ACES_RGC_blink | ||
label "\[value direction]" | ||
selected true | ||
xpos -244 | ||
ypos -112 | ||
addUserKnob {20 GamutCompress l "ACES Reference Gamut Compress (blinkscript)"} | ||
addUserKnob {6 use_gpu l "use gpu" t "use gpu for blinkscript node" -STARTLINE} | ||
use_gpu true | ||
addUserKnob {4 direction M {forward inverse}} | ||
addUserKnob {20 info_tab l Info} | ||
addUserKnob {26 info_label l " " T "<style> a:link \{ color: #ccc \}</style>\n<font color=#ccc>\n<b>ACES 1.3 Reference Gamut Compression</b><br>\nMaps out of gamut colors back into AP1.<br><br>Input image data is expected to be ACEScg.\n<br><br>Based on:<br><a href=https://github.com/ampas/aces-dev/blob/dev/transforms/ctl/lmt/LMT.Academy.GamutCompress.ctl>https://github.com/ampas/aces-dev/blob/dev/transforms/ctl/lmt/LMT.Academy.GamutCompress.ctl</a>"} | ||
} | ||
Input { | ||
inputs 0 | ||
name Input | ||
xpos -40 | ||
ypos -10 | ||
} | ||
AddChannels { | ||
name AddChannels | ||
xpos -40 | ||
ypos 40 | ||
} | ||
BlinkScript { | ||
recompileCount 34 | ||
ProgramGroup 1 | ||
KernelDescription "2 \"GamutCompression\" iterate pixelWise 73c19a90997539f78bd63416346b872f79d9dbc3bc18da77d6bb4c62a2df7287 2 \"src\" Read Point \"dst\" Write Point 1 \"invert\" Bool 1 AA== 1 \"invert\" 1 1 3 \"thr\" Float 3 1 AAAAAAAAAAAAAAAAAAAAAA== \"lim\" Float 3 1 AAAAAAAAAAAAAAAAAAAAAA== \"p\" Float 1 1 AAAAAA==" | ||
kernelSource "kernel GamutCompression : public ImageComputationKernel<ePixelWise> \{\n Image<eRead, eAccessPoint, eEdgeClamped> src;\n Image<eWrite> dst;\n\n param:\n bool invert;\n\n local:\n float3 thr;\n float3 lim;\n float p;\n\n void init() \{\n // thr is the percentage of the core gamut to preserve\n thr = float3(0.815f, 0.803f, 0.88f);\n\n // lim is the max distance from the gamut boundary that will be compressed\n lim = float3(1.147f, 1.264f, 1.312f);\n\n // Aggressiveness of the compression curve\n p = 1.2f;\n \}\n\n // calculate compressed distance\n float compress(float x, float l, float t) \{\n float cx, s;\n if (x < t) \{\n cx = x;\n \} else \{\n // power(p) compression function plot https://www.desmos.com/calculator/54aytu7hek\n if (l < 1.0001) \{\n return x; // disable compression, avoid nan\n \}\n s = (l-t)/pow(pow((1.0f-t)/(l-t),-p)-1.0f,1.0f/p); // calc y=1 intersect\n if (invert == 0) \{\n cx = t+s*((x-t)/s)/(pow(1.0f+pow((x-t)/s,p),1.0f/p)); // compress\n \} else \{\n if (x > (t + s)) \{\n cx = x; // avoid singularity\n \} else \{\n cx = t+s*pow(-(pow((x-t)/s,p)/(pow((x-t)/s,p)-1.0f)),1.0f/p); // uncompress\n \}\n \}\n \}\n return cx;\n \}\n\n\n void process(int2 pos) \{\n // source pixels\n SampleType(src) rgba = src();\n float3 rgb = float3(rgba.x, rgba.y, rgba.z);\n\n // achromatic axis \n float ach = max(rgb.x, max(rgb.y, rgb.z));\n\n // distance from the achromatic axis for each color component aka inverse rgb ratios\n // distance is normalized by achromatic, so that 1.0f is at gamut boundary, avoid 0 div\n float3 dist = ach == 0 ? float3(0.0f, 0.0f, 0.0f) : (ach-rgb)/fabs(ach);\n\n // compress distance with parameterized shaper function\n float3 cdist;\n cdist = float3(\n compress(dist.x, lim.x, thr.x),\n compress(dist.y, lim.y, thr.y),\n compress(dist.z, lim.z, thr.z));\n\n // recalculate rgb from compressed distance and achromatic\n // effectively this scales each color component relative to achromatic axis by the compressed distance\n float3 crgb = ach-cdist*fabs(ach);\n\n // write to output\n dst() = float4(crgb.x, crgb.y, crgb.z, rgba.w);\n \}\n\};" | ||
useGPUIfAvailable {{parent.use_gpu x1 0}} | ||
rebuild "" | ||
GamutCompression_invert {{parent.direction}} | ||
rebuild_finalise "" | ||
name GamutCompress | ||
selected true | ||
xpos -40 | ||
ypos 100 | ||
} | ||
Output { | ||
name Output | ||
xpos -40 | ||
ypos 172 | ||
} | ||
end_group |
Oops, something went wrong.