37void Film::init_aovs(
const Set<std::string> &passes_used_by_viewport_compositor)
39 Vector<ViewLayerAOV *> aovs;
63 if (!aovs.is_empty() && aovs.last() == aov) {
67 if (passes_used_by_viewport_compositor.contains(aov->
name)) {
93 if (!aovs.is_empty()) {
102 if (pass_tx ==
nullptr) {
114 Texture &accum_tx = is_value ? value_accum_tx_ : color_accum_tx_;
122 for (
uint4 candidate_hash : aovs_hash) {
123 if (candidate_hash.x ==
hash) {
130 if (aov_index == -1) {
146void Film::sync_mist()
167 data_.
mist_bias = -mist_start / mist_distance;
178 return (a.extent ==
b.extent) && (a.offset ==
b.offset) &&
179 (a.render_extent ==
b.render_extent) && (a.overscan ==
b.overscan) &&
180 (a.filter_radius ==
b.filter_radius) && (a.scaling_factor ==
b.scaling_factor) &&
181 (a.background_opacity ==
b.background_opacity);
202#define ENABLE_FROM_LEGACY(name_legacy, name_eevee) \
203 SET_FLAG_FROM_TEST(result, \
204 (view_layer->passflag & SCE_PASS_##name_legacy) != 0, \
205 EEVEE_RENDER_PASS_##name_eevee);
222#undef ENABLE_FROM_LEGACY
250 if (pass_type == 0) {
255 if (viewport_compositor_needed_passes.
contains(pass_name)) {
256 viewport_compositor_enabled_passes |= pass_type;
261 return viewport_compositor_enabled_passes;
266 using namespace math;
276 passes_used_by_viewport_compositor, inst_.
view_layer);
280 init_aovs(passes_used_by_viewport_compositor);
287 viewport_compositor_enabled_passes_;
305 enabled_passes_ &= ~EEVEE_RENDER_PASS_VECTOR;
320 output_rect = &fallback_rect;
323 display_extent = extent;
333 data_.
filter_radius = (sampling.sample_count() == 1) ? 0.0f :
334 clamp_f(scene.r.gauss, 0.0f, 100.0f);
357 if (enabled_passes_ & data_passes) {
360 if (enabled_passes_ & color_passes_1) {
363 if (enabled_passes_ & color_passes_2) {
366 if (enabled_passes_ & color_passes_3) {
387 int index = (enabled_passes_ & pass_type) ?
421 int cryptomatte_id = 0;
424 if (enabled_passes_ & pass_type) {
425 index = cryptomatte_id;
439 if ((enabled_passes_ &
459 reset += combined_tx_.current().ensure_2d(color_format, data_.
extent);
460 reset += combined_tx_.next().ensure_2d(color_format, data_.
extent);
462 reset += weight_tx_.current().ensure_2d_array(weight_format, weight_extent, 2);
463 reset += weight_tx_.next().ensure_2d_array(weight_format, weight_extent, 2);
474 (cryptomatte_array_len > 0) ? data_.
extent :
int2(1),
475 (cryptomatte_array_len > 0) ? cryptomatte_array_len :
480 use_reprojection_ =
false;
485 combined_tx_.current().clear(
float4(0.0f));
486 weight_tx_.current().clear(
float4(0.0f));
508 accumulate_ps_.
init();
509 init_pass(accumulate_ps_, sh);
526 const bool is_cryptomatte_pass_enabled = cryptomatte_layer_count > 0;
527 const bool do_cryptomatte_sorting = !inst_.
is_viewport() ||
529 cryptomatte_post_ps_.
init();
530 if (is_cryptomatte_pass_enabled && do_cryptomatte_sorting) {
533 cryptomatte_post_ps_.
bind_image(
"cryptomatte_img", &cryptomatte_tx_);
535 cryptomatte_post_ps_.
push_constant(
"cryptomatte_layer_len", cryptomatte_layer_count);
536 cryptomatte_post_ps_.
push_constant(
"cryptomatte_samples_per_layer",
548 VelocityModule &velocity = inst_.
velocity;
550 pass.specialize_constant(sh,
"enabled_categories",
uint(enabled_categories_));
551 pass.specialize_constant(sh,
"samples_len", &data_.
samples_len);
552 pass.specialize_constant(sh,
"use_reprojection", &use_reprojection_);
553 pass.specialize_constant(sh,
"scaling_factor", data_.
scaling_factor);
554 pass.specialize_constant(sh,
"combined_id", &data_.
combined_id);
555 pass.specialize_constant(sh,
"display_id", &data_.
display_id);
556 pass.specialize_constant(sh,
"normal_id", &data_.
normal_id);
564 pass.bind_ubo(
"camera_prev", &(*velocity.camera_steps[
STEP_PREVIOUS]));
565 pass.bind_ubo(
"camera_curr", &(*velocity.camera_steps[
STEP_CURRENT]));
566 pass.bind_ubo(
"camera_next", &(*velocity.camera_steps[step_next]));
567 pass.bind_texture(
"depth_tx", &rbuffers.depth_tx);
568 pass.bind_texture(
"combined_tx", &combined_final_tx_);
569 pass.bind_texture(
"vector_tx", &rbuffers.vector_tx);
570 pass.bind_texture(
"rp_color_tx", &rbuffers.rp_color_tx);
571 pass.bind_texture(
"rp_value_tx", &rbuffers.rp_value_tx);
572 pass.bind_texture(
"cryptomatte_tx", &rbuffers.cryptomatte_tx);
576 pass.bind_image(
"in_weight_img", &weight_tx_.current());
577 pass.bind_image(
"out_weight_img", &weight_tx_.next());
578 pass.bind_texture(
"in_combined_tx", &combined_tx_.current(), filter);
579 pass.bind_image(
"out_combined_img", &combined_tx_.next());
580 pass.bind_image(
"depth_img", &depth_tx_);
581 pass.bind_image(
"color_accum_img", &color_accum_tx_);
582 pass.bind_image(
"value_accum_img", &value_accum_tx_);
583 pass.bind_image(
"cryptomatte_img", &cryptomatte_tx_);
593 use_reprojection_ =
false;
613 const float bias = 0.5f;
627 const int render_pixel_per_final_pixel =
square_i(scale);
630 int prime = (render_pixel_per_final_pixel / 2) - 1;
633 int2 pixel_co =
int2(index % scale, index / scale);
635 jitter /=
float(scale);
637 jitter += ((
float2(pixel_co) + 0.5f) / scale) - 0.5f;
648 return enabled_passes_;
674void Film::update_sample_table()
688 for (
int y = 0; y <= 1; y++) {
689 for (
int x = 0; x <= 1; x++) {
708 int closest_index = 0;
709 float closest_distance =
FLT_MAX;
712 for (
int y = -filter_radius_ceil; y <= filter_radius_ceil; y++) {
713 for (
int x = -filter_radius_ceil; x <= filter_radius_ceil; x++) {
716 if (distance_sqr < filter_radius_sqr) {
726 if (distance_sqr < closest_distance) {
727 closest_distance = distance_sqr;
735 if (closest_index != 0) {
749 for (FilmSample &
sample : sample_table) {
775 float4 clear_color = {0.0f, 0.0f, 0.0f, 0.0f};
781 update_sample_table();
783 combined_final_tx_ = combined_final_tx;
841 *(
reinterpret_cast<float3 *
>(
result) + px) = *(
reinterpret_cast<float3 *
>(result + px * 4));
855 combined_tx_.current() :
858 (is_cryptomatte ? cryptomatte_tx_ :
859 (is_value ? value_accum_tx_ : color_accum_tx_));
867 return accum_tx.
layer_view(index + layer_offset);
920 viewport_compositor_enabled_passes_ & (1 << i));
921 if (pass_type == 0) {
945 const char *pass_name = pass_names[pass_offset].c_str();
949 PassSimple write_pass_ps = {
"Film.WriteViewportCompositorPass"};
954 write_pass_ps.
bind_image(
"output_img", output_pass_texture);
975 PassSimple write_pass_ps = {
"Film.WriteViewportCompositorPass"};
980 write_pass_ps.
bind_image(
"output_img", output_pass_texture);
int BKE_render_preview_pixel_size(const RenderData *r)
#define BLI_assert_msg(a, msg)
BLI_INLINE unsigned int BLI_hash_string(const char *str)
void * BLI_findstring(const struct ListBase *listbase, const char *id, int offset) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
#define LISTBASE_FOREACH(type, var, list)
MINLINE uint divide_ceil_u(uint a, uint b)
MINLINE float pow2f(float x)
MINLINE float clamp_f(float value, float min, float max)
MINLINE int square_i(int a)
MINLINE float square_f(float a)
BLI_INLINE int BLI_rcti_size_y(const struct rcti *rct)
void BLI_rcti_init(struct rcti *rect, int xmin, int xmax, int ymin, int ymax)
BLI_INLINE int BLI_rcti_size_x(const struct rcti *rct)
bool BLI_rcti_is_empty(const struct rcti *rect)
#define SET_FLAG_FROM_TEST(value, test, flag)
@ VIEW_LAYER_CRYPTOMATTE_MATERIAL
@ VIEW_LAYER_CRYPTOMATTE_ASSET
@ VIEW_LAYER_CRYPTOMATTE_OBJECT
#define EEVEE_RENDER_PASS_MAX_BIT
@ EEVEE_RENDER_PASS_UNUSED_8
@ EEVEE_RENDER_PASS_CRYPTOMATTE_MATERIAL
@ EEVEE_RENDER_PASS_NORMAL
@ EEVEE_RENDER_PASS_UNUSED_14
@ EEVEE_RENDER_PASS_CRYPTOMATTE_OBJECT
@ EEVEE_RENDER_PASS_DIFFUSE_LIGHT
@ EEVEE_RENDER_PASS_VOLUME_LIGHT
@ EEVEE_RENDER_PASS_DIFFUSE_COLOR
@ EEVEE_RENDER_PASS_CRYPTOMATTE_ASSET
@ EEVEE_RENDER_PASS_ENVIRONMENT
@ EEVEE_RENDER_PASS_COMBINED
@ EEVEE_RENDER_PASS_SPECULAR_LIGHT
@ EEVEE_RENDER_PASS_VECTOR
@ EEVEE_RENDER_PASS_SPECULAR_COLOR
@ EEVEE_RENDER_PASS_TRANSPARENT
@ EEVEE_RENDER_PASS_SHADOW
@ EEVEE_RENDER_PASS_POSITION
@ WO_MIST_INVERSE_QUADRATIC
void GPU_framebuffer_bind(GPUFrameBuffer *framebuffer)
void GPU_framebuffer_clear_color(GPUFrameBuffer *fb, const float clear_col[4])
void GPU_framebuffer_viewport_set(GPUFrameBuffer *framebuffer, int x, int y, int width, int height)
void GPU_memory_barrier(eGPUBarrier barrier)
@ GPU_BARRIER_TEXTURE_FETCH
@ GPU_BARRIER_SHADER_IMAGE_ACCESS
@ GPU_BARRIER_TEXTURE_UPDATE
int GPU_texture_height(const GPUTexture *texture)
int GPU_texture_width(const GPUTexture *texture)
void * GPU_texture_read(GPUTexture *texture, eGPUDataFormat data_format, int mip_level)
@ GPU_SAMPLER_FILTERING_LINEAR
eGPUTextureFormat GPU_texture_format(const GPUTexture *texture)
struct GPUShader GPUShader
void reset()
clear internal cached data and reset random seed
bool contains(const Key &key) const
void submit(PassSimple &pass, View &view)
void acquire(int2 extent, eGPUTextureFormat format, eGPUTextureUsage usage=GPU_TEXTURE_USAGE_GENERAL)
void clear(float4 values)
bool ensure_2d_array(eGPUTextureFormat format, int2 extent, int layers, eGPUTextureUsage usage=GPU_TEXTURE_USAGE_GENERAL, const float *data=nullptr, int mip_len=1)
bool ensure_layer_views(bool cube_as_array=false)
bool ensure_2d(eGPUTextureFormat format, int2 extent, eGPUTextureUsage usage=GPU_TEXTURE_USAGE_GENERAL, const float *data=nullptr, int mip_len=1)
GPUTexture * layer_view(int layer)
int3 size(int miplvl=0) const
void bind_texture(const char *name, GPUTexture *texture, GPUSamplerState state=sampler_auto)
void bind_resources(U &resources)
void bind_image(const char *name, GPUTexture *image)
void draw_procedural(GPUPrimType primitive, uint instance_len, uint vertex_len, uint vertex_first=-1, ResourceHandle handle={0}, uint custom_id=0)
void dispatch(int group_len)
void barrier(eGPUBarrier type)
void state_set(DRWState state, int clip_plane_count=0)
void push_constant(const char *name, const float &data)
void shader_set(GPUShader *shader)
bool is_panoramic() const
const CameraData & data_get() const
float2 pixel_jitter_get() const
int pass_id_get(eViewLayerEEVEEPassType pass_type) const
static bool pass_is_float3(eViewLayerEEVEEPassType pass_type)
GPUTexture * get_aov_texture(ViewLayerAOV *aov)
void accumulate(View &view, GPUTexture *combined_final_tx)
static const Vector< std::string > pass_to_render_pass_names(eViewLayerEEVEEPassType pass_type, const ViewLayer *view_layer)
int cryptomatte_layer_max_get() const
int cryptomatte_layer_len_get() const
static ePassStorageType pass_storage_type(eViewLayerEEVEEPassType pass_type)
float * read_pass(eViewLayerEEVEEPassType pass_type, int layer_offset)
void write_viewport_compositor_passes()
static int overscan_pixels_get(float overscan, int2 extent)
bool is_viewport_compositor_enabled() const
AOVsInfoDataBuf aovs_info
void init(const int2 &full_extent, const rcti *output_rect)
float * read_aov(ViewLayerAOV *aov)
GPUTexture * get_pass_texture(eViewLayerEEVEEPassType pass_type, int layer_offset)
eViewLayerEEVEEPassType enabled_passes_get() const
static constexpr bool use_box_filter
void info_append_i18n(const char *msg, Args &&...args)
bool gpencil_engine_enabled() const
bool overlays_enabled() const
RenderBuffers render_buffers
UniformDataModule uniform_data
TextureFromPool combined_tx
void acquire(int2 extent)
uint64_t sample_index() const
bool interactive_mode() const
static float2 sample_disk(const float2 &rand)
float2 rng_2d_get(eSamplingDimension starting_dimension) const
static float2 sample_spiral(const float2 &rand)
GPUShader * static_shader_get(eShaderType shader_type)
local_group_size(16, 16) .push_constant(Type b
additional_info("compositor_sum_float_shared") .push_constant(Type additional_info("compositor_sum_float_shared") .push_constant(Type GPU_RGBA32F
blender::draw::Manager * DRW_manager_get()
DefaultFramebufferList * DRW_viewport_framebuffer_list_get()
blender::draw::TextureFromPool & DRW_viewport_pass_texture_get(const char *pass_name)
DefaultTextureList * DRW_viewport_texture_list_get()
bool DRW_is_viewport_compositor_enabled()
const DRWView * DRW_view_default_get()
#define ENABLE_FROM_LEGACY(name_legacy, name_eevee)
draw_view in_light_buf[] float
draw_view push_constant(Type::INT, "radiance_src") .push_constant(Type capture_info_buf storage_buf(1, Qualifier::READ, "ObjectBounds", "bounds_buf[]") .push_constant(Type draw_view int
#define FILM_PRECOMP_SAMPLE_MAX
Set< std::string > get_used_passes(const Scene &scene, const ViewLayer *view_layer)
@ FILM_PASS_CONVERT_COMBINED
@ FILM_PASS_CONVERT_CRYPTOMATTE
@ FILM_PASS_CONVERT_COLOR
@ FILM_PASS_CONVERT_VALUE
@ FILM_PASS_CONVERT_DEPTH
static eShaderType get_write_pass_shader_type(eViewLayerEEVEEPassType pass_type)
static float film_filter_weight(float filter_radius, float sample_distance_sqr)
bool operator!=(const CameraData &a, const CameraData &b)
static eShaderType get_aov_write_pass_shader_type(const ViewLayerAOV *aov)
static eViewLayerEEVEEPassType enabled_passes(const ViewLayer *view_layer)
bool operator==(const CameraData &a, const CameraData &b)
static eViewLayerEEVEEPassType get_viewport_compositor_enabled_passes(const Set< std::string > &viewport_compositor_needed_passes, const ViewLayer *view_layer)
@ PASS_STORAGE_CRYPTOMATTE
@ PASS_CATEGORY_CRYPTOMATTE
T length_squared(const VecBase< T, Size > &a)
VecBase< T, Size > divide_ceil(const VecBase< T, Size > &a, const VecBase< T, Size > &b)
VecBase< float, 4 > float4
VecBase< int32_t, 2 > int2
VecBase< float, 2 > float2
VecBase< int32_t, 3 > int3
unsigned __int64 uint64_t
GPUFrameBuffer * default_fb
float studiolight_background
struct ViewLayerEEVEE eevee
bool32_t display_is_value
uint4 hash_value[AOV_MAX]
uint4 hash_color[AOV_MAX]
int cryptomatte_samples_len
ePassStorageType display_storage_type
float samples_weight_total
int cryptomatte_material_id
int cryptomatte_object_id
FilmSample samples[FILM_PRECOMP_SAMPLE_MAX]