Add slider for tessellation factor
This commit is contained in:
parent
a45473c77e
commit
025f442686
10
imgui.ini
10
imgui.ini
|
@ -4,8 +4,8 @@ Size=400,400
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
|
|
||||||
[Window][Terrain Controls]
|
[Window][Terrain Controls]
|
||||||
Pos=933,19
|
Pos=856,19
|
||||||
Size=347,701
|
Size=424,701
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000002,0
|
DockId=0x00000002,0
|
||||||
|
|
||||||
|
@ -24,12 +24,12 @@ Collapsed=0
|
||||||
|
|
||||||
[Window][Scene Window]
|
[Window][Scene Window]
|
||||||
Pos=0,19
|
Pos=0,19
|
||||||
Size=931,701
|
Size=854,701
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000001,0
|
DockId=0x00000001,0
|
||||||
|
|
||||||
[Docking][Data]
|
[Docking][Data]
|
||||||
DockSpace ID=0x6F42A598 Window=0xE80F322C Pos=0,19 Size=1280,701 Split=X Selected=0x9F2D9299
|
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=0x00000001 Parent=0x6F42A598 SizeRef=854,701 CentralNode=1 Selected=0x9F2D9299
|
||||||
DockNode ID=0x00000002 Parent=0x6F42A598 SizeRef=347,701 Selected=0xF69494A7
|
DockNode ID=0x00000002 Parent=0x6F42A598 SizeRef=424,701 Selected=0xF69494A7
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ out TC_OUT {
|
||||||
vec2 texCoord;
|
vec2 texCoord;
|
||||||
} tc_out[];
|
} tc_out[];
|
||||||
|
|
||||||
uniform float tessellationFactor = 64.0f;
|
uniform float tessellationFactor;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
// Pass through position and texture coordinates to the tessellation evaluation shader
|
// Pass through position and texture coordinates to the tessellation evaluation shader
|
||||||
|
|
|
@ -39,6 +39,8 @@ const std::string kHGTPath = "hgt/N02E016.hgt";
|
||||||
|
|
||||||
GLuint tex_id = -1;
|
GLuint tex_id = -1;
|
||||||
|
|
||||||
|
float tessellationFactor = 1.0f;
|
||||||
|
|
||||||
std::vector<Vertex> vertices;
|
std::vector<Vertex> vertices;
|
||||||
std::vector<GLuint> indices;
|
std::vector<GLuint> indices;
|
||||||
|
|
||||||
|
@ -222,6 +224,9 @@ void Scene::Display(GLFWwindow* window) {
|
||||||
GLint heightTextureLoc = glGetUniformLocation(shader_program_, "heightTexture");
|
GLint heightTextureLoc = glGetUniformLocation(shader_program_, "heightTexture");
|
||||||
glUniform1i(heightTextureLoc, 0);
|
glUniform1i(heightTextureLoc, 0);
|
||||||
|
|
||||||
|
GLint tessFactorLoc = glGetUniformLocation(shader_program_, "tessellationFactor");
|
||||||
|
glUniform1f(tessFactorLoc, tessellationFactor);
|
||||||
|
|
||||||
glBindVertexArray(vao_);
|
glBindVertexArray(vao_);
|
||||||
glPatchParameteri(GL_PATCH_VERTICES, 4);
|
glPatchParameteri(GL_PATCH_VERTICES, 4);
|
||||||
glDrawElements(GL_PATCHES, indices.size(), GL_UNSIGNED_INT, 0);
|
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::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();
|
ImGui::End();
|
||||||
|
|
||||||
// Draw FBO to ImGui window
|
// Draw FBO to ImGui window
|
||||||
|
|
Loading…
Reference in New Issue