View Single Post
Old 5th March 2014, 00:13   #24258  |  Link
Shiandow
Registered User
 
Join Date: Dec 2013
Posts: 753
Quote:
Originally Posted by madshi View Post
I'm not convinced about this. Smooth motion blending could in theory mix a black pixel from frame A together with a white pixel from frame B, regardless of bitdepth. Obviously doing this in linear light will result in dramatically different results compared to doing it in gamma light. However, if we're talking about dithering, we're dealing with mixing two neighbor shades in the output bitdepth. The general position of these two shades on the overall gamma curve are not changed by the dithering process. Using linear light will only slightly change how many pixels are drawn with shade 1 and how many with shade 2. Because of that I don't think that smooth motion FRC and dithering would have to use the same gamma function. But I've not tested any of this, so I'm just brainstorming here...
I just confirmed that it also happens when smooth motion is disabled and only when dithering is dynamic. So indeed it seems that I was wrong that the blinking was caused by dithering and smooth motion using different gamma curves. It also seems to happen on places that don't even change colour which also suggests that smooth motion can't be the cause. Something doesn't seem to be as random as it should be.

That aside, I am convinced that it would be better if smooth motion and dithering used the same gamma curves. For instance assume that smooth motion attempts to blend two adjacent colours 1,2. Let's say that the result should be 50% shade 1 and 50% shade 2, if this processing is done in linear light then the resulting colour generally won't be precisely between colours 1 and 2. But then in the dithering step the resulting pixels won't be 50% shade 1 or shade 2 but will be biased towards one of them. You could solve this by changing the gamma curve of smooth motion to be linear in between adjacent colours, or you can change the fractional part of the resulting pixel value such that the right percentage is rounded up instead of rounded down. This last method should in theory give an exact result so that is the one I tried to achieve with the following shader:

Code:
#define depth pow(2,8)
sampler s0 : register(s0);

float4 f(float4 x)
{
	return pow(x,1/0.45);
}

float4 main(float2 tex : TEXCOORD0) : COLOR
{
	float4 c0  = tex2D(s0, tex);
	float4 low = floor(depth*c0)/depth;
	float4 hi  = ceil (depth*c0)/depth;
	float4 c1  = (f(c0)-f(low))/(f(hi)-f(low));
	return low+(c1/depth);
}
the value 'depth' should be 2^8 if the final output is 8 bits, 2^6 for 6 bits etc. This shader shouldn't change the behaviour of the dithering algorithms much, beyond correcting the colours. In particular the error diffusion algorithms still diffuse errors in gamma light (more or less).
Shiandow is offline   Reply With Quote