Merge pull request #52205 from BastiaanOlij/blit_source_rect
Add source rectangle to blit
This commit is contained in:
commit
461d31427c
9 changed files with 49 additions and 33 deletions
|
|
@ -46,6 +46,8 @@ void RendererCompositorRD::blit_render_targets_to_screen(DisplayServer::WindowID
|
|||
RID rd_texture = storage->texture_get_rd_texture(texture);
|
||||
ERR_CONTINUE(rd_texture.is_null());
|
||||
|
||||
// TODO if keep_3d_linear was set when rendering to this render target we need to add a linear->sRGB conversion in.
|
||||
|
||||
if (!render_target_descriptors.has(rd_texture) || !RD::get_singleton()->uniform_set_is_valid(render_target_descriptors[rd_texture])) {
|
||||
Vector<RD::Uniform> uniforms;
|
||||
RD::Uniform u;
|
||||
|
|
@ -65,10 +67,14 @@ void RendererCompositorRD::blit_render_targets_to_screen(DisplayServer::WindowID
|
|||
RD::get_singleton()->draw_list_bind_index_array(draw_list, blit.array);
|
||||
RD::get_singleton()->draw_list_bind_uniform_set(draw_list, render_target_descriptors[rd_texture], 0);
|
||||
|
||||
blit.push_constant.rect[0] = p_render_targets[i].rect.position.x / screen_size.width;
|
||||
blit.push_constant.rect[1] = p_render_targets[i].rect.position.y / screen_size.height;
|
||||
blit.push_constant.rect[2] = p_render_targets[i].rect.size.width / screen_size.width;
|
||||
blit.push_constant.rect[3] = p_render_targets[i].rect.size.height / screen_size.height;
|
||||
blit.push_constant.src_rect[0] = p_render_targets[i].src_rect.position.x;
|
||||
blit.push_constant.src_rect[1] = p_render_targets[i].src_rect.position.y;
|
||||
blit.push_constant.src_rect[2] = p_render_targets[i].src_rect.size.width;
|
||||
blit.push_constant.src_rect[3] = p_render_targets[i].src_rect.size.height;
|
||||
blit.push_constant.dst_rect[0] = p_render_targets[i].dst_rect.position.x / screen_size.width;
|
||||
blit.push_constant.dst_rect[1] = p_render_targets[i].dst_rect.position.y / screen_size.height;
|
||||
blit.push_constant.dst_rect[2] = p_render_targets[i].dst_rect.size.width / screen_size.width;
|
||||
blit.push_constant.dst_rect[3] = p_render_targets[i].dst_rect.size.height / screen_size.height;
|
||||
blit.push_constant.layer = p_render_targets[i].multi_view.layer;
|
||||
blit.push_constant.eye_center[0] = p_render_targets[i].lens_distortion.eye_center.x;
|
||||
blit.push_constant.eye_center[1] = p_render_targets[i].lens_distortion.eye_center.y;
|
||||
|
|
@ -203,10 +209,14 @@ void RendererCompositorRD::set_boot_image(const Ref<Image> &p_image, const Color
|
|||
RD::get_singleton()->draw_list_bind_index_array(draw_list, blit.array);
|
||||
RD::get_singleton()->draw_list_bind_uniform_set(draw_list, uset, 0);
|
||||
|
||||
blit.push_constant.rect[0] = screenrect.position.x;
|
||||
blit.push_constant.rect[1] = screenrect.position.y;
|
||||
blit.push_constant.rect[2] = screenrect.size.width;
|
||||
blit.push_constant.rect[3] = screenrect.size.height;
|
||||
blit.push_constant.src_rect[0] = 0.0;
|
||||
blit.push_constant.src_rect[1] = 0.0;
|
||||
blit.push_constant.src_rect[2] = 1.0;
|
||||
blit.push_constant.src_rect[3] = 1.0;
|
||||
blit.push_constant.dst_rect[0] = screenrect.position.x;
|
||||
blit.push_constant.dst_rect[1] = screenrect.position.y;
|
||||
blit.push_constant.dst_rect[2] = screenrect.size.width;
|
||||
blit.push_constant.dst_rect[3] = screenrect.size.height;
|
||||
blit.push_constant.layer = 0;
|
||||
blit.push_constant.eye_center[0] = 0;
|
||||
blit.push_constant.eye_center[1] = 0;
|
||||
|
|
|
|||
|
|
@ -55,7 +55,8 @@ protected:
|
|||
};
|
||||
|
||||
struct BlitPushConstant {
|
||||
float rect[4];
|
||||
float src_rect[4];
|
||||
float dst_rect[4];
|
||||
|
||||
float eye_center[2];
|
||||
float k1;
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
#VERSION_DEFINES
|
||||
|
||||
layout(push_constant, binding = 0, std140) uniform Pos {
|
||||
vec4 src_rect;
|
||||
vec4 dst_rect;
|
||||
|
||||
vec2 eye_center;
|
||||
|
|
@ -22,8 +23,8 @@ layout(location = 0) out vec2 uv;
|
|||
|
||||
void main() {
|
||||
vec2 base_arr[4] = vec2[](vec2(0.0, 0.0), vec2(0.0, 1.0), vec2(1.0, 1.0), vec2(1.0, 0.0));
|
||||
uv = base_arr[gl_VertexIndex];
|
||||
vec2 vtx = data.dst_rect.xy + uv * data.dst_rect.zw;
|
||||
uv = data.src_rect.xy + base_arr[gl_VertexIndex] * data.src_rect.zw;
|
||||
vec2 vtx = data.dst_rect.xy + base_arr[gl_VertexIndex] * data.dst_rect.zw;
|
||||
gl_Position = vec4(vtx * 2.0 - 1.0, 0.0, 1.0);
|
||||
}
|
||||
|
||||
|
|
@ -34,6 +35,7 @@ void main() {
|
|||
#VERSION_DEFINES
|
||||
|
||||
layout(push_constant, binding = 0, std140) uniform Pos {
|
||||
vec4 src_rect;
|
||||
vec4 dst_rect;
|
||||
|
||||
vec2 eye_center;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue