Add slider for tessellation factor

This commit is contained in:
Jack Christensen 2024-08-17 19:05:05 -04:00
parent a45473c77e
commit 025f442686
3 changed files with 13 additions and 6 deletions

View File

@ -4,8 +4,8 @@ Size=400,400
Collapsed=0
[Window][Terrain Controls]
Pos=933,19
Size=347,701
Pos=856,19
Size=424,701
Collapsed=0
DockId=0x00000002,0
@ -24,12 +24,12 @@ Collapsed=0
[Window][Scene Window]
Pos=0,19
Size=931,701
Size=854,701
Collapsed=0
DockId=0x00000001,0
[Docking][Data]
DockSpace ID=0x6F42A598 Window=0xE80F322C Pos=0,19 Size=1280,701 Split=X Selected=0x9F2D9299
DockNode ID=0x00000001 Parent=0x6F42A598 SizeRef=931,701 CentralNode=1 Selected=0x9F2D9299
DockNode ID=0x00000002 Parent=0x6F42A598 SizeRef=347,701 Selected=0xF69494A7
DockNode ID=0x00000001 Parent=0x6F42A598 SizeRef=854,701 CentralNode=1 Selected=0x9F2D9299
DockNode ID=0x00000002 Parent=0x6F42A598 SizeRef=424,701 Selected=0xF69494A7

View File

@ -12,7 +12,7 @@ out TC_OUT {
vec2 texCoord;
} tc_out[];
uniform float tessellationFactor = 64.0f;
uniform float tessellationFactor;
void main() {
// Pass through position and texture coordinates to the tessellation evaluation shader

View File

@ -39,6 +39,8 @@ const std::string kHGTPath = "hgt/N02E016.hgt";
GLuint tex_id = -1;
float tessellationFactor = 1.0f;
std::vector<Vertex> vertices;
std::vector<GLuint> indices;
@ -222,6 +224,9 @@ void Scene::Display(GLFWwindow* window) {
GLint heightTextureLoc = glGetUniformLocation(shader_program_, "heightTexture");
glUniform1i(heightTextureLoc, 0);
GLint tessFactorLoc = glGetUniformLocation(shader_program_, "tessellationFactor");
glUniform1f(tessFactorLoc, tessellationFactor);
glBindVertexArray(vao_);
glPatchParameteri(GL_PATCH_VERTICES, 4);
glDrawElements(GL_PATCHES, indices.size(), GL_UNSIGNED_INT, 0);
@ -308,6 +313,8 @@ void Scene::DrawGui(GLFWwindow* window) {
}
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
ImGui::SliderFloat("Tessellation Level", &tessellationFactor, 1.0f, 64.0f);
ImGui::End();
// Draw FBO to ImGui window