• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1uniform sampler2D m_Texture;
2varying vec2 texCoord;
3
4uniform vec4 m_LineColor;
5uniform vec4 m_PaperColor;
6uniform float m_ColorInfluenceLine;
7uniform float m_ColorInfluencePaper;
8
9uniform float m_FillValue;
10uniform float m_Luminance1;
11uniform float m_Luminance2;
12uniform float m_Luminance3;
13uniform float m_Luminance4;
14uniform float m_Luminance5;
15
16uniform float m_LineDistance;
17uniform float m_LineThickness;
18
19void main() {
20    vec4 texVal = texture2D(m_Texture, texCoord);
21    float linePixel = 0.0;
22
23    float lum = texVal.r*0.2126 + texVal.g*0.7152 + texVal.b*0.0722;
24
25    if (lum < m_Luminance1){
26        if (mod(gl_FragCoord.x + gl_FragCoord.y, m_LineDistance * 2.0) < m_LineThickness)
27            linePixel = 1.0;
28    }
29    if (lum < m_Luminance2){
30        if (mod(gl_FragCoord.x - gl_FragCoord.y, m_LineDistance * 2.0) < m_LineThickness)
31            linePixel = 1.0;
32    }
33    if (lum < m_Luminance3){
34        if (mod(gl_FragCoord.x + gl_FragCoord.y - m_LineDistance, m_LineDistance) < m_LineThickness)
35            linePixel = 1.0;
36    }
37    if (lum < m_Luminance4){
38        if (mod(gl_FragCoord.x - gl_FragCoord.y - m_LineDistance, m_LineDistance) < m_LineThickness)
39            linePixel = 1.0;
40    }
41    if (lum < m_Luminance5){ // No line, make a blob instead
42        linePixel = m_FillValue;
43    }
44
45    // Mix line color with existing color information
46    vec4 lineColor = mix(m_LineColor, texVal, m_ColorInfluenceLine);
47    // Mix paper color with existing color information
48    vec4 paperColor = mix(m_PaperColor, texVal, m_ColorInfluencePaper);
49
50    gl_FragColor = mix(paperColor, lineColor, linePixel);
51}