Compare commits

...

20 Commits

Author SHA1 Message Date
Jack Christensen 3f6f19aaf0 Update .gitlab-ci.yml file 2024-08-29 15:32:12 +00:00
Jack Christensen fa298669ef Update .gitlab-ci.yml file 2024-08-29 05:16:01 +00:00
Jack Christensen a4070255f5 Update .gitlab-ci.yml file 2024-08-29 05:14:02 +00:00
Jack 353ba0ef63 Add release to .gitlab-ci.yml 2024-08-29 01:12:10 -04:00
Jack 0ffef286eb Updated to v0.0.4 2024-08-28 23:14:36 -04:00
Jack f8e1c14fa7 Merge branch 'main' of https://git.jackmchristensen.com/jack/terravisor 2024-08-28 23:12:22 -04:00
Jack 9a3b928c8f Merge branches 2024-08-28 23:12:18 -04:00
Jack Christensen 8f6b1de6fc Merge branch 'feature/3-mesh-tessellation' into 'main'
Bind attribute location

See merge request jack/terravisor!4
2024-08-29 03:10:24 +00:00
Jack b3aac984a7 Correctly calculate normals with dynamic tessellation 2024-08-28 23:07:40 -04:00
Jack 85533814e1 Dynamic tessellation based on slope
TODO normals do not reflect slope tessellation
2024-08-28 22:24:23 -04:00
Jack 9fa18ac69e Merge branch 'main' into feature/3-mesh-tessellation 2024-08-28 21:20:02 -04:00
Jack Christensen 9e6d0d4c02 Merge branch 'feature/interface-scaling' into 'main'
Resize font and add JetBrainsMono

See merge request jack/terravisor!3
2024-08-29 01:13:43 +00:00
Jack 93048ed1b6 Merge branch 'main' into feature/3-mesh-tessellation 2024-08-28 13:59:01 -04:00
Jack 5b38f5548e Updated imgui.ini 2024-08-28 10:06:02 -04:00
Jack a66f4e275a Merge branch 'feature/1-camera-controls' into feature/3-mesh-tessellation 2024-08-28 10:05:24 -04:00
Jack a92b85ab35 Add GeoData to TEC 2024-08-25 23:04:34 -04:00
Jack c4f539c5b8 Fix namechange
Revert back to regular uniforms file name
2024-08-25 22:53:24 -04:00
Jack 1b4e3990e8 Tmp commit
Because I'm just renaming a file by making it lower case (technically snake_case) I need to do a tmp commit so the rename sticks.
2024-08-25 22:52:15 -04:00
Jack 7cf2ec7b55 Refactor uniforms
Add GeoData to control uniforms for geo pass. TODO refactor post pass uniforms
2024-08-25 22:49:45 -04:00
Jack f638a2f1f8 Bind attribute location
Realized that attribute locations were not bound for the geometry pass. Fixed that and renamed variables to be camelCase
2024-08-25 22:16:14 -04:00
8 changed files with 64 additions and 25 deletions

View File

@ -7,6 +7,7 @@ stages:
variables:
VCPKG_ROOT: "/vcpkg"
CMAKE_BUILD_TYPE: "Release"
build:
stage: build
@ -32,4 +33,4 @@ run_tests:
- export DISPLAY=:99
- export TEST_MODE=1
- cd build
- ./TerraVisor
- ./TerraVisor

View File

@ -4,4 +4,8 @@
## [v0.0.3] - 2024-08-28
### Changed
- Correctly manage window resizing for camera aspect ratio
- Correctly manage window resizing for camera aspect ratio
## [v0.0.4] - 2024-08-28
### Changed
- Added dynamic tessellation determined by the slope of the terrain

View File

@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.10)
project(TerraVisor VERSION 0.0.3)
project(TerraVisor VERSION 0.0.4)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

View File

@ -30,20 +30,20 @@ DockId=0x00000003,0
[Window][Viewport]
Pos=0,34
Size=2134,1641
Size=2178,1641
Collapsed=0
DockId=0x00000003,0
[Window][Scene Settings]
Pos=2137,34
Size=743,1641
Pos=2181,34
Size=699,1641
Collapsed=0
DockId=0x00000004,0
[Docking][Data]
DockSpace ID=0x6F42A598 Window=0xE80F322C Pos=0,34 Size=2880,1641 Split=X Selected=0x9F2D9299
DockNode ID=0x00000001 Parent=0x6F42A598 SizeRef=0,0 Split=X Selected=0x13926F0B
DockNode ID=0x00000003 Parent=0x00000001 SizeRef=2134,701 CentralNode=1 Selected=0x13926F0B
DockNode ID=0x00000004 Parent=0x00000001 SizeRef=743,701 Selected=0x413E6147
DockNode ID=0x00000003 Parent=0x00000001 SizeRef=578,701 CentralNode=1 Selected=0x13926F0B
DockNode ID=0x00000004 Parent=0x00000001 SizeRef=699,701 Selected=0x413E6147
DockNode ID=0x00000002 Parent=0x6F42A598 SizeRef=419,701 Selected=0xF69494A7

View File

