2015年12月11日金曜日

Gamma補正近似

sRGBからリニアへの変換は, 2乗で近似する.
sRGB to Linear
LinearRGB = sRGB*sRGB; 

2015年12月2日水曜日

Unity3D 5 "Enable Internal Profiler"をスクリプトから設定

PlayerSettings.enableInternalProfilerは, iOS用です.
Androidは, プロパティ名 "AndroidProfiler"です.
//For iOS
PlayerSettings.enableInternalProfiler = true;

//For Android
PlayerSettings[] playerSettings = Resources.FindObjectsOfTypeAll();

foreach(PlayerSettings ps in playerSettings) {
    SerializedObject serializedObject = new SerializedObject(ps);
    SerializedProperty enableInternalProfiler = serializedObject.FindProperty("AndroidProfiler");
    if(null == enableInternalProfiler) {
        continue;
    }
    enableInternalProfiler.boolValue = true;
    serializedObject.ApplyModifiedProperties();
}

2015年11月26日木曜日

セカント法を用いた逆関数補間テーブル

セカント法(Secant Method)
$x_{n+1}=x_n - f(x_n)\frac{x_n - x_{n-1}}{f(x_n)-f(x_{n-1})}$
で逆関数の値を事前に計算し, 後に線形補間で求めるメモ.

2015年11月23日月曜日

Ericsson Texture Compression 1に透過情報を入れる

Unity 3D用のコンバータを作成してみる.
https://github.com/taqu/YUVDither

ETC1 に無理やり透過情報を入れる.

2015年11月17日火曜日

Unity3D RenderTextureから, RenderTargetIdentifierを作成

renderTexture = new RenderTexture(
    width,
    height,
    24,
    RenderTextureFormat.Default,
    RenderTextureReadWrite.Default);

CommandBuffer commandBuffer = new CommandBuffer();

int screenCopyID1 = Shader.PropertyToID("_Temp1");
commandBuffer.GetTemporaryRT(
    screenCopyID1,
    width, height, 0,
    FilterMode.Bilinear);

RenderTargetIdentifier renderTargetId = new RenderTargetIdentifier(renderTexture);
commandBuffer.Blit(renderTargetId, screenCopyID1);
てな感じで, コマンドバッファに組み込んでいける.

2015年10月30日金曜日

Low-Discrepancy Sampling

Efficient Multidimensional Sampling
がレイトレース用のサンプリングとして, いい感じ.
PBRT本では, 計算の仕方は異なるが同じものなはず.

2015年10月18日日曜日

Unity3D 16bit ディザリング

テクスチャリソースのインポート処理時に,
ディザリング処理して16ビットに変換する.
Contrast Aware Halftoningを実装.

https://github.com/taqu/Dither