Files
cocos-engine/editor/assets/effects/util/profiler.effect
2022-02-22 16:19:15 +08:00

75 lines
1.6 KiB
Plaintext

// Copyright (c) 2017-2020 Xiamen Yaji Software Co., Ltd.
CCEffect %{
techniques:
- passes:
- vert: profiler-vs:vert
frag: profiler-fs:frag
priority: max
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 <cc-global>
#pragma define ROWS 8 // multiple of 4
#pragma define COLS 10
#pragma 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 () {
mat2 proj = mat2(cc_matProj[0].xy, cc_matProj[1].xy);
proj /= abs(proj[1].x + proj[1].y);
vec2 position = proj * a_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 vec4(position, 0.0, 1.0);
}
}%
CCProgram profiler-fs %{
precision mediump float;
#include <output>
in vec2 v_uv;
uniform sampler2D mainTexture;
vec4 frag () {
return CCFragOutput(texture(mainTexture, v_uv));
}
}%