@ -24,21 +24,48 @@ in VS_OUT {
out TC_OUT {
vec3 position;
vec2 texCoord;
float tessLevel;
} tc_out[];
float getHeight(vec2 uv) {
return texture(heightTexture, uv).r * displacementScale;
}
float calculateSlope() {
float step = 1.0f / (float(gridDensity) * maxTessellation + 1.0f);
// Find surrounding heights
float hLeft = getHeight(tc_in[gl_InvocationID].texCoord + vec2(-step, 0.0f));
float hRight = getHeight(tc_in[gl_InvocationID].texCoord + vec2(step, 0.0f));
float hUp = getHeight(tc_in[gl_InvocationID].texCoord + vec2(0.0f, step));
float hDown = getHeight(tc_in[gl_InvocationID].texCoord + vec2(0.0f, -step));
float slopeX = abs(hLeft - hRight) * displacementScale;
float slopeY = abs(hUp - hDown) * displacementScale;
float maxSlope = max(slopeX, slopeY);
return maxSlope;
}
void main() {
// Pass through position and texture coordinates to the tessellation evaluation shader
tc_out[gl_InvocationID].position = tc_in[gl_InvocationID].position;
tc_out[gl_InvocationID].texCoord = tc_in[gl_InvocationID].texCoord;
float slope = calculateSlope();
float tessLevel = tessellationFactor * (1.0f + slope * 10.0f);
tessLevel = max(tessLevel, maxTessellation);
tc_out[gl_InvocationID].tessLevel = tessLevel;
// Set tessellation levels
if (gl_InvocationID == 0) {
gl_TessLevelOuter[0] = maxTessellation;
gl_TessLevelOuter[1] = maxTessellation;
gl_TessLevelOuter[2] = maxTessellation;
gl_TessLevelOuter[3] = maxTessellation;
gl_TessLevelOuter[0] = tessLevel;
gl_TessLevelOuter[1] = tessLevel;
gl_TessLevelOuter[2] = tessLevel;
gl_TessLevelOuter[3] = tessLevel;
gl_TessLevelInner[0] = maxTessellation;
gl_TessLevelInner[1] = maxTessellation;
gl_TessLevelInner[0] = tessLevel;
gl_TessLevelInner[1] = tessLevel;
}
}

View File

@ -18,6 +18,7 @@ layout(std140, binding = 4) uniform GeoUniforms
in TC_OUT {
vec3 position;
vec2 texCoord;
float tessLevel;
} te_in[];
out TE_OUT {
@ -30,19 +31,25 @@ float getHeight(vec2 uv) {
return texture(heightTexture, uv).r * displacementScale;
}
float getNeighbor(float tessFactor) {
return (float(gridDensity) * tessFactor + 1.0f);
}
vec3 calculateSmoothNormal(vec3 pos, vec2 coord) {
// Currently hardcoded to match patch density
float step = 1.0f / (float(gridDensity) * maxTessellation + 1.0f);
//float step = 1.0f / (float(gridDensity) * tessLevel + 1.0f);
float stepU = 1.0f / (float(gridDensity) * gl_TessLevelInner[0]);
float stepV = 1.0f / (float(gridDensity) * gl_TessLevelInner[1]);
// Find surrounding heights
float hLeft = getHeight(coord + vec2(-step, 0.0f));
float hRight = getHeight(coord + vec2(step, 0.0f));
float hUp = getHeight(coord + vec2(0.0f, step));
float hDown = getHeight(coord + vec2(0.0f, -step));
float hLeft = getHeight(coord + vec2(-stepU, 0.0f));
float hRight = getHeight(coord + vec2(stepU, 0.0f));
float hUp = getHeight(coord + vec2(0.0f, stepV));
float hDown = getHeight(coord + vec2(0.0f, -stepV));
// Calculate tangents
vec3 tangentX = normalize(vec3(step, hRight - hLeft, 0.0));
vec3 tangentY = normalize(vec3(0.0, hUp - hDown, step));
vec3 tangentX = normalize(vec3(stepU, hRight - hLeft, 0.0));
vec3 tangentY = normalize(vec3(0.0, hUp - hDown, stepV));
return normalize(cross(tangentY, tangentX));
}

View File

@ -20,7 +20,6 @@ void ApplyUIScaling(GLFWwindow* window) {
ImGuiIO& io = ImGui::GetIO();
io.Fonts->Clear();
std::cout << "Current Path: " << std::filesystem::current_path() << std::endl;
#ifdef _WIN32
io.Fonts->AddFontFromFileTTF("imgui/misc/fonts/JetBrainsMono/JetBrainsMono-Medium.ttf", 8.0f * scale);

View File

@ -240,8 +240,7 @@ void Scene::Display(GLFWwindow* window) {
glUseProgram(shader_program_);
//glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
// glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
Window* viewport = Interface::GetWindowByName(windows_, "Viewport");
if (viewport && viewport->size.x > 0 && viewport->size.y > 0) {
@ -270,7 +269,9 @@ void Scene::Display(GLFWwindow* window) {
glPatchParameteri(GL_PATCH_VERTICES, 4);
glDrawElements(GL_PATCHES, indices.size(), GL_UNSIGNED_INT, 0);
//glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
FBO::Unbind();
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
FBO::Bind(lht_fbo_);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);