Warning, /plasma/kwin/src/scene/shaders/debug_fractional_core.frag is written in an unsupported language. File is not indexed.
0001 /* 0002 SPDX-FileCopyrightText: 2022 Arjen Hiemstra <ahiemstra@heimr.nl> 0003 SPDX-FileCopyrightText: 2022 David Edmundson <davidedmundson@kde.org> 0004 0005 SPDX-License-Identifier: GPL-2.0-or-later 0006 */ 0007 0008 #version 140 0009 0010 uniform float fractionalPrecision; 0011 uniform vec2 geometrySize; 0012 0013 in vec2 texcoord0; 0014 in float vertexFractional; 0015 0016 out vec4 fragColor; 0017 0018 // paint every time we query textures at non-integer alignments 0019 // it implies we're being upscaled in ways that will cause blurryness 0020 // 2x scaling will go through fine 0021 void main() 0022 { 0023 const float strength = 0.4; 0024 0025 // Calculate an error correction value based on the minimum precision we 0026 // want to measure. 0027 float errorCorrection = 1.0 / fractionalPrecision; 0028 0029 // Determine which exact pixel we are reading from the source texture. 0030 // Texture sampling happens in the middle of a pixel so we need to add 0.5. 0031 vec2 sourcePixel = texcoord0 * geometrySize + 0.5; 0032 // Cancel out any precision artifacts below what we actually want to measure. 0033 sourcePixel = round(sourcePixel * errorCorrection) / errorCorrection; 0034 0035 // The total error is the sum of the fractional parts of the source pixel. 0036 float error = dot(fract(sourcePixel), vec2(1.0)); 0037 0038 fragColor = vec4(0.0); 0039 0040 if (vertexFractional > 0.5) { 0041 fragColor = mix(fragColor, vec4(0.0, 0.0, 1.0, 1.0), strength); 0042 } 0043 0044 if (error > fractionalPrecision) { 0045 fragColor = mix(fragColor, vec4(1.0, 0.0, 0.0, 1.0), strength); 0046 } 0047 } 0048