improve text shader
This commit is contained in:
Родитель
9196614f06
Коммит
4addcbeb1c
|
@ -9,7 +9,7 @@ public enum PolygonMode {
|
||||||
public static class ChartsRenderSettings {
|
public static class ChartsRenderSettings {
|
||||||
public static bool useDefaultMat = false;
|
public static bool useDefaultMat = false;
|
||||||
public static bool debugTextMat = false;
|
public static bool debugTextMat = false;
|
||||||
public static float textThickness = 0.52f;
|
public static float textThickness = 0.3f;
|
||||||
public static PolygonMode polygonMode = PolygonMode.fill;
|
public static PolygonMode polygonMode = PolygonMode.fill;
|
||||||
public static int textQuality = 1;
|
public static int textQuality = 1;
|
||||||
}
|
}
|
|
@ -8,33 +8,39 @@ in vec4 fragCol;
|
||||||
in vec2 texCoord;
|
in vec2 texCoord;
|
||||||
|
|
||||||
// uniforms
|
// uniforms
|
||||||
uniform float u_gamma = 0.52;
|
uniform float u_gamma = 0.3;
|
||||||
uniform sampler2D texture0;
|
uniform sampler2D texture0;
|
||||||
uniform vec3 cameraPos;
|
|
||||||
uniform float textQuality;
|
uniform float textQuality;
|
||||||
|
|
||||||
// outputs
|
// outputs
|
||||||
out vec4 outFragColor;
|
out vec4 outFragColor;
|
||||||
|
|
||||||
float sample(vec2 coord) {
|
float sample(vec2 coord, float gammaAdd) {
|
||||||
float dist = texture2D(texture0, coord).r - .5;
|
float dist = texture2D(texture0, coord).r - u_gamma - gammaAdd;
|
||||||
float alpha = clamp(dist / fwidth(dist) + .5, 0.0, 1.0);
|
float alpha = clamp(dist / fwidth(dist) + u_gamma + gammaAdd, 0.0, 1.0);
|
||||||
return alpha;
|
return alpha;
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: better LCD-rendering for light theme
|
|
||||||
void main() {
|
void main() {
|
||||||
|
const float rA = 1;
|
||||||
|
const float bA = 1;
|
||||||
|
|
||||||
|
float fragGamma = (fragCol.x + fragCol.y + fragCol.z) * .1;
|
||||||
float s = -dFdx(texCoord.x) / 3.0;
|
float s = -dFdx(texCoord.x) / 3.0;
|
||||||
|
|
||||||
if (textQuality == 1) {
|
if (textQuality == 1) {
|
||||||
float r = sample(texCoord - vec2(s,0));
|
float g = sample(texCoord, fragGamma);
|
||||||
float g = sample(texCoord);
|
float r = sample(texCoord - vec2(s,0), fragGamma);
|
||||||
float b = sample(texCoord + vec2(s,0));
|
float b = sample(texCoord + vec2(s,0), fragGamma);
|
||||||
float a = max(r,max(g,b));
|
float a = max(r,max(g,b));
|
||||||
gl_FragColor = (vec4(r,g,b,a) + vec4(1,1,1,0)) * vec4(.5,.5,.5,1) * fragCol;
|
float rContrast = max(r-g, 0);
|
||||||
|
float bContrast = max(b-g, 0);
|
||||||
|
|
||||||
|
gl_FragColor = vec4(1,1,1,a) * fragCol;
|
||||||
|
gl_FragColor.r = mix(gl_FragColor.r, r, r * rContrast);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
float a = sample(texCoord);
|
float a = sample(texCoord, fragGamma);
|
||||||
gl_FragColor = vec4(1,1,1,a) * fragCol;
|
gl_FragColor = vec4(1,1,1,a) * fragCol;
|
||||||
}
|
}
|
||||||
}
|
}
|
Загрузка…
Ссылка в новой задаче