Finish implementing Canvas Background mode
This commit is contained in:
parent
49cc12bf89
commit
21ac6d7d8e
7 changed files with 77 additions and 38 deletions
|
|
@ -510,16 +510,18 @@ void CopyEffects::copy_to_atlas_fb(RID p_source_rd_texture, RID p_dest_framebuff
|
|||
|
||||
memset(©_to_fb.push_constant, 0, sizeof(CopyToFbPushConstant));
|
||||
|
||||
copy_to_fb.push_constant.use_section = true;
|
||||
copy_to_fb.push_constant.flags |= COPY_TO_FB_FLAG_USE_SECTION;
|
||||
copy_to_fb.push_constant.section[0] = p_uv_rect.position.x;
|
||||
copy_to_fb.push_constant.section[1] = p_uv_rect.position.y;
|
||||
copy_to_fb.push_constant.section[2] = p_uv_rect.size.x;
|
||||
copy_to_fb.push_constant.section[3] = p_uv_rect.size.y;
|
||||
|
||||
if (p_flip_y) {
|
||||
copy_to_fb.push_constant.flip_y = true;
|
||||
copy_to_fb.push_constant.flags |= COPY_TO_FB_FLAG_FLIP_Y;
|
||||
}
|
||||
|
||||
copy_to_fb.push_constant.luminance_multiplier = 1.0;
|
||||
|
||||
// setup our uniforms
|
||||
RID default_sampler = material_storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED);
|
||||
|
||||
|
|
@ -537,28 +539,35 @@ void CopyEffects::copy_to_atlas_fb(RID p_source_rd_texture, RID p_dest_framebuff
|
|||
RD::get_singleton()->draw_list_draw(draw_list, true);
|
||||
}
|
||||
|
||||
void CopyEffects::copy_to_fb_rect(RID p_source_rd_texture, RID p_dest_framebuffer, const Rect2i &p_rect, bool p_flip_y, bool p_force_luminance, bool p_alpha_to_zero, bool p_srgb, RID p_secondary, bool p_multiview, bool p_alpha_to_one) {
|
||||
void CopyEffects::copy_to_fb_rect(RID p_source_rd_texture, RID p_dest_framebuffer, const Rect2i &p_rect, bool p_flip_y, bool p_force_luminance, bool p_alpha_to_zero, bool p_srgb, RID p_secondary, bool p_multiview, bool p_alpha_to_one, bool p_linear) {
|
||||
UniformSetCacheRD *uniform_set_cache = UniformSetCacheRD::get_singleton();
|
||||
ERR_FAIL_NULL(uniform_set_cache);
|
||||
MaterialStorage *material_storage = MaterialStorage::get_singleton();
|
||||
ERR_FAIL_NULL(material_storage);
|
||||
|
||||
memset(©_to_fb.push_constant, 0, sizeof(CopyToFbPushConstant));
|
||||
copy_to_fb.push_constant.luminance_multiplier = 1.0;
|
||||
|
||||
if (p_flip_y) {
|
||||
copy_to_fb.push_constant.flip_y = true;
|
||||
copy_to_fb.push_constant.flags |= COPY_TO_FB_FLAG_FLIP_Y;
|
||||
}
|
||||
if (p_force_luminance) {
|
||||
copy_to_fb.push_constant.force_luminance = true;
|
||||
copy_to_fb.push_constant.flags |= COPY_TO_FB_FLAG_FORCE_LUMINANCE;
|
||||
}
|
||||
if (p_alpha_to_zero) {
|
||||
copy_to_fb.push_constant.alpha_to_zero = true;
|
||||
copy_to_fb.push_constant.flags |= COPY_TO_FB_FLAG_ALPHA_TO_ZERO;
|
||||
}
|
||||
if (p_srgb) {
|
||||
copy_to_fb.push_constant.srgb = true;
|
||||
copy_to_fb.push_constant.flags |= COPY_TO_FB_FLAG_SRGB;
|
||||
}
|
||||
if (p_alpha_to_one) {
|
||||
copy_to_fb.push_constant.alpha_to_one = true;
|
||||
copy_to_fb.push_constant.flags |= COPY_TO_FB_FLAG_ALPHA_TO_ONE;
|
||||
}
|
||||
if (p_linear) {
|
||||
// Used for copying to a linear buffer. In the mobile renderer we divide the contents of the linear buffer
|
||||
// to allow for a wider effective range.
|
||||
copy_to_fb.push_constant.flags |= COPY_TO_FB_FLAG_LINEAR;
|
||||
copy_to_fb.push_constant.luminance_multiplier = prefer_raster_effects ? 2.0 : 1.0;
|
||||
}
|
||||
|
||||
// setup our uniforms
|
||||
|
|
|
|||
|
|
@ -181,16 +181,21 @@ private:
|
|||
COPY_TO_FB_MAX,
|
||||
};
|
||||
|
||||
enum CopyToFBFlags {
|
||||
COPY_TO_FB_FLAG_FLIP_Y = (1 << 0),
|
||||
COPY_TO_FB_FLAG_USE_SECTION = (1 << 1),
|
||||
COPY_TO_FB_FLAG_FORCE_LUMINANCE = (1 << 2),
|
||||
COPY_TO_FB_FLAG_ALPHA_TO_ZERO = (1 << 3),
|
||||
COPY_TO_FB_FLAG_SRGB = (1 << 4),
|
||||
COPY_TO_FB_FLAG_ALPHA_TO_ONE = (1 << 5),
|
||||
COPY_TO_FB_FLAG_LINEAR = (1 << 6),
|
||||
};
|
||||
|
||||
struct CopyToFbPushConstant {
|
||||
float section[4];
|
||||
float pixel_size[2];
|
||||
uint32_t flip_y;
|
||||
uint32_t use_section;
|
||||
|
||||
uint32_t force_luminance;
|
||||
uint32_t alpha_to_zero;
|
||||
uint32_t srgb;
|
||||
uint32_t alpha_to_one;
|
||||
float luminance_multiplier;
|
||||
uint32_t flags;
|
||||
|
||||
float set_color[4];
|
||||
};
|
||||
|
|
@ -322,7 +327,7 @@ public:
|
|||
void copy_cubemap_to_panorama(RID p_source_cube, RID p_dest_panorama, const Size2i &p_panorama_size, float p_lod, bool p_is_array);
|
||||
void copy_depth_to_rect(RID p_source_rd_texture, RID p_dest_framebuffer, const Rect2i &p_rect, bool p_flip_y = false);
|
||||
void copy_depth_to_rect_and_linearize(RID p_source_rd_texture, RID p_dest_texture, const Rect2i &p_rect, bool p_flip_y, float p_z_near, float p_z_far);
|
||||
void copy_to_fb_rect(RID p_source_rd_texture, RID p_dest_framebuffer, const Rect2i &p_rect, bool p_flip_y = false, bool p_force_luminance = false, bool p_alpha_to_zero = false, bool p_srgb = false, RID p_secondary = RID(), bool p_multiview = false, bool alpha_to_one = false);
|
||||
void copy_to_fb_rect(RID p_source_rd_texture, RID p_dest_framebuffer, const Rect2i &p_rect, bool p_flip_y = false, bool p_force_luminance = false, bool p_alpha_to_zero = false, bool p_srgb = false, RID p_secondary = RID(), bool p_multiview = false, bool alpha_to_one = false, bool p_linear = false);
|
||||
void copy_to_atlas_fb(RID p_source_rd_texture, RID p_dest_framebuffer, const Rect2 &p_uv_rect, RD::DrawListID p_draw_list, bool p_flip_y = false, bool p_panorama = false);
|
||||
void copy_raster(RID p_source_texture, RID p_dest_framebuffer);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue