*エフェクト-色調補正 [#u511f066] 画面の色味を補正するもの。 計算式や実装など本来の物と違ったらごめんなさい。 ---- #contents ** モノクロ [#m788e47c] RGB色空間をYCbCr色空間に変換。 輝度Yだけ取り出す。 const float3 RGBtoY = {0.299, 0.587, 0.114}; float4 color = tex2D(TextureSampler, tex_coord0); color.rgb = dot(color, RGBtoY); return color; ** セピア [#c3f417b7] モノクロ化した後に、Cb, Cr に適当な数値をいれて、再度RGBに戻す。 const float3 RGBtoY = { 0.299, 0.587, 0.114}; float3x3 YCbCrtoRGB = { {1.0, 0.00000, 1.40200}, {1.0, -0.34414, -0.71414}, {1.0, 1.77200, 0.00000}, }; float4 color = tex2D(TextureSampler, tex_coord0); // RGBからYCbCrへ変換 float3 YCbCr; YCbCr.x = dot(color, RGBtoY); YCbCr.y = -0.091; YCbCr.z = 0.056; // YCbCr -> rgb color.rgb = mul(YCbCrtoRGB, YCbCr); return color; ** コントラスト調整 [#b77541b0] 明るい所は明るく、暗い所は暗く強調する。 色は0.0~1.0なので、中間の0.5を基準に上下に引っ張ってます。 float4 color = tex2D(TextureSampler, tex_coord0); // -0.5~0.5の範囲 color.rgb = ((color.rgb - 0.5) * Rate) + 0.5; return color; |