// Copyright (c) 2017-2020 Xiamen Yaji Software Co., Ltd. CCEffect %{ techniques: - passes: - vert: profiler-vs:vert frag: profiler-fs:frag depthStencilState: depthTest: false depthWrite: false blendState: targets: - blend: true blendSrc: src_alpha blendDst: one_minus_src_alpha blendDstAlpha: one_minus_src_alpha rasterizerState: cullMode: none }% CCProgram profiler-vs %{ precision mediump float; #include #define ROWS 8 // multiple of 4 #define COLS 10 #define VECTOR_COUNT ROWS * COLS / 4 in vec3 a_position; in vec4 a_color; out vec2 v_uv; uniform Constants { vec4 offset; // xy: bottom-left corner offset, z: symbol width }; uniform PerFrameInfo { vec4 digits[VECTOR_COUNT]; }; float getComponent(vec4 v, float i) { if (i < 1.0) { return v.x; } else if (i < 2.0) { return v.y; } else if (i < 3.0) { return v.z; } else { return v.w; } } vec4 vert () { vec4 position = cc_matViewProj * vec4(a_position, 1.0); position.xy += offset.xy; v_uv = a_color.xy; if (a_color.z >= 0.0) { float n = getComponent(digits[int(a_color.z)], a_color.w); v_uv += vec2(offset.z * n, 0.0); } return position; } }% CCProgram profiler-fs %{ precision mediump float; #include in vec2 v_uv; uniform sampler2D mainTexture; vec4 frag () { return CCFragOutput(texture(mainTexture, v_uv)); } }%