17#ifndef QOPENGL_ENGINE_SHADER_SOURCE_H
18#define QOPENGL_ENGINE_SHADER_SOURCE_H
26 void setPosition(); \n\
27 void main(void) \n\
28 { \n\
29 setPosition(); \n\
30 }\n";
33 attribute highp vec2 textureCoordArray; \n\
34 varying highp vec2 textureCoords; \n\
35 void setPosition(); \n\
36 void main(void) \n\
37 { \n\
38 setPosition(); \n\
39 textureCoords = textureCoordArray; \n\
40 }\n";
43 attribute highp vec2 textureCoordArray; \n\
44 attribute lowp float opacityArray; \n\
45 varying highp vec2 textureCoords; \n\
46 varying lowp float opacity; \n\
47 void setPosition(); \n\
48 void main(void) \n\
49 { \n\
50 setPosition(); \n\
51 textureCoords = textureCoordArray; \n\
52 opacity = opacityArray; \n\
53 }\n";
58 attribute highp vec2 vertexCoordsArray; \n\
59 attribute highp vec3 pmvMatrix1; \n\
60 attribute highp vec3 pmvMatrix2; \n\
61 attribute highp vec3 pmvMatrix3; \n\
62 void setPosition(void) \n\
63 { \n\
64 highp mat3 pmvMatrix = mat3(pmvMatrix1, pmvMatrix2, pmvMatrix3); \n\
65 vec3 transformedPos = pmvMatrix * vec3(vertexCoordsArray.xy, 1.0); \n\
66 gl_Position = vec4(transformedPos.xy, 0.0, transformedPos.z); \n\
67 }\n";
70 uniform highp mat3 matrix; \n\
71 attribute highp vec2 vertexCoordsArray; \n\
72 void setPosition(void) \n\
73 { \n\
74 gl_Position = vec4(matrix * vec3(vertexCoordsArray, 1), 1);\n\
75 } \n";
78 attribute highp vec4 vertexCoordsArray; \n\
79 void setPosition(void) \n\
80 { \n\
81 gl_Position = vertexCoordsArray; \n\
82 }\n";
86 attribute highp vec2 vertexCoordsArray; \n\
87 attribute highp vec3 pmvMatrix1; \n\
88 attribute highp vec3 pmvMatrix2; \n\
89 attribute highp vec3 pmvMatrix3; \n\
90 uniform mediump vec2 halfViewportSize; \n\
91 uniform highp vec2 invertedTextureSize; \n\
92 uniform highp mat3 brushTransform; \n\
93 varying highp vec2 patternTexCoords; \n\
94 void setPosition(void) \n\
95 { \n\
96 highp mat3 pmvMatrix = mat3(pmvMatrix1, pmvMatrix2, pmvMatrix3); \n\
97 vec3 transformedPos = pmvMatrix * vec3(vertexCoordsArray.xy, 1.0); \n\
98 gl_Position.xy = transformedPos.xy / transformedPos.z; \n\
99 mediump vec2 viewportCoords = (gl_Position.xy + 1.0) * halfViewportSize; \n\
100 mediump vec3 hTexCoords = brushTransform * vec3(viewportCoords, 1.0); \n\
101 mediump float invertedHTexCoordsZ = 1.0 / hTexCoords.z; \n\
102 gl_Position = vec4(gl_Position.xy * invertedHTexCoordsZ, 0.0, invertedHTexCoordsZ); \n\
103 patternTexCoords.xy = (hTexCoords.xy * 0.125) * invertedHTexCoordsZ; \n\
104 }\n";
110 uniform sampler2D brushTexture; \n\
111 uniform lowp vec4 patternColor; \n\
112 varying highp vec2 patternTexCoords;\n\
113 lowp vec4 srcPixel() \n\
114 { \n\
115 return patternColor * (1.0 - texture2D(brushTexture, patternTexCoords).r); \n\
116 }\n";
121 attribute highp vec2 vertexCoordsArray; \n\
122 attribute highp vec3 pmvMatrix1; \n\
123 attribute highp vec3 pmvMatrix2; \n\
124 attribute highp vec3 pmvMatrix3; \n\
125 uniform mediump vec2 halfViewportSize; \n\
126 uniform highp vec3 linearData; \n\
127 uniform highp mat3 brushTransform; \n\
128 varying mediump float index; \n\
129 void setPosition() \n\
130 { \n\
131 highp mat3 pmvMatrix = mat3(pmvMatrix1, pmvMatrix2, pmvMatrix3); \n\
132 vec3 transformedPos = pmvMatrix * vec3(vertexCoordsArray.xy, 1.0); \n\
133 gl_Position.xy = transformedPos.xy / transformedPos.z; \n\
134 mediump vec2 viewportCoords = (gl_Position.xy + 1.0) * halfViewportSize; \n\
135 mediump vec3 hTexCoords = brushTransform * vec3(viewportCoords, 1); \n\
136 mediump float invertedHTexCoordsZ = 1.0 / hTexCoords.z; \n\
137 gl_Position = vec4(gl_Position.xy * invertedHTexCoordsZ, 0.0, invertedHTexCoordsZ); \n\
138 index = (dot(linearData.xy, hTexCoords.xy) * linearData.z) * invertedHTexCoordsZ; \n\
139 }\n";
145 uniform sampler2D brushTexture; \n\
146 varying mediump float index; \n\
147 lowp vec4 srcPixel() \n\
148 { \n\
149 mediump vec2 val = vec2(index, 0.5); \n\
150 return texture2D(brushTexture, val); \n\
151 }\n";
156 attribute highp vec2 vertexCoordsArray; \n\
157 attribute highp vec3 pmvMatrix1; \n\
158 attribute highp vec3 pmvMatrix2; \n\
159 attribute highp vec3 pmvMatrix3; \n\
160 uniform mediump vec2 halfViewportSize; \n\
161 uniform highp mat3 brushTransform; \n\
162 varying highp vec2 A; \n\
163 void setPosition(void) \n\
164 { \n\
165 highp mat3 pmvMatrix = mat3(pmvMatrix1, pmvMatrix2, pmvMatrix3); \n\
166 vec3 transformedPos = pmvMatrix * vec3(vertexCoordsArray.xy, 1.0); \n\
167 gl_Position.xy = transformedPos.xy / transformedPos.z; \n\
168 mediump vec2 viewportCoords = (gl_Position.xy + 1.0) * halfViewportSize; \n\
169 mediump vec3 hTexCoords = brushTransform * vec3(viewportCoords, 1); \n\
170 mediump float invertedHTexCoordsZ = 1.0 / hTexCoords.z; \n\
171 gl_Position = vec4(gl_Position.xy * invertedHTexCoordsZ, 0.0, invertedHTexCoordsZ); \n\
172 A = hTexCoords.xy * invertedHTexCoordsZ; \n\
173 }\n";
179 #define INVERSE_2PI 0.1591549430918953358 \n\
180 uniform sampler2D brushTexture; \n\
181 uniform mediump float angle; \n\
182 varying highp vec2 A; \n\
183 lowp vec4 srcPixel() \n\
184 { \n\
185 highp float t; \n\
186 if (abs(A.y) == abs(A.x)) \n\
187 t = (atan(-A.y + 0.002, A.x) + angle) * INVERSE_2PI; \n\
188 else \n\
189 t = (atan(-A.y, A.x) + angle) * INVERSE_2PI; \n\
190 return texture2D(brushTexture, vec2(t - floor(t), 0.5)); \n\
191 }\n";
195static const char*
const qopenglslPositionWithRadialGradientBrushVertexShader =
"\n\
196 attribute highp vec2 vertexCoordsArray;\n\
197 attribute highp vec3 pmvMatrix1; \n\
198 attribute highp vec3 pmvMatrix2; \n\
199 attribute highp vec3 pmvMatrix3; \n\
200 uniform mediump vec2 halfViewportSize; \n\
201 uniform highp mat3 brushTransform; \n\
202 uniform highp vec2 fmp; \n\
203 uniform mediump vec3 bradius; \n\
204 varying highp float b; \n\
205 varying highp vec2 A; \n\
206 void setPosition(void) \n\
207 {\n\
208 highp mat3 pmvMatrix = mat3(pmvMatrix1, pmvMatrix2, pmvMatrix3); \n\
209 vec3 transformedPos = pmvMatrix * vec3(vertexCoordsArray.xy, 1.0); \n\
210 gl_Position.xy = transformedPos.xy / transformedPos.z; \n\
211 mediump vec2 viewportCoords = (gl_Position.xy + 1.0) * halfViewportSize; \n\
212 mediump vec3 hTexCoords = brushTransform * vec3(viewportCoords, 1); \n\
213 mediump float invertedHTexCoordsZ = 1.0 / hTexCoords.z; \n\
214 gl_Position = vec4(gl_Position.xy * invertedHTexCoordsZ, 0.0, invertedHTexCoordsZ); \n\
215 A = hTexCoords.xy * invertedHTexCoordsZ; \n\
216 b = bradius.x + 2.0 * dot(A, fmp); \n\
220 = qopenglslPositionWithRadialGradientBrushVertexShader;
223 uniform sampler2D brushTexture; \n\
224 uniform highp float fmp2_m_radius2; \n\
225 uniform highp float inverse_2_fmp2_m_radius2; \n\
226 uniform highp float sqrfr; \n\
227 varying highp float b; \n\
228 varying highp vec2 A; \n\
229 uniform mediump vec3 bradius; \n\
230 lowp vec4 srcPixel() \n\
231 { \n\
232 highp float c = sqrfr-dot(A, A); \n\
233 highp float det = b*b - 4.0*fmp2_m_radius2*c; \n\
234 lowp vec4 result = vec4(0.0); \n\
235 if (det >= 0.0) { \n\
236 highp float detSqrt = sqrt(det); \n\
237 highp float w = max((-b - detSqrt) * inverse_2_fmp2_m_radius2, (-b + detSqrt) * inverse_2_fmp2_m_radius2); \n\
238 if (bradius.y + w * bradius.z >= 0.0) \n\
239 result = texture2D(brushTexture, vec2(w, 0.5)); \n\
240 } \n\
241 return result; \n\
242 }\n";
247 attribute highp vec2 vertexCoordsArray; \n\
248 attribute highp vec3 pmvMatrix1; \n\
249 attribute highp vec3 pmvMatrix2; \n\
250 attribute highp vec3 pmvMatrix3; \n\
251 uniform mediump vec2 halfViewportSize; \n\
252 uniform highp vec2 invertedTextureSize; \n\
253 uniform highp mat3 brushTransform; \n\
254 varying highp vec2 brushTextureCoords; \n\
255 void setPosition(void) \n\
256 { \n\
257 highp mat3 pmvMatrix = mat3(pmvMatrix1, pmvMatrix2, pmvMatrix3); \n\
258 vec3 transformedPos = pmvMatrix * vec3(vertexCoordsArray.xy, 1.0); \n\
259 gl_Position.xy = transformedPos.xy / transformedPos.z; \n\
260 mediump vec2 viewportCoords = (gl_Position.xy + 1.0) * halfViewportSize; \n\
261 mediump vec3 hTexCoords = brushTransform * vec3(viewportCoords, 1); \n\
262 mediump float invertedHTexCoordsZ = 1.0 / hTexCoords.z; \n\
263 gl_Position = vec4(gl_Position.xy * invertedHTexCoordsZ, 0.0, invertedHTexCoordsZ); \n\
264 brushTextureCoords.xy = (hTexCoords.xy * invertedTextureSize) * gl_Position.w; \n\
265 }\n";
271 varying highp vec2 brushTextureCoords; \n\
272 uniform sampler2D brushTexture; \n\
273 lowp vec4 srcPixel() \n\
274 { \n\
275 return texture2D(brushTexture, brushTextureCoords); \n\
276 }\n";
279 varying highp vec2 brushTextureCoords; \n\
280 uniform lowp vec4 patternColor; \n\
281 uniform sampler2D brushTexture; \n\
282 lowp vec4 srcPixel() \n\
283 { \n\
284 return patternColor * (1.0 - texture2D(brushTexture, brushTextureCoords).r); \n\
285 }\n";
289 uniform lowp vec4 fragmentColor; \n\
290 lowp vec4 srcPixel() \n\
291 { \n\
292 return fragmentColor; \n\
293 }\n";
296 varying highp vec2 textureCoords; \n\
297 uniform sampler2D imageTexture; \n\
298 lowp vec4 srcPixel() \n\
299 { \n"
300 "return texture2D(imageTexture, textureCoords); \n"
304 varying highp vec2 textureCoords; \n\
305 uniform sampler2D imageTexture; \n\
306 lowp vec4 srcPixel() \n\
307 { \n\
308 return customShader(imageTexture, textureCoords); \n\
309 }\n";
312 varying highp vec2 textureCoords; \n\
313 uniform lowp vec4 patternColor; \n\
314 uniform sampler2D imageTexture; \n\
315 lowp vec4 srcPixel() \n\
316 { \n\
317 return patternColor * (1.0 - texture2D(imageTexture, textureCoords).r); \n\
318 }\n";
321 varying highp vec2 textureCoords; \n\
322 uniform sampler2D imageTexture; \n\
323 lowp vec4 srcPixel() \n\
324 { \n\
325 lowp vec4 sample = texture2D(imageTexture, textureCoords); \n\
326 sample.rgb = sample.rgb * sample.a; \n\
327 return sample; \n\
328 }\n";
331 varying highp vec2 textureCoords; \n\
332 uniform sampler2D imageTexture; \n\
333 lowp vec4 srcPixel() \n\
334 { \n\
335 return texture2D(imageTexture, textureCoords).rrra; \n\
336 }\n";
339 varying highp vec2 textureCoords; \n\
340 uniform sampler2D imageTexture; \n\
341 lowp vec4 srcPixel() \n\
342 { \n\
343 return vec4(0, 0, 0, texture2D(imageTexture, textureCoords).r); \n\
344 }\n";
347 lowp vec4 srcPixel() \n\
348 { \n\
349 return vec4(0.98, 0.06, 0.75, 1.0); \n\
350 }\n";
353 varying lowp float opacity; \n\
354 lowp vec4 srcPixel(); \n\
355 void main() \n\
356 { \n\
357 gl_FragColor = srcPixel() * opacity; \n\
358 }\n";
361 uniform lowp float globalOpacity; \n\
362 lowp vec4 srcPixel(); \n\
363 lowp vec4 applyMask(lowp vec4); \n\
364 void main() \n\
365 { \n\
366 gl_FragColor = applyMask(srcPixel()*globalOpacity); \n\
367 }\n";
370 lowp vec4 srcPixel(); \n\
371 lowp vec4 applyMask(lowp vec4); \n\
372 void main() \n\
373 { \n\
374 gl_FragColor = applyMask(srcPixel()); \n\
375 }\n";
378 uniform lowp float globalOpacity; \n\
379 lowp vec4 srcPixel(); \n\
380 void main() \n\
381 { \n\
382 gl_FragColor = srcPixel()*globalOpacity; \n\
383 }\n";
386 lowp vec4 srcPixel(); \n\
387 void main() \n\
388 { \n\
389 gl_FragColor = srcPixel(); \n\
390 }\n";
393 varying highp vec2 textureCoords;\n\
394 uniform sampler2D maskTexture;\n\
395 lowp vec4 applyMask(lowp vec4 src) \n\
396 {\n\
397 lowp vec4 mask = texture2D(maskTexture, textureCoords); \n\
398 return src * mask.a; \n\
399 }\n";
417 varying highp vec2 textureCoords;\n\
418 uniform sampler2D maskTexture;\n\
419 lowp vec4 applyMask(lowp vec4 src) \n\
420 { \n\
421 lowp vec4 mask = texture2D(maskTexture, textureCoords); \n\
422 return src.a * mask; \n\
423 }\n";
426 varying highp vec2 textureCoords;\n\
427 uniform sampler2D maskTexture;\n\
428 lowp vec4 applyMask(lowp vec4 src) \n\
429 { \n\
430 lowp vec4 mask = texture2D(maskTexture, textureCoords); \n\
431 return src * mask; \n\
432 }\n";
434static const char*
const qopenglslMultiplyCompositionModeFragmentShader =
"\n\
435 #ifdef GL_KHR_blend_equation_advanced\n\
436 layout(blend_support_multiply) out;\n\
437 #endif\n";
439static const char*
const qopenglslScreenCompositionModeFragmentShader =
"\n\
440 #ifdef GL_KHR_blend_equation_advanced\n\
441 layout(blend_support_screen) out;\n\
442 #endif\n";
444static const char*
const qopenglslOverlayCompositionModeFragmentShader =
"\n\
445 #ifdef GL_KHR_blend_equation_advanced\n\
446 layout(blend_support_overlay) out;\n\
447 #endif\n";
449static const char*
const qopenglslDarkenCompositionModeFragmentShader =
"\n\
450 #ifdef GL_KHR_blend_equation_advanced\n\
451 layout(blend_support_darken) out;\n\
452 #endif\n";
454static const char*
const qopenglslLightenCompositionModeFragmentShader =
"\n\
455 #ifdef GL_KHR_blend_equation_advanced\n\
456 layout(blend_support_lighten) out;\n\
457 #endif\n";
459static const char*
const qopenglslColorDodgeCompositionModeFragmentShader =
"\n\
460 #ifdef GL_KHR_blend_equation_advanced\n\
461 layout(blend_support_colordodge) out;\n\
462 #endif\n";
464static const char*
const qopenglslColorBurnCompositionModeFragmentShader =
"\n\
465 #ifdef GL_KHR_blend_equation_advanced\n\
466 layout(blend_support_colorburn) out;\n\
467 #endif\n";
469static const char*
const qopenglslHardLightCompositionModeFragmentShader =
"\n\
470 #ifdef GL_KHR_blend_equation_advanced\n\
471 layout(blend_support_hardlight) out;\n\
472 #endif\n";
474static const char*
const qopenglslSoftLightCompositionModeFragmentShader =
"\n\
475 #ifdef GL_KHR_blend_equation_advanced\n\
476 layout(blend_support_softlight) out;\n\
477 #endif\n";
479static const char*
const qopenglslDifferenceCompositionModeFragmentShader =
"\n\
480 #ifdef GL_KHR_blend_equation_advanced\n\
481 layout(blend_support_difference) out;\n\
482 #endif\n";
484static const char*
const qopenglslExclusionCompositionModeFragmentShader =
"\n\
485 #ifdef GL_KHR_blend_equation_advanced\n\
486 layout(blend_support_exclusion) out;\n\
487 #endif\n";
490
491
492
493
496
497
498
499
500
501
502static const char*
const qopenglslMainVertexShader_core =
503 "#version 150 core\n\
504 void setPosition(); \n\
505 void main(void) \n\
506 { \n\
507 setPosition(); \n\
508 }\n";
510static const char*
const qopenglslMainWithTexCoordsVertexShader_core =
511 "#version 150 core\n\
512 in vec2 textureCoordArray; \n\
513 out vec2 textureCoords; \n\
514 void setPosition(); \n\
515 void main(void) \n\
516 { \n\
517 setPosition(); \n\
518 textureCoords = textureCoordArray; \n\
519 }\n";
521static const char*
const qopenglslMainWithTexCoordsAndOpacityVertexShader_core =
522 "#version 150 core\n\
523 in vec2 textureCoordArray; \n\
524 in float opacityArray; \n\
525 out vec2 textureCoords; \n\
526 out float opacity; \n\
527 void setPosition(); \n\
528 void main(void) \n\
529 { \n\
530 setPosition(); \n\
531 textureCoords = textureCoordArray; \n\
532 opacity = opacityArray; \n\
533 }\n";
537static const char*
const qopenglslPositionOnlyVertexShader_core =
"\n\
538 in vec2 vertexCoordsArray; \n\
539 in vec3 pmvMatrix1; \n\
540 in vec3 pmvMatrix2; \n\
541 in vec3 pmvMatrix3; \n\
542 void setPosition(void) \n\
543 { \n\
544 mat3 pmvMatrix = mat3(pmvMatrix1, pmvMatrix2, pmvMatrix3); \n\
545 vec3 transformedPos = pmvMatrix * vec3(vertexCoordsArray.xy, 1.0); \n\
546 gl_Position = vec4(transformedPos.xy, 0.0, transformedPos.z); \n\
547 }\n";
549static const char*
const qopenglslComplexGeometryPositionOnlyVertexShader_core =
"\n\
550 in vec2 vertexCoordsArray; \n\
551 uniform mat3 matrix; \n\
552 void setPosition(void) \n\
553 { \n\
554 gl_Position = vec4(matrix * vec3(vertexCoordsArray, 1), 1);\n\
555 } \n";
557static const char*
const qopenglslUntransformedPositionVertexShader_core =
"\n\
558 in vec4 vertexCoordsArray; \n\
559 void setPosition(void) \n\
560 { \n\
561 gl_Position = vertexCoordsArray; \n\
562 }\n";
565static const char*
const qopenglslPositionWithPatternBrushVertexShader_core =
"\n\
566 in vec2 vertexCoordsArray; \n\
567 in vec3 pmvMatrix1; \n\
568 in vec3 pmvMatrix2; \n\
569 in vec3 pmvMatrix3; \n\
570 out vec2 patternTexCoords; \n\
571 uniform vec2 halfViewportSize; \n\
572 uniform vec2 invertedTextureSize; \n\
573 uniform mat3 brushTransform; \n\
574 void setPosition(void) \n\
575 { \n\
576 mat3 pmvMatrix = mat3(pmvMatrix1, pmvMatrix2, pmvMatrix3); \n\
577 vec3 transformedPos = pmvMatrix * vec3(vertexCoordsArray.xy, 1.0); \n\
578 gl_Position.xy = transformedPos.xy / transformedPos.z; \n\
579 vec2 viewportCoords = (gl_Position.xy + 1.0) * halfViewportSize; \n\
580 vec3 hTexCoords = brushTransform * vec3(viewportCoords, 1.0); \n\
581 float invertedHTexCoordsZ = 1.0 / hTexCoords.z; \n\
582 gl_Position = vec4(gl_Position.xy * invertedHTexCoordsZ, 0.0, invertedHTexCoordsZ); \n\
583 patternTexCoords.xy = (hTexCoords.xy * 0.125) * invertedHTexCoordsZ; \n\
584 }\n";
586static const char*
const qopenglslAffinePositionWithPatternBrushVertexShader_core
587 = qopenglslPositionWithPatternBrushVertexShader_core;
589static const char*
const qopenglslPatternBrushSrcFragmentShader_core =
"\n\
590 in vec2 patternTexCoords;\n\
591 uniform sampler2D brushTexture; \n\
592 uniform vec4 patternColor; \n\
593 vec4 srcPixel() \n\
594 { \n\
595 return patternColor * (1.0 - texture(brushTexture, patternTexCoords).r); \n\
596 }\n";
600static const char*
const qopenglslPositionWithLinearGradientBrushVertexShader_core =
"\n\
601 in vec2 vertexCoordsArray; \n\
602 in vec3 pmvMatrix1; \n\
603 in vec3 pmvMatrix2; \n\
604 in vec3 pmvMatrix3; \n\
605 out float index; \n\
606 uniform vec2 halfViewportSize; \n\
607 uniform vec3 linearData; \n\
608 uniform mat3 brushTransform; \n\
609 void setPosition() \n\
610 { \n\
611 mat3 pmvMatrix = mat3(pmvMatrix1, pmvMatrix2, pmvMatrix3); \n\
612 vec3 transformedPos = pmvMatrix * vec3(vertexCoordsArray.xy, 1.0); \n\
613 gl_Position.xy = transformedPos.xy / transformedPos.z; \n\
614 vec2 viewportCoords = (gl_Position.xy + 1.0) * halfViewportSize; \n\
615 vec3 hTexCoords = brushTransform * vec3(viewportCoords, 1); \n\
616 float invertedHTexCoordsZ = 1.0 / hTexCoords.z; \n\
617 gl_Position = vec4(gl_Position.xy * invertedHTexCoordsZ, 0.0, invertedHTexCoordsZ); \n\
618 index = (dot(linearData.xy, hTexCoords.xy) * linearData.z) * invertedHTexCoordsZ; \n\
619 }\n";
621static const char*
const qopenglslAffinePositionWithLinearGradientBrushVertexShader_core
622 = qopenglslPositionWithLinearGradientBrushVertexShader_core;
624static const char*
const qopenglslLinearGradientBrushSrcFragmentShader_core =
"\n\
625 uniform sampler2D brushTexture; \n\
626 in float index; \n\
627 vec4 srcPixel() \n\
628 { \n\
629 vec2 val = vec2(index, 0.5); \n\
630 return texture(brushTexture, val); \n\
631 }\n";
635static const char*
const qopenglslPositionWithConicalGradientBrushVertexShader_core =
"\n\
636 in vec2 vertexCoordsArray; \n\
637 in vec3 pmvMatrix1; \n\
638 in vec3 pmvMatrix2; \n\
639 in vec3 pmvMatrix3; \n\
640 out vec2 A; \n\
641 uniform vec2 halfViewportSize; \n\
642 uniform mat3 brushTransform; \n\
643 void setPosition(void) \n\
644 { \n\
645 mat3 pmvMatrix = mat3(pmvMatrix1, pmvMatrix2, pmvMatrix3); \n\
646 vec3 transformedPos = pmvMatrix * vec3(vertexCoordsArray.xy, 1.0); \n\
647 gl_Position.xy = transformedPos.xy / transformedPos.z; \n\
648 vec2 viewportCoords = (gl_Position.xy + 1.0) * halfViewportSize; \n\
649 vec3 hTexCoords = brushTransform * vec3(viewportCoords, 1); \n\
650 float invertedHTexCoordsZ = 1.0 / hTexCoords.z; \n\
651 gl_Position = vec4(gl_Position.xy * invertedHTexCoordsZ, 0.0, invertedHTexCoordsZ); \n\
652 A = hTexCoords.xy * invertedHTexCoordsZ; \n\
653 }\n";
655static const char*
const qopenglslAffinePositionWithConicalGradientBrushVertexShader_core
656 = qopenglslPositionWithConicalGradientBrushVertexShader_core;
658static const char*
const qopenglslConicalGradientBrushSrcFragmentShader_core =
"\n\
659 #define INVERSE_2PI 0.1591549430918953358 \n\
660 in vec2 A; \n\
661 uniform sampler2D brushTexture; \n\
662 uniform float angle; \n\
663 vec4 srcPixel() \n\
664 { \n\
665 float t; \n\
666 if (abs(A.y) == abs(A.x)) \n\
667 t = (atan(-A.y + 0.002, A.x) + angle) * INVERSE_2PI; \n\
668 else \n\
669 t = (atan(-A.y, A.x) + angle) * INVERSE_2PI; \n\
670 return texture(brushTexture, vec2(t - floor(t), 0.5)); \n\
671 }\n";
675static const char*
const qopenglslPositionWithRadialGradientBrushVertexShader_core =
"\n\
676 in vec2 vertexCoordsArray;\n\
677 in vec3 pmvMatrix1; \n\
678 in vec3 pmvMatrix2; \n\
679 in vec3 pmvMatrix3; \n\
680 out float b; \n\
681 out vec2 A; \n\
682 uniform vec2 halfViewportSize; \n\
683 uniform mat3 brushTransform; \n\
684 uniform vec2 fmp; \n\
685 uniform vec3 bradius; \n\
686 void setPosition(void) \n\
687 {\n\
688 mat3 pmvMatrix = mat3(pmvMatrix1, pmvMatrix2, pmvMatrix3); \n\
689 vec3 transformedPos = pmvMatrix * vec3(vertexCoordsArray.xy, 1.0); \n\
690 gl_Position.xy = transformedPos.xy / transformedPos.z; \n\
691 vec2 viewportCoords = (gl_Position.xy + 1.0) * halfViewportSize; \n\
692 vec3 hTexCoords = brushTransform * vec3(viewportCoords, 1); \n\
693 float invertedHTexCoordsZ = 1.0 / hTexCoords.z; \n\
694 gl_Position = vec4(gl_Position.xy * invertedHTexCoordsZ, 0.0, invertedHTexCoordsZ); \n\
695 A = hTexCoords.xy * invertedHTexCoordsZ; \n\
696 b = bradius.x + 2.0 * dot(A, fmp); \n\
697 }\n";
699static const char*
const qopenglslAffinePositionWithRadialGradientBrushVertexShader_core
700 = qopenglslPositionWithRadialGradientBrushVertexShader_core;
702static const char*
const qopenglslRadialGradientBrushSrcFragmentShader_core =
"\n\
703 in float b; \n\
704 in vec2 A; \n\
705 uniform sampler2D brushTexture; \n\
706 uniform float fmp2_m_radius2; \n\
707 uniform float inverse_2_fmp2_m_radius2; \n\
708 uniform float sqrfr; \n\
709 uniform vec3 bradius; \n\
710 \n\
711 vec4 srcPixel() \n\
712 { \n\
713 float c = sqrfr-dot(A, A); \n\
714 float det = b*b - 4.0*fmp2_m_radius2*c; \n\
715 vec4 result = vec4(0.0); \n\
716 if (det >= 0.0) { \n\
717 float detSqrt = sqrt(det); \n\
718 float w = max((-b - detSqrt) * inverse_2_fmp2_m_radius2, (-b + detSqrt) * inverse_2_fmp2_m_radius2); \n\
719 if (bradius.y + w * bradius.z >= 0.0) \n\
720 result = texture(brushTexture, vec2(w, 0.5)); \n\
721 } \n\
722 return result; \n\
723 }\n";
727static const char*
const qopenglslPositionWithTextureBrushVertexShader_core =
"\n\
728 in vec2 vertexCoordsArray; \n\
729 in vec3 pmvMatrix1; \n\
730 in vec3 pmvMatrix2; \n\
731 in vec3 pmvMatrix3; \n\
732 out vec2 brushTextureCoords; \n\
733 uniform vec2 halfViewportSize; \n\
734 uniform vec2 invertedTextureSize; \n\
735 uniform mat3 brushTransform; \n\
736 \n\
737 void setPosition(void) \n\
738 { \n\
739 mat3 pmvMatrix = mat3(pmvMatrix1, pmvMatrix2, pmvMatrix3); \n\
740 vec3 transformedPos = pmvMatrix * vec3(vertexCoordsArray.xy, 1.0); \n\
741 gl_Position.xy = transformedPos.xy / transformedPos.z; \n\
742 vec2 viewportCoords = (gl_Position.xy + 1.0) * halfViewportSize; \n\
743 vec3 hTexCoords = brushTransform * vec3(viewportCoords, 1); \n\
744 float invertedHTexCoordsZ = 1.0 / hTexCoords.z; \n\
745 gl_Position = vec4(gl_Position.xy * invertedHTexCoordsZ, 0.0, invertedHTexCoordsZ); \n\
746 brushTextureCoords.xy = (hTexCoords.xy * invertedTextureSize) * gl_Position.w; \n\
747 }\n";
749static const char*
const qopenglslAffinePositionWithTextureBrushVertexShader_core
750 = qopenglslPositionWithTextureBrushVertexShader_core;
752static const char*
const qopenglslTextureBrushSrcFragmentShader_core =
"\n\
753 in vec2 brushTextureCoords; \n\
754 uniform sampler2D brushTexture; \n\
755 vec4 srcPixel() \n\
756 { \n\
757 return texture(brushTexture, brushTextureCoords); \n\
758 }\n";
760static const char*
const qopenglslTextureBrushSrcWithPatternFragmentShader_core =
"\n\
761 in vec2 brushTextureCoords; \n\
762 uniform vec4 patternColor; \n\
763 uniform sampler2D brushTexture; \n\
764 vec4 srcPixel() \n\
765 { \n\
766 return patternColor * (1.0 - texture(brushTexture, brushTextureCoords).r); \n\
767 }\n";
770static const char*
const qopenglslSolidBrushSrcFragmentShader_core =
"\n\
771 uniform vec4 fragmentColor; \n\
772 vec4 srcPixel() \n\
773 { \n\
774 return fragmentColor; \n\
775 }\n";
777static const char*
const qopenglslImageSrcFragmentShader_core =
"\n\
778 in vec2 textureCoords; \n\
779 uniform sampler2D imageTexture; \n\
780 vec4 srcPixel() \n\
781 { \n\
782 return texture(imageTexture, textureCoords); \n\
783 }\n";
785static const char*
const qopenglslCustomSrcFragmentShader_core =
"\n\
786 in vec2 textureCoords; \n\
787 uniform sampler2D imageTexture; \n\
788 vec4 srcPixel() \n\
789 { \n\
790 return customShader(imageTexture, textureCoords); \n\
791 }\n";
793static const char*
const qopenglslImageSrcWithPatternFragmentShader_core =
"\n\
794 in vec2 textureCoords; \n\
795 uniform vec4 patternColor; \n\
796 uniform sampler2D imageTexture; \n\
797 vec4 srcPixel() \n\
798 { \n\
799 return patternColor * (1.0 - texture(imageTexture, textureCoords).r); \n\
800 }\n";
802static const char*
const qopenglslNonPremultipliedImageSrcFragmentShader_core =
"\n\
803 in vec2 textureCoords; \n\
804 uniform sampler2D imageTexture; \n\
805 vec4 srcPixel() \n\
806 { \n\
807 vec4 sample = texture(imageTexture, textureCoords); \n\
808 sample.rgb = sample.rgb * sample.a; \n\
809 return sample; \n\
810 }\n";
812static const char*
const qopenglslGrayscaleImageSrcFragmentShader_core =
"\n\
813 in vec2 textureCoords; \n\
814 uniform sampler2D imageTexture; \n\
815 vec4 srcPixel() \n\
816 { \n\
817 return texture(imageTexture, textureCoords).rrra; \n\
818 }\n";
820static const char*
const qopenglslAlphaImageSrcFragmentShader_core =
"\n\
821 in vec2 textureCoords; \n\
822 uniform sampler2D imageTexture; \n\
823 vec4 srcPixel() \n\
824 { \n\
825 return vec4(0, 0, 0, texture(imageTexture, textureCoords).r); \n\
826 }\n";
828static const char*
const qopenglslShockingPinkSrcFragmentShader_core =
"\n\
829 vec4 srcPixel() \n\
830 { \n\
831 return vec4(0.98, 0.06, 0.75, 1.0); \n\
832 }\n";
834static const char*
const qopenglslMainFragmentShader_ImageArrays_core =
835 "#version 150 core\n\
836 in float opacity; \n\
837 out vec4 fragColor; \n\
838 vec4 srcPixel(); \n\
839 void main() \n\
840 { \n\
841 fragColor = srcPixel() * opacity; \n\
842 }\n";
844static const char*
const qopenglslMainFragmentShader_MO_core =
845 "#version 150 core\n\
846 out vec4 fragColor; \n\
847 uniform float globalOpacity; \n\
848 vec4 srcPixel(); \n\
849 vec4 applyMask(vec4); \n\
850 void main() \n\
851 { \n\
852 fragColor = applyMask(srcPixel()*globalOpacity); \n\
853 }\n";
855static const char*
const qopenglslMainFragmentShader_M_core =
856 "#version 150 core\n\
857 out vec4 fragColor; \n\
858 vec4 srcPixel(); \n\
859 vec4 applyMask(vec4); \n\
860 void main() \n\
861 { \n\
862 fragColor = applyMask(srcPixel()); \n\
863 }\n";
865static const char*
const qopenglslMainFragmentShader_O_core =
866 "#version 150 core\n\
867 out vec4 fragColor; \n\
868 uniform float globalOpacity; \n\
869 vec4 srcPixel(); \n\
870 void main() \n\
871 { \n\
872 fragColor = srcPixel()*globalOpacity; \n\
873 }\n";
875static const char*
const qopenglslMainFragmentShader_core =
876 "#version 150 core\n\
877 out vec4 fragColor; \n\
878 vec4 srcPixel(); \n\
879 void main() \n\
880 { \n\
881 fragColor = srcPixel(); \n\
882 }\n";
884static const char*
const qopenglslMaskFragmentShader_core =
"\n\
885 in vec2 textureCoords;\n\
886 uniform sampler2D maskTexture;\n\
887 vec4 applyMask(vec4 src) \n\
888 {\n\
889 vec4 mask = texture(maskTexture, textureCoords); \n\
890 return src * mask.r; \n\
891 }\n";
908static const char*
const qopenglslRgbMaskFragmentShaderPass1_core =
"\n\
909 in vec2 textureCoords;\n\
910 uniform sampler2D maskTexture;\n\
911 vec4 applyMask(vec4 src) \n\
912 { \n\
913 vec4 mask = texture(maskTexture, textureCoords); \n\
914 return src.a * mask; \n\
915 }\n";
917static const char*
const qopenglslRgbMaskFragmentShaderPass2_core =
"\n\
918 in vec2 textureCoords;\n\
919 uniform sampler2D maskTexture;\n\
920 vec4 applyMask(vec4 src) \n\
921 { \n\
922 vec4 mask = texture(maskTexture, textureCoords); \n\
923 return src * mask; \n\
924 }\n";
927
928
929
930
QOpenGLEngineSharedShaders * shadersForThread(QOpenGLContext *context)
Combined button and popup list for selecting options.
Q_GLOBAL_STATIC(QOpenGLShaderStorage, qt_shader_storage)
static const char *const qopenglslConicalGradientBrushSrcFragmentShader
static QT_BEGIN_NAMESPACE const char *const qopenglslMainVertexShader
static const char *const qopenglslPatternBrushSrcFragmentShader
static const char *const qopenglslMainFragmentShader_M
static const char *const qopenglslPositionWithConicalGradientBrushVertexShader
static const char *const qopenglslImageSrcWithPatternFragmentShader
static const char *const qopenglslSolidBrushSrcFragmentShader
static const char *const qopenglslImageSrcFragmentShader
static const char *const qopenglslAffinePositionWithLinearGradientBrushVertexShader
static const char *const qopenglslMainFragmentShader_ImageArrays
static const char *const qopenglslAlphaImageSrcFragmentShader
static const char *const qopenglslLinearGradientBrushSrcFragmentShader
static const char *const qopenglslPositionOnlyVertexShader
static const char *const qopenglslShockingPinkSrcFragmentShader
static const char *const qopenglslPositionWithPatternBrushVertexShader
static const char *const qopenglslMainFragmentShader_MO
static const char *const qopenglslMainWithTexCoordsAndOpacityVertexShader
static const char *const qopenglslRgbMaskFragmentShaderPass2
static const char *const qopenglslRgbMaskFragmentShaderPass1
static const char *const qopenglslCustomSrcFragmentShader
static const char *const qopenglslAffinePositionWithRadialGradientBrushVertexShader
static const char *const qopenglslGrayscaleImageSrcFragmentShader
static const char *const qopenglslAffinePositionWithTextureBrushVertexShader
static const char *const qopenglslAffinePositionWithConicalGradientBrushVertexShader
static const char *const qopenglslUntransformedPositionVertexShader
static const char *const qopenglslMainFragmentShader
static const char *const qopenglslAffinePositionWithPatternBrushVertexShader
static const char *const qopenglslTextureBrushSrcWithPatternFragmentShader
static const char *const qopenglslRadialGradientBrushSrcFragmentShader
static const char *const qopenglslTextureBrushSrcFragmentShader
static const char *const qopenglslMainFragmentShader_O
static const char *const qopenglslPositionWithLinearGradientBrushVertexShader
static const char *const qopenglslComplexGeometryPositionOnlyVertexShader
static const char *const qopenglslMaskFragmentShader
static const char *const qopenglslPositionWithTextureBrushVertexShader
static const char *const qopenglslMainWithTexCoordsVertexShader
static const char *const qopenglslNonPremultipliedImageSrcFragmentShader
#define QT_MASK_TEXTURE_UNIT