ポスプロのシェーダーを書く
TODO:なんか書く。このページ、もうちょいまじめに書きたい
Blur
ブラー。ぼけ。ピントによって近景、遠景のいずれかがボケる。動くものがボケる場合、モーションブラーと呼ぶ。動くものにあわせてカメラを動かす場合は景色の方がボケる。ボケは英語でそのままbokeh。
code:HLSL
float4 _MainTex_TexelSize;
fixed4 frag (v2f i) : SV_Target
{
float2 uv = i.uv;
float2 dir = -uv;
float d = length(dir);
dir = normalize(dir) * _MainTex_TexelSize.xy;
dir *= 1.2 * d;
fixed4 col = tex2D(_MainTex, uv) * 0.19;
for (int j = 1; j < 10; j++) {
col += tex2D(_MainTex, uv + dir * j) * (0.19 - j * 0.02);
}
return col;
}
Bloom
強い光が周辺にあふれ出る効果。グローとも呼ぶ。中国語だと泛光。bloom, light bloom, glow。ガウシアンフィルターで処理する。そのまま実装すると処理量が多いが、x方向とy方向とでPassを分けると計算を軽く実現できる。
Vignet
ビネット。画面周辺の色が変わる効果。
code:HLSL
fixed4 frag (v2f i) : SV_Target
{
float2 uv = i.uv;
fixed4 col = tex2D(_MainTex, i.uv);
uv = 2. * uv - 1.;
col *= 1.0 - dot(uv, uv);
return col;
}
Fog
// t is RayTCurrent
vec3 col = mix(materialColor, bgColor, 1.-exp(-.000002*t*t*t));
AA
これどうするのかしらん
ddxとddy使って色を平均化する?とか?
MSAAとかFXAAを調べましょうネェー
Eye Adaptation