VideoHelp Forum
+ Reply to Thread
Results 1 to 2 of 2
Thread
  1. Member DanilaZabiaka's Avatar
    Join Date
    May 2020
    Location
    Чебоксары
    Search Comp PM
    Hey. I wanted to say something about video. There are a lot of very bad things with it, but people ignores it
    For example, colors
    RGB pallete is 0-255, now we works with LCD screens, before this we watched on CRT screen

    Some people knows that CRT has better colors, but actually its possible on LCD displays. The first problem is levels

    0-0-0 and 255-255-255 is completely different on CRT and LCD. With another words, you can not met lcd 0-0-0 and 255-255-255 in real life. Black is too black, white is too white
    Video works with limited color range as i know 16-236, but players force them to 0-255
    Its possible to fix this with shaders, actually

    MPC has levels shader, but its broken, the formula is not correct. I fix it and created 2 shaders

    Black:
    Code:
    // Levels=ps_2_0
    // Code from MPC fixed by Danila Zabiaka
    
    sampler s0 : register(s0);
    #define black 16.0
    
    
    
    float4 main(float2 tex : TEXCOORD0) : COLOR
    
    {
    
    	// original pixel
    
    	float4 c0 = tex2D(s0,tex);
    
    
    
    	return c0 + black/255.0 - c0*black/255.0  ;
    
    }
    White

    Code:
    sampler s0 : register(s0);
    
    #define white 236.0
    
    float4 main(float2 tex : TEXCOORD0) : COLOR {
    	// original pixel
    	float4 c0 = tex2D(s0, tex);
    
    	return c0 * white/255.0;
    }
    Then, comression artefacts. Compression is very bad for gradients, it gives blocks and banding. Its debanding shader

    Code:
    //From Dreamject . History: MaverickTse(AviUtl)->SAPikachu(Avisynth)->haasn(GLSL)->JPulowski(Reshade HLSL)->mbah.primbon(HLSL)
    /* --- Settings --- */
    
    #define Threshold			70.0                     //[0.0:4096.0] //-The debanding filter's cut-off threshold. Higher numbers increase the debanding strength dramatically but progressively diminish image details. (Default 64)
    #define Range				16.0                     //[1.0:64.0] //-The debanding filter's initial radius. The radius increases linearly for each iteration. A higher radius will find more gradients, but a lower radius will smooth more aggressively. (Default 16)
    #define Iterations			1                        //[1:16] //-The number of debanding steps to perform per sample. Each step reduces a bit more banding, but takes time to compute. Note that the strength of each step falls off very quickly, so high numbers (>4) are practically useless. (Default 1)
    #define Grain				0.0                     //[0.0:4096.0] //-Add some extra noise to the image. This significantly helps cover up remaining quantization artifacts. Higher numbers add more noise. (Default 48)
    
    /* ---  Defining Constants --- */
    #define myTex2D(s,p) tex2D(s,p)
    
    #ifndef s0
      sampler s0 : register(s0);
      #define s1 s0
    //sampler s1 : register(s1);
    
      float4 p0 : register(c0);
      float4 p1 : register(c1);
    
    //  #define width (p0[0])
    //  #define height (p0[1])
    //  #define counter (p0[2])
      #define clock (p0[3])
    //  #define px (p1[0]) //one_over_width 
    //  #define py (p1[1]) //one_over_height
    
      #define px (p1.x) //one_over_width 
      #define py (p1.y) //one_over_height
      
      #define screen_size float2(p0.x,p0.y)
    
      #define pixel float2(px,py)
    
    //#define pxy float2(p1.xy)
    
    //#define PI acos(-1)
    #endif
    
    
    /* ---  Main code --- */
    
       /*-----------------------------------------------------------.   
      /                     Deband Filter                           /
      '-----------------------------------------------------------*/
    
    float permute(float x) { return ((34.0 * x + 1.0) * x) % 289.0; }
    float rand(float x)    { return frac(x * 0.024390243); }
    
    
    float3 average(sampler2D tex, float2 pos, float range, inout float h) 
    {
        // Compute a random rangle and distance
        float dist = rand(h) * range;     h = permute(h);
        float dir  = rand(h) * 6.2831853; h = permute(h);
    
        float2 pt = dist * pixel;
        float2 o = float2(cos(dir), sin(dir));
    
        // Sample at quarter-turn intervals around the source pixel
        float3 ref[4];
        ref[0] = tex2D(tex, pos + pt * float2( o.x,  o.y)).rgb;
        ref[1] = tex2D(tex, pos + pt * float2(-o.y,  o.x)).rgb;
        ref[2] = tex2D(tex, pos + pt * float2(-o.x, -o.y)).rgb;
        ref[3] = tex2D(tex, pos + pt * float2( o.y, -o.x)).rgb;
    
        // Return the (normalized) average
        return (ref[0] + ref[1] + ref[2] + ref[3]) * 0.25;
    }
    
    
    /* --- Main --- */
    
    float4 main(float2 texcoord : TEXCOORD0) : COLOR 
    {   
    	float h;
        // Initialize the PRNG by hashing the position + a random uniform
        float3 m = float3(texcoord, clock * 0.0002) + 1.0;
        h = permute(permute(permute(m.x) + m.y) + m.z);
    
        // Sample the source pixel
        float3 col = tex2D(s0, texcoord).rgb;
    	float3 avg; float3 diff;
    	
    	#if (Iterations == 1)
    		[unroll]
    	#endif
        for (int i = 1; i <= Iterations; i++) {
            // Sample the average pixel and use it instead of the original if the difference is below the given threshold
            avg = average(s0, texcoord, i * Range, h);
            diff = abs(col - avg);
            col = lerp(avg, col, diff > Threshold * 0.00006103515625 * i);
        }
    
        if (Grain > 0.0) {
    		// Add some random noise to smooth out residual differences
    		float3 noise;
    		noise.x = rand(h); h = permute(h);
    		noise.y = rand(h); h = permute(h);
    		noise.z = rand(h); h = permute(h);
    		col += (Grain * 0.000122070313) * (noise - 0.5);
    	}
    
        return float4(col, 1.0);
    }
    Surfaces in real life has texture, but video compression removes noise

    It's noise shader, i prefer 2-5

    HTML Code:
    sampler s0 : register(s0);
    float4 p0 :  register(c0);
    float4 p1 :  register(c1);
    
    #define amplificationFactor 5
    #define offset -15.0
    #define dx (p1[0])
    #define dy (p1[1])
    #define counter (p0[2])
    #define clock (p0[3])
    
    
    
    float randCust(in float2 uv) {
    	float noiseX = (frac(sin(dot(uv, float2(12.9898,78.233)      )) * 43758.5453));
    	float noiseY = (frac(sin(dot(uv, float2(12.9898,78.233) * 2.0)) * 43758.5453));
    	return noiseX * noiseY;
    }
    
    float4 main(float2 tex : TEXCOORD0) : COLOR {
    	float4 orig;
    	orig = tex2D(s0, tex);
    	float noise = randCust(tex*(counter/500)) + offset/100;
    
    	return orig+ (noise*amplificationFactor/100);
    }
    Then, time. When you see TV or go to the cinema, you dont see time bar, and you can dive in watching, when you can move cursor and see how much time passed left, it destroys. In potplayer its possible to make time bar hidable, in another player you cant

    Hm...
    Quote Quote  
  2. Member DanilaZabiaka's Avatar
    Join Date
    May 2020
    Location
    Чебоксары
    Search Comp PM
    About colors, if some coder read me. There are some software to control colors on screen like f.lux

    Actually if you wanna make your display better, you need change black and white point boths.

    Its not enought to just make colors warmer how f.lux suggests

    It will be great, if you can tune levels. You can limit white a little in dccw from windows


    But there are no correct tools to change black point. May be some programmer can change redshift sources to make this possible and make simple GUI
    https://github.com/jonls/redshift

    Actually for calibration for your taste you dont need to change color temp, you can move RGB sliders, like dccw does, but they works only for max values

    May be somebody can change redshift a little for this gui
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!