티스토리 툴바



2011/08/25 02:20

RGBM & RGBD

float4 EncodeRGBM(float3 rgb)
{
float maxRGB = max(rgb.x,max(rgb.g,rgb.b));
float M = maxRGB / MaxRange;
M = ceil(M * 255.0) / 255.0;
return float4(rgb / (M * MaxRange ), M);
}

float3 DecodeRGBM(float4 rgbm)
{
return rgbm.rgb * (rgbm.a * MaxRange );
}

float4 EncodeRGBD(float3 rgb)
{
float maxRGB = max(rgb.x,max(rgb.g,rgb.b));
float D = max(MaxRange / maxRGB, 1);
D = saturate(floor(D) / 255.0);
return float4(rgb.rgb * (D * (255.0 / MaxRange)), D);
}

float3 DecodeRGBD(float4 rgbd)
{
return rgbd.rgb * ((MaxRange / 255.0) / rgbd.a);
}
저작자 표시 비영리 동일 조건 변경 허락
Creative Commons License
Creative Commons License

'Misc' 카테고리의 다른 글

RGBM & RGBD  (0) 2011/08/25
Unsharp mask  (0) 2009/10/07
Trackback 0 Comment 0