/********************************************************************* * * file: gles_canvas_shaders.h * note: string literals auto-generated by embed_text.py * date: 02/022023 * **********************************************************************/ #ifndef __GLES_CANVAS_SHADERS_H__ #define __GLES_CANVAS_SHADERS_H__ //NOTE: string imported from src\gles_canvas_shaders\gles_canvas_fragment.glsl const char* gles_canvas_fragment = "#version 310 es\n" "\n" "precision mediump float;\n" "layout(std430) buffer;\n" "\n" "struct vertex {\n" " vec2 pos;\n" " vec4 cubic;\n" " vec2 uv;\n" " vec4 color;\n" " vec4 clip;\n" " int zIndex;\n" "};\n" "\n" "layout(binding = 0) buffer vertexBufferSSBO {\n" " vertex elements[];\n" "} vertexBuffer ;\n" "\n" "layout(binding = 1) buffer indexBufferSSBO {\n" " uint elements[];\n" "} indexBuffer ;\n" "\n" "layout(location = 0) uniform int indexCount;\n" "\n" "layout(location = 0) out vec4 fragColor;\n" "\n" "bool is_top_left(ivec2 a, ivec2 b)\n" "{\n" " return( (a.y == b.y && b.x < a.x)\n" " ||(b.y < a.y));\n" "}\n" "\n" "int orient2d(ivec2 a, ivec2 b, ivec2 p)\n" "{\n" " return((b.x-a.x)*(p.y-a.y) - (b.y-a.y)*(p.x-a.x));\n" "}\n" "\n" "void main()\n" "{\n" " const float subPixelFactor = 16.;\n" " const int sampleCount = 8;\n" "\n" " ivec2 centerPoint = ivec2(round(gl_FragCoord.xy * subPixelFactor));\n" " ivec2 samplePoints[sampleCount] = ivec2[sampleCount](centerPoint + ivec2(1, 3),\n" " centerPoint + ivec2(-1, -3),\n" " centerPoint + ivec2(5, -1),\n" " centerPoint + ivec2(-3, 5),\n" " centerPoint + ivec2(-5, -5),\n" " centerPoint + ivec2(-7, 1),\n" " centerPoint + ivec2(3, -7),\n" " centerPoint + ivec2(7, 7));\n" "\n" " vec4 sampleColor[sampleCount];\n" " vec4 currentColor[sampleCount];\n" " int currentZIndex[sampleCount];\n" " int flipCount[sampleCount];\n" "\n" " for(int i=0; i= 0 && (w1+bias1) >= 0 && (w2+bias2) >= 0)\n" " {\n" " vec4 cubic = (cubic0*float(w0) + cubic1*float(w1) + cubic2*float(w2))/(float(w0)+float(w1)+float(w2));\n" "\n" " float eps = 0.0001;\n" " if(cubic.w*(cubic.x*cubic.x*cubic.x - cubic.y*cubic.z) <= eps)\n" " {\n" " if(zIndex == currentZIndex[sampleIndex])\n" " {\n" " flipCount[sampleIndex]++;\n" " }\n" " else\n" " {\n" " if((flipCount[sampleIndex] & 0x01) != 0)\n" " {\n" " sampleColor[sampleIndex] = currentColor[sampleIndex];\n" " }\n" " currentColor[sampleIndex] = sampleColor[sampleIndex]*(1.-color.a) + color.a*color;\n" " currentZIndex[sampleIndex] = zIndex;\n" " flipCount[sampleIndex] = 1;\n" " }\n" " }\n" " }\n" " }\n" " }\n" " vec4 pixelColor = vec4(0);\n" " for(int sampleIndex = 0; sampleIndex < sampleCount; sampleIndex++)\n" " {\n" " if((flipCount[sampleIndex] & 0x01) != 0)\n" " {\n" " sampleColor[sampleIndex] = currentColor[sampleIndex];\n" " }\n" " pixelColor += sampleColor[sampleIndex];\n" " }\n" " fragColor = pixelColor/float(sampleCount);\n" "}\n"; //NOTE: string imported from src\gles_canvas_shaders\gles_canvas_vertex.glsl const char* gles_canvas_vertex = "#version 310 es\n" "\n" "precision mediump float;\n" "\n" "void main()\n" "{\n" " float x = float(((uint(gl_VertexID) + 2u) / 3u)%2u);\n" " float y = float(((uint(gl_VertexID) + 1u) / 3u)%2u);\n" "\n" " gl_Position = vec4(-1.0f + x*2.0f, -1.0f+y*2.0f, 0.0f, 1.0f);\n" "}\n"; #endif // __GLES_CANVAS_SHADERS_H__