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