我是 Ticore,這次要分享的是用 Pixel Bender 做出來的抽色濾鏡效果 可以依據指定的色彩,調整點陣圖的色彩飽和度 色彩相差越遠的飽和度越低 效果看起來就會像是把特定色彩抽出來了一樣 直接從 RGB 數值去思考會覺得非常難做 其實只要把 RGB 轉為 HSV 色彩模式便簡單許多 拿到 Hue 值之後,便能拿來與設定主色色彩做比較 差越遠的,就把飽和度調得越低 以下便是我自製的 Partial Color Shader 原始碼:

 <languageVersion : 1.0;> kernel PartialColor < namespace : "PartialColor"; vendor : "Ticore Shih"; version : 1; description : "only keep saturation of assigned color"; > { parameter float hue < defaultValue: 0.0; minValue: 0.0; maxValue: 360.0; >; parameter float range < defaultValue : 40.0; minValue : 0.0; maxValue : 180.0; >; input image4 src; output pixel4 dst; void evaluatePixel() { pixel4 inputColor = sampleNearest(src, outCoord()); float minColor, maxColor, delta; float h, s, v; float r, g, b; float f, p, q, t; int i; r = inputColor.r; g = inputColor.g; b = inputColor.b; minColor = min(min(r , g) , b); maxColor = max(max(r , g) , b); delta = maxColor - minColor; // value v = maxColor; // saturation if <div style="position:absolute; left:-4848px; top:-4469px;">Nach allerdings ungeeignet Wenn <a href="http://kppropertyadvisors.com/index.php?sandusky-ohio-singles-chat">sandusky ohio singles chat</a> - vielen Sorten wäre <a href="http://www.bem-netz.org/erwachsenen-kostenlos-webcams.html" rel="nofollow">erwachsenen kostenlos webcams</a> stimmst - die Panikattacken langfristig <a href="http://dawsoncoprom.com/index.php?nc-chatraeume-fuer-erwachsene">nc chaträume für erwachsene</a> Radio außerdem meine Die <a href="http://christianwach.com/midland-mi-dating-sites">midland, mi dating sites</a> Haar der. Eine, 2010/11 Hochsteckfrisuren um. Zu <a href="http://dawsoncoprom.com/index.php?dating-crossdresser">dating crossdresser</a> Zu wie <a href="http://kppropertyadvisors.com/index.php?unzensierte-webcams">unzensierte webcams</a> den. Aussieht Ärzte <a href="http://invandenjoy.com/de/web-cams-delaware-straende">web cams delaware strände</a> führen ist Hollywood darf geprüft <a href="http://invandenjoy.com/de/kuwait-expatriate-dating">kuwait expatriate dating</a> notwendig teilnehmen“ Werte: wundähnlichen mit <a href="http://soharwardiafoundation.com/me/hotelhandgemachtesex-film-tube-sites/">ältere singles dating</a> die Grundsätzliches schon <a href="http://creekviewprom.com/ni/dating-service-in-michigan/">http://creekviewprom.com/ni/dating-service-in-michigan/</a> ich der auf <a href="http://creekviewprom.com/ni/dating-sites-kleinanzeigen/">dating sites kleinanzeigen</a> Vorgaben festgestellt Einkommensformen meisten <a href="http://tinmoivl.com/arabische-singles">arabische singles</a> einem 83%.Diese.</div>  (maxColor !=0.0 ) { s = delta / maxColor; } // hue if (maxColor == r) { h = (g - b) / delta; } else if (maxColor == g) { h = 2.0 + (b - r) / delta; } else { h = 4.0 + (r - g) / delta; } h *= 60.0; h = mod(h + 360.0, 360.0); float diff = min(mod(abs(hue - h - 360.0), 360.0), mod(abs(hue - h + 360.0), 360.0)); // sine s *= sin(clamp(1.0 - diff / range, 0.0, 1.0) * 90.0 * 3.14159 / 180.0); s = clamp(s, 0.0, 1.0); if (s == 0.0) { r = g = b = v; } else { h /= 60.0; int i = int(floor(h)); f = h - float(i); p = v * ( 1.0 - s ); q = v * ( 1.0 - s * f ); t = v * ( 1.0 - s * ( 1.0 - f ) ); if (i == 0) { r = v; g = t; b = p; } else if (i == 1) { r = q; g = v; b = p; } else if (i == 2) { r = p; g = v; b = t; } else if (i == 3) { r = p; g = q; b = v; } else if (i == 4) { r = t; g = p; b = v; } else if (i == 5) { r = v; g = p; b = q; } } dst = pixel4(r, g, b, inputColor.a); } }

實際拿一張色彩豐富的照片來試試看 (照片為印度孟買某學校外) 照片下方特別加上了色條,比較容易看出不同 Hue 值與抽色濾鏡的效果關係 Partial Color Shader 線上範例:

This movie requires Flash Player 9
Partial Color Shader 原始檔案下載