EEVEE-Next: Fix Alt+B render borders
A few offsets were missing. Reminder that this does not change the actual render resolution but it reduces the VRAM consumption of accumulation buffers.
This commit is contained in:
@@ -311,7 +311,7 @@ void Film::init(const int2 &extent, const rcti *output_rect)
|
||||
{
|
||||
/* TODO(@fclem): Over-scans. */
|
||||
|
||||
render_extent_ = math::divide_ceil(extent, int2(data_.scaling_factor));
|
||||
data_.render_extent = math::divide_ceil(extent, int2(data_.scaling_factor));
|
||||
int2 weight_extent = inst_.camera.is_panoramic() ? data_.extent : int2(data_.scaling_factor);
|
||||
|
||||
eGPUTextureFormat color_format = GPU_RGBA16F;
|
||||
@@ -536,7 +536,13 @@ void Film::accumulate(const DRWView *view)
|
||||
{
|
||||
if (inst_.is_viewport()) {
|
||||
DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get();
|
||||
DefaultTextureList *dtxl = DRW_viewport_texture_list_get();
|
||||
GPU_framebuffer_bind(dfbl->default_fb);
|
||||
/* Clear when using render borders. */
|
||||
if (data_.extent != int2(GPU_texture_width(dtxl->color), GPU_texture_height(dtxl->color))) {
|
||||
float4 clear_color = {0.0f, 0.0f, 0.0f, 0.0f};
|
||||
GPU_framebuffer_clear_color(dfbl->default_fb, clear_color);
|
||||
}
|
||||
GPU_framebuffer_viewport_set(dfbl->default_fb, UNPACK2(data_.offset), UNPACK2(data_.extent));
|
||||
}
|
||||
|
||||
|
||||
@@ -55,8 +55,6 @@ class Film {
|
||||
/** Static reference as SwapChain does not actually move the objects when swapping. */
|
||||
GPUTexture *weight_src_tx_ = nullptr;
|
||||
GPUTexture *weight_dst_tx_ = nullptr;
|
||||
/** Extent used by the render buffers when rendering the main views. */
|
||||
int2 render_extent_ = int2(-1);
|
||||
/** User setting to disable reprojection. Useful for debugging or have a more precise render. */
|
||||
bool force_disable_reprojection_ = false;
|
||||
|
||||
@@ -86,7 +84,7 @@ class Film {
|
||||
|
||||
int2 render_extent_get() const
|
||||
{
|
||||
return render_extent_;
|
||||
return data_.render_extent;
|
||||
}
|
||||
|
||||
float2 pixel_jitter_get() const;
|
||||
|
||||
@@ -154,6 +154,8 @@ struct FilmData {
|
||||
int2 extent;
|
||||
/** Offset of the film in the full-res frame, in pixels. */
|
||||
int2 offset;
|
||||
/** Extent used by the render buffers when rendering the main views. */
|
||||
int2 render_extent;
|
||||
/** Sub-pixel offset applied to the window matrix.
|
||||
* NOTE: In final film pixel unit.
|
||||
* NOTE: Positive values makes the view translate in the negative axes direction.
|
||||
@@ -172,6 +174,7 @@ struct FilmData {
|
||||
/** Is true if accumulation of filtered passes is needed. */
|
||||
bool1 any_render_pass_1;
|
||||
bool1 any_render_pass_2;
|
||||
float _pad0, _pad1;
|
||||
/** Output counts per type. */
|
||||
int color_len, value_len;
|
||||
/** Index in color_accum_img or value_accum_img of each pass. -1 if pass is not enabled. */
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
void main()
|
||||
{
|
||||
ivec2 texel_film = ivec2(gl_FragCoord.xy);
|
||||
ivec2 texel_film = ivec2(gl_FragCoord.xy) - film_buf.offset;
|
||||
float out_depth;
|
||||
|
||||
if (film_buf.display_only) {
|
||||
|
||||
@@ -80,9 +80,9 @@ FilmSample film_sample_get(int sample_n, ivec2 texel_film)
|
||||
# endif
|
||||
|
||||
FilmSample film_sample = film_buf.samples[sample_n];
|
||||
film_sample.texel += texel_film;
|
||||
film_sample.texel += texel_film + film_buf.offset;
|
||||
/* Use extend on borders. */
|
||||
film_sample.texel = clamp(film_sample.texel, ivec2(0, 0), film_buf.extent - 1);
|
||||
film_sample.texel = clamp(film_sample.texel, ivec2(0, 0), film_buf.render_extent - 1);
|
||||
|
||||
/* TODO(fclem): Panoramic projection will need to compute the sample weight in the shader
|
||||
* instead of precomputing it on CPU. */
|
||||
@@ -440,7 +440,7 @@ void film_store_combined(
|
||||
/* Interactive accumulation. Do reprojection and Temporal Anti-Aliasing. */
|
||||
|
||||
/* Reproject by finding where this pixel was in the previous frame. */
|
||||
vec2 motion = film_pixel_history_motion_vector(dst.texel);
|
||||
vec2 motion = film_pixel_history_motion_vector(src_texel);
|
||||
vec2 history_texel = vec2(dst.texel) + motion;
|
||||
|
||||
float velocity = length(motion);
|
||||
@@ -592,11 +592,13 @@ void film_process_data(ivec2 texel_film, out vec4 out_color, out float out_depth
|
||||
float weight_accum = 0.0;
|
||||
vec4 combined_accum = vec4(0.0);
|
||||
|
||||
for (int i = 0; i < film_buf.samples_len; i++) {
|
||||
FilmSample src = film_sample_get(i, texel_film);
|
||||
FilmSample src;
|
||||
for (int i = film_buf.samples_len - 1; i >= 0; i--) {
|
||||
src = film_sample_get(i, texel_film);
|
||||
film_sample_accum_combined(src, combined_accum, weight_accum);
|
||||
}
|
||||
film_store_combined(dst, texel_film, combined_accum, weight_accum, out_color);
|
||||
/* NOTE: src.texel is center texel in incomming data buffer. */
|
||||
film_store_combined(dst, src.texel, combined_accum, weight_accum, out_color);
|
||||
}
|
||||
|
||||
if (film_buf.has_data) {
|
||||
|
||||
Reference in New Issue
Block a user