Defoveate with the same grid server uses
This commit is contained in:
@@ -393,8 +393,8 @@ void stream_reprojection::reproject(vk::raii::CommandBuffer & command_buffer, in
|
|||||||
};
|
};
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
glm::mat4 hmd_unview = glm::mat4_cast(glm::quat(
|
glm::mat4 hmd_view = glm::mat4_cast(glm::quat(
|
||||||
dest_pose.w,
|
-dest_pose.w,
|
||||||
dest_pose.x,
|
dest_pose.x,
|
||||||
dest_pose.y,
|
dest_pose.y,
|
||||||
dest_pose.z));
|
dest_pose.z));
|
||||||
@@ -413,23 +413,29 @@ void stream_reprojection::reproject(vk::raii::CommandBuffer & command_buffer, in
|
|||||||
};
|
};
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
glm::mat4 video_view = glm::mat4_cast(glm::quat(
|
glm::mat4 video_unview = glm::mat4_cast(glm::quat(
|
||||||
-source_pose.w,
|
source_pose.w,
|
||||||
source_pose.x,
|
source_pose.x,
|
||||||
source_pose.y,
|
source_pose.y,
|
||||||
source_pose.z));
|
source_pose.z));
|
||||||
|
|
||||||
ubo[source]->reprojection = video_proj * video_view * hmd_unview * glm::inverse(hmd_proj);
|
ubo[source]->reprojection = hmd_proj * hmd_view * video_unview * glm::inverse(video_proj);
|
||||||
|
|
||||||
ubo[source]->a.x = foveation_parameters[source].x.a;
|
if (foveation_parameters[source].x.scale < 1)
|
||||||
ubo[source]->b.x = foveation_parameters[source].x.b;
|
{
|
||||||
ubo[source]->lambda.x = foveation_parameters[source].x.a / foveation_parameters[source].x.scale;
|
ubo[source]->a.x = foveation_parameters[source].x.a;
|
||||||
ubo[source]->xc.x = foveation_parameters[source].x.center;
|
ubo[source]->b.x = foveation_parameters[source].x.b;
|
||||||
|
ubo[source]->lambda.x = foveation_parameters[source].x.scale / foveation_parameters[source].x.a;
|
||||||
|
ubo[source]->xc.x = foveation_parameters[source].x.center;
|
||||||
|
}
|
||||||
|
|
||||||
ubo[source]->a.y = foveation_parameters[source].y.a;
|
if (foveation_parameters[source].y.scale < 1)
|
||||||
ubo[source]->b.y = foveation_parameters[source].y.b;
|
{
|
||||||
ubo[source]->lambda.y = foveation_parameters[source].y.a / foveation_parameters[source].y.scale;
|
ubo[source]->a.y = foveation_parameters[source].y.a;
|
||||||
ubo[source]->xc.y = foveation_parameters[source].y.center;
|
ubo[source]->b.y = foveation_parameters[source].y.b;
|
||||||
|
ubo[source]->lambda.y = foveation_parameters[source].y.scale / foveation_parameters[source].y.a;
|
||||||
|
ubo[source]->xc.y = foveation_parameters[source].y.center;
|
||||||
|
}
|
||||||
|
|
||||||
vk::RenderPassBeginInfo begin_info{
|
vk::RenderPassBeginInfo begin_info{
|
||||||
.renderPass = *renderpass,
|
.renderPass = *renderpass,
|
||||||
|
|||||||
@@ -21,8 +21,8 @@
|
|||||||
|
|
||||||
layout (constant_id = 0) const bool use_foveation_x = false;
|
layout (constant_id = 0) const bool use_foveation_x = false;
|
||||||
layout (constant_id = 1) const bool use_foveation_y = false;
|
layout (constant_id = 1) const bool use_foveation_y = false;
|
||||||
layout (constant_id = 2) const int nb_x = 1;
|
layout (constant_id = 2) const int nb_x = 64;
|
||||||
layout (constant_id = 3) const int nb_y = 1;
|
layout (constant_id = 3) const int nb_y = 64;
|
||||||
|
|
||||||
layout(set = 0, binding = 1) uniform UniformBufferObject
|
layout(set = 0, binding = 1) uniform UniformBufferObject
|
||||||
{
|
{
|
||||||
@@ -37,26 +37,24 @@ ubo;
|
|||||||
|
|
||||||
vec2 reproject_and_unfoveate(vec2 uv)
|
vec2 reproject_and_unfoveate(vec2 uv)
|
||||||
{
|
{
|
||||||
vec4 tmp = ubo.reprojection * vec4(uv, 1.0, 1.0);
|
uv = 2 * uv - 1;
|
||||||
uv = vec2(tmp) / tmp.z; // between -1 and 1
|
|
||||||
|
|
||||||
if (use_foveation_x && use_foveation_y)
|
if (use_foveation_x && use_foveation_y)
|
||||||
{
|
{
|
||||||
uv = atan(ubo.lambda * (uv - ubo.xc)) / ubo.a - ubo.b;
|
uv = ubo.lambda * tan(ubo.a * uv + ubo.b) + ubo.xc;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (use_foveation_x)
|
if (use_foveation_x)
|
||||||
{
|
{
|
||||||
uv.x = (atan(ubo.lambda * (uv - ubo.xc)) / ubo.a - ubo.b).x;
|
uv.x = (ubo.lambda * tan(ubo.a * uv + ubo.b) + ubo.xc).y;
|
||||||
}
|
}
|
||||||
if (use_foveation_y)
|
if (use_foveation_y)
|
||||||
{
|
{
|
||||||
uv.y = (atan(ubo.lambda * (uv - ubo.xc)) / ubo.a - ubo.b).y;
|
uv.y = (ubo.lambda * tan(ubo.a * uv + ubo.b) + ubo.xc).y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
vec4 tmp = ubo.reprojection * vec4(uv, 1.0, 1.0);
|
||||||
return uv * 0.5 + vec2(0.5, 0.5);
|
return vec2(tmp) / tmp.z; // between -1 and 1
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef VERT_SHADER
|
#ifdef VERT_SHADER
|
||||||
@@ -67,22 +65,15 @@ vec2 positions[6] = vec2[](
|
|||||||
|
|
||||||
layout(location = 0) out vec2 outUV;
|
layout(location = 0) out vec2 outUV;
|
||||||
|
|
||||||
layout(location = 1) out vec4 test;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
vec2 quad_size = vec2(2, 2) / vec2(nb_x, nb_y);
|
vec2 quad_size = 1 / vec2(nb_x, nb_y);
|
||||||
int cell_id = gl_VertexIndex / 6;
|
int cell_id = gl_VertexIndex / 6;
|
||||||
|
|
||||||
vec2 top_left = quad_size * vec2(cell_id % nb_x, cell_id / nb_x) - 1.0;
|
vec2 top_left = quad_size * vec2(cell_id % nb_x, cell_id / nb_x);
|
||||||
outUV = top_left + positions[gl_VertexIndex % 6] * quad_size;
|
outUV = top_left + positions[gl_VertexIndex % 6] * quad_size;
|
||||||
|
|
||||||
gl_Position = vec4(outUV, 0.0, 1.0);
|
gl_Position = vec4(reproject_and_unfoveate(outUV), 0.0, 1.0);
|
||||||
|
|
||||||
if (nb_x > 1 || nb_y > 1)
|
|
||||||
outUV = reproject_and_unfoveate(outUV);
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -90,20 +81,12 @@ void main()
|
|||||||
layout(set = 0, binding = 0) uniform sampler2D texSampler;
|
layout(set = 0, binding = 0) uniform sampler2D texSampler;
|
||||||
|
|
||||||
layout(location = 0) in vec2 inUV;
|
layout(location = 0) in vec2 inUV;
|
||||||
layout(location = 1) in vec4 test;
|
|
||||||
|
|
||||||
layout(location = 0) out vec4 outColor;
|
layout(location = 0) out vec4 outColor;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
vec2 uv;
|
outColor = vec4(texture(texSampler, inUV).rgb, 1);
|
||||||
|
|
||||||
if (nb_x == 1 && nb_y == 1)
|
|
||||||
uv = reproject_and_unfoveate(inUV);
|
|
||||||
else
|
|
||||||
uv = inUV;
|
|
||||||
|
|
||||||
outColor = vec4(texture(texSampler, uv).rgb, 1);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user