KiCad PCB EDA Suite
shader_src.h
Go to the documentation of this file.
1 // Do not edit this file, it is autogenerated by CMake.
2 
3 #ifndef SHADER_SRC_H
4 #define SHADER_SRC_H
5 
6 const unsigned int shaders_number = 2;
7 const char* shaders_src[] =
8 {
9 
10 // /home/kicad/workspace/kicad-doxygen/common/gal/opengl/shader.vert
11 "#version 120\n"
12 "const float SHADER_LINE=1.0;\n"
13 "const float SHADER_FILLED_CIRCLE=2.0;\n"
14 "const float SHADER_STROKED_CIRCLE=3.0;\n"
15 "const float SHADER_FONT=4.0;\n"
16 "const float MIN_WIDTH=1.0;\n"
17 "attribute vec4 attrShaderParams;\n"
18 "varying vec4 shaderParams;\n"
19 "varying vec2 circleCoords;\n"
20 "void main()\n"
21 "{\n"
22 "shaderParams=attrShaderParams;\n"
23 "if(shaderParams[0]==SHADER_LINE)\n"
24 "{\n"
25 "float lineWidth=shaderParams[3];\n"
26 "float worldScale=abs(gl_ModelViewMatrix[0][0]);\n"
27 "if(worldScale*lineWidth<MIN_WIDTH)\n"
28 "gl_Position=gl_ModelViewProjectionMatrix*\n"
29 "(gl_Vertex+vec4(shaderParams.yz*MIN_WIDTH/(worldScale*lineWidth),0.0,0.0));\n"
30 "else\n"
31 "gl_Position=gl_ModelViewProjectionMatrix*\n"
32 "(gl_Vertex+vec4(shaderParams.yz,0.0,0.0));\n"
33 "}\n"
34 "else if((shaderParams[0]==SHADER_STROKED_CIRCLE)||\n"
35 "(shaderParams[0]==SHADER_FILLED_CIRCLE))\n"
36 "{\n"
37 "if(shaderParams[1]==1.0)\n"
38 "circleCoords=vec2(-sqrt(3.0),-1.0);\n"
39 "else if(shaderParams[1]==2.0)\n"
40 "circleCoords=vec2(sqrt(3.0),-1.0);\n"
41 "else if(shaderParams[1]==3.0)\n"
42 "circleCoords=vec2(0.0,2.0);\n"
43 "else if(shaderParams[1]==4.0)\n"
44 "circleCoords=vec2(-3.0/sqrt(3.0),0.0);\n"
45 "else if(shaderParams[1]==5.0)\n"
46 "circleCoords=vec2(3.0/sqrt(3.0),0.0);\n"
47 "else if(shaderParams[1]==6.0)\n"
48 "circleCoords=vec2(0.0,2.0);\n"
49 "float lineWidth=shaderParams[3];\n"
50 "float worldScale=abs(gl_ModelViewMatrix[0][0]);\n"
51 "if(worldScale*lineWidth<MIN_WIDTH)\n"
52 "shaderParams[3]=shaderParams[3]/(worldScale*lineWidth);\n"
53 "gl_Position=ftransform();\n"
54 "}\n"
55 "else\n"
56 "{\n"
57 "gl_Position=ftransform();\n"
58 "}\n"
59 "gl_FrontColor=gl_Color;\n"
60 "}\n"
61 ,
62 // /home/kicad/workspace/kicad-doxygen/common/gal/opengl/shader.frag
63 "#version 120\n"
64 "#define USE_MSDF\n"
65 "const float SHADER_LINE=1.0;\n"
66 "const float SHADER_FILLED_CIRCLE=2.0;\n"
67 "const float SHADER_STROKED_CIRCLE=3.0;\n"
68 "const float SHADER_FONT=4.0;\n"
69 "varying vec4 shaderParams;\n"
70 "varying vec2 circleCoords;\n"
71 "uniform sampler2D fontTexture;\n"
72 "uniform int fontTextureWidth;\n"
73 "void filledCircle(vec2 aCoord)\n"
74 "{\n"
75 "if(dot(aCoord,aCoord)<1.0)\n"
76 "gl_FragColor=gl_Color;\n"
77 "else\n"
78 "discard;\n"
79 "}\n"
80 "void strokedCircle(vec2 aCoord,float aRadius,float aWidth)\n"
81 "{\n"
82 "float outerRadius=aRadius+(aWidth/2);\n"
83 "float innerRadius=aRadius -(aWidth/2);\n"
84 "float relWidth=innerRadius/outerRadius;\n"
85 "if((dot(aCoord,aCoord)<1.0)&&\n"
86 "(dot(aCoord,aCoord)>relWidth*relWidth))\n"
87 "gl_FragColor=gl_Color;\n"
88 "else\n"
89 "discard;\n"
90 "}\n"
91 "#ifdef USE_MSDF\n"
92 "float median(vec3 v)\n"
93 "{\n"
94 "return max(min(v.r,v.g),min(max(v.r,v.g),v.b));\n"
95 "}\n"
96 "#endif\n"
97 "void main()\n"
98 "{\n"
99 "if(shaderParams[0]==SHADER_FILLED_CIRCLE)\n"
100 "{\n"
101 "filledCircle(circleCoords);\n"
102 "}\n"
103 "else if(shaderParams[0]==SHADER_STROKED_CIRCLE)\n"
104 "{\n"
105 "strokedCircle(circleCoords,shaderParams[2],shaderParams[3]);\n"
106 "}\n"
107 "else if(shaderParams[0]==SHADER_FONT)\n"
108 "{\n"
109 "vec2 tex=shaderParams.yz;\n"
110 "float derivative=length(dFdx(tex))*fontTextureWidth/4;\n"
111 "#ifdef USE_MSDF\n"
112 "float dist=median(texture2D(fontTexture,tex).rgb);\n"
113 "#else\n"
114 "float dist=texture2D(fontTexture,tex).r;\n"
115 "#endif\n"
116 "float alpha=smoothstep(0.5 - derivative,0.5+derivative,dist);\n"
117 "gl_FragColor=vec4(gl_Color.rgb,alpha);\n"
118 "}\n"
119 "else\n"
120 "{\n"
121 "gl_FragColor=gl_Color;\n"
122 "}\n"
123 "}\n"
124 ,};
125 #endif /* SHADER_SRC_H */
const char * shaders_src[]
Definition: shader_src.h:7
const unsigned int shaders_number
Definition: shader_src.h:6