update
This commit is contained in:
17
main.cpp
17
main.cpp
@@ -215,6 +215,10 @@ private:
|
||||
glBindVertexArray(0);
|
||||
}
|
||||
|
||||
void initHeatmapGeometry_() {
|
||||
|
||||
}
|
||||
|
||||
bool initBgProgram() {
|
||||
auto vshader = std::make_unique<LOpenGLShader>(LOpenGLShader::ShaderType::Vertex);
|
||||
auto fshader = std::make_unique<LOpenGLShader>(LOpenGLShader::ShaderType::Fragment);
|
||||
@@ -275,6 +279,12 @@ private:
|
||||
return true;
|
||||
}
|
||||
|
||||
bool initHeatmapProgram() {
|
||||
auto vshader = std::make_unique<LOpenGLShader>(LOpenGLShader::ShaderType::Vertex);
|
||||
auto fshader = std::make_unique<LOpenGLShader>(LOpenGLShader::ShaderType::Fragment);
|
||||
|
||||
}
|
||||
|
||||
void drawBg() {
|
||||
if (!bgProg_ || !bgVao_ || !bgVbo_) {
|
||||
std::cout << "check !bgProg_ || !bgVao_ || !bgVbo_ failed\n";
|
||||
@@ -291,7 +301,7 @@ private:
|
||||
glBindVertexArray(0);
|
||||
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
}
|
||||
}
|
||||
|
||||
void drawPanel() {
|
||||
if (!panelProg_ || !panelVao_ || !panelVbo_ || !panelIbo_) {
|
||||
@@ -435,6 +445,11 @@ private:
|
||||
float panelHeight_ = 0.35;
|
||||
float panelDepth_ = 0.05;
|
||||
|
||||
std::unique_ptr<LOpenGLProgram> heatmapProg_;
|
||||
std::string heatmapVertShaderPath_;
|
||||
std::string heatmapFragShaderPath_;
|
||||
unsigned int heatmapVao_ = 0;
|
||||
unsigned int heatmapVbo_ = 0;
|
||||
|
||||
ViewPort viewport_{800, 600};
|
||||
Camera camera_{glm::vec3(0.0f, 0.0f, 2.0f)};
|
||||
|
||||
@@ -62,41 +62,37 @@ float maxNeighborValue(vec2 uv) {
|
||||
return max(max(v00, v10), max(v01, v11));
|
||||
}
|
||||
|
||||
float maxNeighborValue3(vec2 uv) {
|
||||
vec2 texSizeF = 1.0 / uTexelSize;
|
||||
ivec2 texSizeI(vec2 texelSize) {
|
||||
vec2 texSizeF = 1.0 / texelSize;
|
||||
ivec2 texSizeI = ivec2(max(vec2(1.0), floor(texSizeF + 0.5)));
|
||||
ivec2 maxCoord = texSizeI - ivec2(1);
|
||||
return texSizeI;
|
||||
}
|
||||
|
||||
vec2 texelF = clamp(uv * texSizeF, vec2(0.0), vec2(maxCoord));
|
||||
ivec2 base = ivec2(floor(texelF));
|
||||
ivec2 base10 = min(base + ivec2(1, 0), maxCoord);
|
||||
ivec2 base20 = min(base + ivec2(2, 0), maxCoord);
|
||||
ivec2 base01 = min(base + ivec2(0, 1), maxCoord);
|
||||
ivec2 base11 = min(base + ivec2(1, 1), maxCoord);
|
||||
ivec2 base21 = min(base + ivec2(2, 1), maxCoord);
|
||||
ivec2 base02 = min(base + ivec2(0, 2), maxCoord);
|
||||
ivec2 base12 = min(base + ivec2(1, 2), maxCoord);
|
||||
ivec2 base22 = min(base + ivec2(2, 2), maxCoord);
|
||||
ivec2 uvToTexel(vec2 uv, vec2 texelSize) {
|
||||
ivec2 sizeI = texSizeI(texelSize);
|
||||
ivec2 maxCoord = sizeI - ivec2(1);
|
||||
vec2 texelF = clamp(uv * vec2(maxCoord), vec2(0.0), vec2(maxCoord));
|
||||
return ivec2(floor(texelF));
|
||||
}
|
||||
|
||||
float v00 = texelFetch(uHeightTex, base, 0).r;
|
||||
float v10 = texelFetch(uHeightTex, base10, 0).r;
|
||||
float v20 = texelFetch(uHeightTex, base20, 0).r;
|
||||
float v01 = texelFetch(uHeightTex, base01, 0).r;
|
||||
float v11 = texelFetch(uHeightTex, base11, 0).r;
|
||||
float v21 = texelFetch(uHeightTex, base21, 0).r;
|
||||
float v02 = texelFetch(uHeightTex, base02, 0).r;
|
||||
float v12 = texelFetch(uHeightTex, base12, 0).r;
|
||||
float v22 = texelFetch(uHeightTex, base22, 0).r;
|
||||
float maxNeighborValueK(vec2 uv, int radius) {
|
||||
radius = clamp(radius, 0, 4);
|
||||
ivec2 sizeI = texSizeI(uTexelSize);
|
||||
ivec2 maxCoord = sizeI - ivec2(1);
|
||||
ivec2 p = uvToTexel(uv, uTexelSize);
|
||||
|
||||
float max1020 = max(v10, v20);
|
||||
float max0111 = max(v01, v11);
|
||||
float max2102 = max(v21, v02);
|
||||
float max1222 = max(v12, v22);
|
||||
float vmax = -1e30;
|
||||
|
||||
float fmax1 = max(max1020, max0111);
|
||||
float fmax2 = max(max2102, max1222);
|
||||
for (int i = -4; i <= 4; ++i) {
|
||||
for (int j = -4; j <= 4; ++j) {
|
||||
if (abs(i) > radius || abs(j) > radius) continue;
|
||||
ivec2 c = clamp(p + ivec2(i, j), ivec2(0), maxCoord);
|
||||
float v = texelFetch(uHeightTex, c, 0).r;
|
||||
vmax = max(vmax, v);
|
||||
}
|
||||
}
|
||||
|
||||
return max(v00, max(fmax1, fmax2));
|
||||
return vmax;
|
||||
}
|
||||
|
||||
vec3 colorRamp(float t) {
|
||||
|
||||
Reference in New Issue
Block a user