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