diff options
author | Lauri Myllari <lauri.myllari@gmail.com> | 2015-05-10 21:29:28 -0700 |
---|---|---|
committer | Rainer Hochecker <fernetmenta@online.de> | 2015-12-06 19:55:22 +0100 |
commit | c4a136d22f5be60793edc3aa7ba79474c0677812 (patch) | |
tree | 98e134f5a3db8085fe2bac7724b688a6633a2ce2 /system | |
parent | a4eb99246c03bb0f8558bc553a706141eca8e4d7 (diff) |
gl: GLSLOutput helper with dithering
Implement a GLSLOutput class that can be passed to shaders to implement
an output stage with RGB range conversion and dithering. Add support for
GLSLOutput in YUV2RGBShader and ConvolutionFilterShader.
Single pass rendering to full range is not optimal as the range
conversion could be done in colorspace conversion matrix. Keeping video
levels avoids banding in multipass rendering though.
Diffstat (limited to 'system')
-rw-r--r-- | system/shaders/output.glsl | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/system/shaders/output.glsl b/system/shaders/output.glsl index 53c89935ae..83f77b04c0 100644 --- a/system/shaders/output.glsl +++ b/system/shaders/output.glsl @@ -1,6 +1,24 @@ +#if (XBMC_DITHER) +uniform sampler2D m_dither; +uniform float m_ditherquant; +uniform vec2 m_dithersize; +#endif + void main() { - vec4 rgb = process(); + vec4 rgb = process(); + +#if (XBMC_FULLRANGE) + rgb = clamp((rgb-(16.0/255.0)) * 255.0/219.0, 0, 1); +#endif + +#if (XBMC_DITHER) + vec2 ditherpos = gl_FragCoord.xy / m_dithersize; + // ditherval is multiplied by 65536/(dither_size^2) to make it [0,1[ + // FIXME: scale dither values before uploading? + float ditherval = texture2D(m_dither, ditherpos).r * 16.0; + rgb = floor(rgb * m_ditherquant + ditherval) / m_ditherquant; +#endif - gl_FragColor = rgb; + gl_FragColor = rgb; } |