diff --git a/res/dpr/depth_peeling_reprojection_stereo.frag b/res/dpr/depth_peeling_reprojection_stereo.frag index 6ccb5b672d84452e0454185502ba5402c563502d..d787c3dd17d3a17b4a6ddf807e4abfce37dc41b3 100644 --- a/res/dpr/depth_peeling_reprojection_stereo.frag +++ b/res/dpr/depth_peeling_reprojection_stereo.frag @@ -28,9 +28,9 @@ void main() { if (clipPos.z <= depth + params.zThreshold) { discard; } - float zNear = 0.1; - float zFar = 256.0; - float linearDepth = zNear * zFar / (zFar + depth * (zNear - zFar)); + /* float zNear = 0.1; */ + /* float zFar = 256.0; */ + /* float linearDepth = zNear * zFar / (zFar + depth * (zNear - zFar)); */ // outFragColor = vec4(vec3(pow(depth, 64.0)), 1.0); } @@ -45,9 +45,12 @@ void main() { float nDotL = dot(normal, normalize(vec3(0.1, 0.14, 1.0))); /* if (gl_Layer == 0) { */ + /* outFragColor = vec4(1.0); */ + /* } else { */ + /* outFragColor = vec4(1.0, 0.0, 1.0, 1.0); */ + /* } */ outFragColor = vec4(max(nDotL, 0.23) * diffuse.rgb, diffuse.a); /* } */ - // outFragColor = vec4(1.0); } diff --git a/res/dpr/depth_peeling_reprojection_stereo.geom b/res/dpr/depth_peeling_reprojection_stereo.geom index 0370f2f10aecbca9e7905c9c9512fd6fd2917506..e8303f840080fd010cb62da936b32fec90ab5d31 100644 --- a/res/dpr/depth_peeling_reprojection_stereo.geom +++ b/res/dpr/depth_peeling_reprojection_stereo.geom @@ -1,36 +1,31 @@ #version 450 core #extension GL_ARB_viewport_array : enable +#extension GL_NV_geometry_shader_passthrough : require +#extension GL_NV_viewport_array2 : require -layout (triangles, invocations = 2) in; -layout (triangle_strip, max_vertices = 3) out; +layout (triangles) in; +/* layout (triangle_strip, max_vertices = 3) out; */ -layout(location = 0) in vec3 inPos[]; -layout(location = 1) in vec3 inNormal[]; -layout(location = 2) in vec3 inTangent[]; -layout(location = 3) in vec2 inUV[]; -layout(location = 4) in vec4 inClipPos[]; +layout(location = 0, passthrough) in vec3 inPos[]; +layout(location = 1, passthrough) in vec3 inNormal[]; +layout(location = 2, passthrough) in vec3 inTangent[]; +layout(location = 3, passthrough) in vec2 inUV[]; +layout(location = 4, passthrough) in vec4 inClipPos[]; -layout(location = 0) out vec3 outPos; -layout(location = 1) out vec3 outNormal; -layout(location = 2) out vec3 outTangent; -layout(location = 3) out vec2 outUV; -layout(location = 4) out vec4 outClipPos; +layout(location = 0, passthrough) out vec3 outPos; +layout(location = 1, passthrough) out vec3 outNormal; +layout(location = 2, passthrough) out vec3 outTangent; +layout(location = 3, passthrough) out vec2 outUV; +layout(location = 4, passthrough) out vec4 outClipPos; -in gl_PerVertex { +layout(passthrough) in gl_PerVertex { vec4 gl_Position; } gl_in[]; +layout (viewport_relative) out highp int gl_Layer; + void main() { - for (int i = 0; i < 3; ++i) { - outPos = inPos[i]; - outNormal = inNormal[i]; - outTangent = inTangent[i]; - outUV = inUV[i]; - outClipPos = inClipPos[i]; - gl_Position = gl_in[i].gl_Position; - gl_Layer = gl_InvocationID; - EmitVertex(); - } - EndPrimitive(); + gl_ViewportMask[0] = 3; + gl_Layer = 0; } diff --git a/src/depth_peeling_reprojection_stereo.cpp b/src/depth_peeling_reprojection_stereo.cpp index 4d542534a8e2e39651baff116c8c02c69ed0d4f0..f67e111e24457786be8351acca81315589e3ce0b 100644 --- a/src/depth_peeling_reprojection_stereo.cpp +++ b/src/depth_peeling_reprojection_stereo.cpp @@ -281,6 +281,26 @@ render_pass::ptr depth_peeling_reprojection_stereo::create_render_pass(lava::ind pipeline->set_rasterization_cull_mode(VK_CULL_MODE_BACK_BIT); pipeline->on_process = [this, render_pass_index](VkCommandBuffer command_buffer) { + std::array<VkViewport, 2> viewports = { + VkViewport { + .x = 0.0f, + .y = 0.0f, + .width = 1024.0f, + .height = 1024.0f, + .minDepth = 0.0f, + .maxDepth = 1.0f, + }, + VkViewport { + .x = 0.0f, + .y = 0.0f, + .width = 1024.0f, + .height = 1024.0f, + .minDepth = 0.0f, + .maxDepth = 1.0f, + } + }; + vkCmdSetViewport(command_buffer, 0, 2, viewports.data()); + pipeline_layout_->bind(command_buffer, app()->left_eye_framebuffer()->per_frame_descriptor_set, 0); pipeline_layout_->bind(command_buffer, descriptor_sets_[render_pass_index], 3); pipeline_layout_->bind(command_buffer, reprojection_pipeline_descriptor_set_[0], 4); @@ -369,6 +389,18 @@ render_pass::ptr depth_peeling_reprojection_stereo::create_render_pass(lava::ind }; render_pass->create({ views }, area); + // pipeline->on_create = [this](graphics_pipeline::create_info& create_info) { + // assert(create_info.viewport_state.viewportCount == 1); + // // viewports_[0] = create_info.viewport_state.pViewports[0]; + // // viewports_[1] = create_info.viewport_state.pViewports[0]; + // // scissors_[0] = create_info.viewport_state.pScissors[0]; + // // scissors_[1] = create_info.viewport_state.pScissors[0]; + // create_info.viewport_state.viewportCount = 2; + // // create_info.viewport_state.pViewports = viewports_.data(); + // create_info.viewport_state.scissorCount = 2; + // // create_info.viewport_state.pScissors = scissors_.data(); + // return true; + // }; pipeline->create(render_pass->get()); render_pass->add_front(pipeline); diff --git a/src/vr_app.cpp b/src/vr_app.cpp index 7d3267f6a17cfe97365f669d635bf41f8e9a0c57..204282e061ab90a7b7a59cbd60c3bc3031cfa55a 100644 --- a/src/vr_app.cpp +++ b/src/vr_app.cpp @@ -74,6 +74,8 @@ vr_app::vr_app(name name, argh::parser cmd_line) { device_param.extensions.push_back(extension.c_str()); } } + device_param.extensions.push_back("VK_NV_geometry_shader_passthrough"); + device_param.extensions.push_back("VK_NV_viewport_array2"); device_param.features.fillModeNonSolid = true; device_param.features.multiViewport = true; device_param.features.geometryShader = true;