Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/engines/eevee_next/eevee_film.hh
| Show All 37 Lines | public: | ||||
| static constexpr bool use_box_filter = false; | static constexpr bool use_box_filter = false; | ||||
| private: | private: | ||||
| Instance &inst_; | Instance &inst_; | ||||
| /** Incoming combined buffer with post FX applied (motion blur + depth of field). */ | /** Incoming combined buffer with post FX applied (motion blur + depth of field). */ | ||||
| GPUTexture *combined_final_tx_ = nullptr; | GPUTexture *combined_final_tx_ = nullptr; | ||||
| /** Main accumulation textures containing every render-pass except depth and combined. */ | /** | ||||
| * Main accumulation textures containing every render-pass except depth, cryptomatte and | |||||
| * combined. | |||||
| */ | |||||
| Texture color_accum_tx_; | Texture color_accum_tx_; | ||||
| Texture value_accum_tx_; | Texture value_accum_tx_; | ||||
| /** Depth accumulation texture. Separated because using a different format. */ | /** Depth accumulation texture. Separated because using a different format. */ | ||||
| Texture depth_tx_; | Texture depth_tx_; | ||||
| /** Cryptomatte texture. Separated because it requires full floats. */ | |||||
| Texture cryptomatte_tx_; | |||||
| /** Combined "Color" buffer. Double buffered to allow re-projection. */ | /** Combined "Color" buffer. Double buffered to allow re-projection. */ | ||||
| SwapChain<Texture, 2> combined_tx_; | SwapChain<Texture, 2> combined_tx_; | ||||
| /** Weight buffers. Double buffered to allow updating it during accumulation. */ | /** Weight buffers. Double buffered to allow updating it during accumulation. */ | ||||
| SwapChain<Texture, 2> weight_tx_; | SwapChain<Texture, 2> weight_tx_; | ||||
| /** User setting to disable reprojection. Useful for debugging or have a more precise render. */ | /** User setting to disable reprojection. Useful for debugging or have a more precise render. */ | ||||
| bool force_disable_reprojection_ = false; | bool force_disable_reprojection_ = false; | ||||
| PassSimple accumulate_ps_ = {"Film.Accumulate"}; | PassSimple accumulate_ps_ = {"Film.Accumulate"}; | ||||
| PassSimple cryptomatte_post_ps_ = {"Film.Cryptomatte.Post"}; | |||||
| FilmDataBuf data_; | FilmDataBuf data_; | ||||
| eViewLayerEEVEEPassType enabled_passes_ = eViewLayerEEVEEPassType(0); | eViewLayerEEVEEPassType enabled_passes_ = eViewLayerEEVEEPassType(0); | ||||
| public: | public: | ||||
| Film(Instance &inst) : inst_(inst){}; | Film(Instance &inst) : inst_(inst){}; | ||||
| ~Film(){}; | ~Film(){}; | ||||
| void init(const int2 &full_extent, const rcti *output_rect); | void init(const int2 &full_extent, const rcti *output_rect); | ||||
| void sync(); | void sync(); | ||||
| void end_sync(); | void end_sync(); | ||||
| /** Accumulate the newly rendered sample contained in #RenderBuffers and blit to display. */ | /** Accumulate the newly rendered sample contained in #RenderBuffers and blit to display. */ | ||||
| void accumulate(const DRWView *view, GPUTexture *combined_final_tx); | void accumulate(const DRWView *view, GPUTexture *combined_final_tx); | ||||
| /** Sort and normalize cryptomatte samples. */ | |||||
| void cryptomatte_sort(); | |||||
| /** Blit to display. No rendered sample needed. */ | /** Blit to display. No rendered sample needed. */ | ||||
| void display(); | void display(); | ||||
| float *read_pass(eViewLayerEEVEEPassType pass_type); | float *read_pass(eViewLayerEEVEEPassType pass_type, int layer_offset); | ||||
| float *read_aov(ViewLayerAOV *aov); | float *read_aov(ViewLayerAOV *aov); | ||||
| /** Returns shading views internal resolution. */ | /** Returns shading views internal resolution. */ | ||||
| int2 render_extent_get() const | int2 render_extent_get() const | ||||
| { | { | ||||
| return data_.render_extent; | return data_.render_extent; | ||||
| } | } | ||||
| float2 pixel_jitter_get() const; | float2 pixel_jitter_get() const; | ||||
| float background_opacity_get() const | float background_opacity_get() const | ||||
| { | { | ||||
| return data_.background_opacity; | return data_.background_opacity; | ||||
| } | } | ||||
| eViewLayerEEVEEPassType enabled_passes_get() const; | eViewLayerEEVEEPassType enabled_passes_get() const; | ||||
| int cryptomatte_layer_max_get() const; | |||||
| int cryptomatte_layer_len_get() const; | |||||
| static bool pass_is_value(eViewLayerEEVEEPassType pass_type) | static ePassStorageType pass_storage_type(eViewLayerEEVEEPassType pass_type) | ||||
fclem: Make the Cryptomatte a friend of the Film class. But maybe better to merge the sorting to the… | |||||
Done Inline ActionsY jbakker: Y | |||||
| { | { | ||||
| switch (pass_type) { | switch (pass_type) { | ||||
| case EEVEE_RENDER_PASS_Z: | case EEVEE_RENDER_PASS_Z: | ||||
| case EEVEE_RENDER_PASS_MIST: | case EEVEE_RENDER_PASS_MIST: | ||||
| case EEVEE_RENDER_PASS_SHADOW: | case EEVEE_RENDER_PASS_SHADOW: | ||||
| case EEVEE_RENDER_PASS_AO: | case EEVEE_RENDER_PASS_AO: | ||||
| return true; | return PASS_STORAGE_VALUE; | ||||
| case EEVEE_RENDER_PASS_CRYPTOMATTE_OBJECT: | |||||
| case EEVEE_RENDER_PASS_CRYPTOMATTE_ASSET: | |||||
| case EEVEE_RENDER_PASS_CRYPTOMATTE_MATERIAL: | |||||
| return PASS_STORAGE_CRYPTOMATTE; | |||||
| default: | default: | ||||
| return false; | return PASS_STORAGE_COLOR; | ||||
| } | } | ||||
| } | } | ||||
| static bool pass_is_float3(eViewLayerEEVEEPassType pass_type) | static bool pass_is_float3(eViewLayerEEVEEPassType pass_type) | ||||
| { | { | ||||
| switch (pass_type) { | switch (pass_type) { | ||||
| case EEVEE_RENDER_PASS_NORMAL: | case EEVEE_RENDER_PASS_NORMAL: | ||||
| case EEVEE_RENDER_PASS_DIFFUSE_LIGHT: | case EEVEE_RENDER_PASS_DIFFUSE_LIGHT: | ||||
| Show All 34 Lines | switch (pass_type) { | ||||
| case EEVEE_RENDER_PASS_EMIT: | case EEVEE_RENDER_PASS_EMIT: | ||||
| return data_.emission_id; | return data_.emission_id; | ||||
| case EEVEE_RENDER_PASS_ENVIRONMENT: | case EEVEE_RENDER_PASS_ENVIRONMENT: | ||||
| return data_.environment_id; | return data_.environment_id; | ||||
| case EEVEE_RENDER_PASS_SHADOW: | case EEVEE_RENDER_PASS_SHADOW: | ||||
| return data_.shadow_id; | return data_.shadow_id; | ||||
| case EEVEE_RENDER_PASS_AO: | case EEVEE_RENDER_PASS_AO: | ||||
| return data_.ambient_occlusion_id; | return data_.ambient_occlusion_id; | ||||
| case EEVEE_RENDER_PASS_CRYPTOMATTE: | case EEVEE_RENDER_PASS_CRYPTOMATTE_OBJECT: | ||||
| return -1; /* TODO */ | return data_.cryptomatte_object_id; | ||||
| case EEVEE_RENDER_PASS_CRYPTOMATTE_ASSET: | |||||
| return data_.cryptomatte_asset_id; | |||||
| case EEVEE_RENDER_PASS_CRYPTOMATTE_MATERIAL: | |||||
| return data_.cryptomatte_material_id; | |||||
| case EEVEE_RENDER_PASS_VECTOR: | case EEVEE_RENDER_PASS_VECTOR: | ||||
| return data_.vector_id; | return data_.vector_id; | ||||
| default: | default: | ||||
| return -1; | return -1; | ||||
| } | } | ||||
| } | } | ||||
| static const char *pass_to_render_pass_name(eViewLayerEEVEEPassType pass_type) | static const Vector<std::string> pass_to_render_pass_names(eViewLayerEEVEEPassType pass_type, | ||||
| const ViewLayer *view_layer) | |||||
| { | { | ||||
| Vector<std::string> result; | |||||
| auto build_cryptomatte_passes = [&](const char *pass_name) { | |||||
| const int num_cryptomatte_passes = (view_layer->cryptomatte_levels + 1) / 2; | |||||
| for (int pass = 0; pass < num_cryptomatte_passes; pass++) { | |||||
| std::stringstream ss; | |||||
| ss.fill('0'); | |||||
| ss << pass_name; | |||||
| ss.width(2); | |||||
| ss << pass; | |||||
| result.append(ss.str()); | |||||
| } | |||||
| }; | |||||
| switch (pass_type) { | switch (pass_type) { | ||||
| case EEVEE_RENDER_PASS_COMBINED: | case EEVEE_RENDER_PASS_COMBINED: | ||||
| return RE_PASSNAME_COMBINED; | result.append(RE_PASSNAME_COMBINED); | ||||
| break; | |||||
| case EEVEE_RENDER_PASS_Z: | case EEVEE_RENDER_PASS_Z: | ||||
| return RE_PASSNAME_Z; | result.append(RE_PASSNAME_Z); | ||||
| break; | |||||
| case EEVEE_RENDER_PASS_MIST: | case EEVEE_RENDER_PASS_MIST: | ||||
| return RE_PASSNAME_MIST; | result.append(RE_PASSNAME_MIST); | ||||
| break; | |||||
| case EEVEE_RENDER_PASS_NORMAL: | case EEVEE_RENDER_PASS_NORMAL: | ||||
| return RE_PASSNAME_NORMAL; | result.append(RE_PASSNAME_NORMAL); | ||||
| break; | |||||
| case EEVEE_RENDER_PASS_DIFFUSE_LIGHT: | case EEVEE_RENDER_PASS_DIFFUSE_LIGHT: | ||||
| return RE_PASSNAME_DIFFUSE_DIRECT; | result.append(RE_PASSNAME_DIFFUSE_DIRECT); | ||||
| break; | |||||
| case EEVEE_RENDER_PASS_DIFFUSE_COLOR: | case EEVEE_RENDER_PASS_DIFFUSE_COLOR: | ||||
| return RE_PASSNAME_DIFFUSE_COLOR; | result.append(RE_PASSNAME_DIFFUSE_COLOR); | ||||
| break; | |||||
| case EEVEE_RENDER_PASS_SPECULAR_LIGHT: | case EEVEE_RENDER_PASS_SPECULAR_LIGHT: | ||||
| return RE_PASSNAME_GLOSSY_DIRECT; | result.append(RE_PASSNAME_GLOSSY_DIRECT); | ||||
| break; | |||||
| case EEVEE_RENDER_PASS_SPECULAR_COLOR: | case EEVEE_RENDER_PASS_SPECULAR_COLOR: | ||||
| return RE_PASSNAME_GLOSSY_COLOR; | result.append(RE_PASSNAME_GLOSSY_COLOR); | ||||
| break; | |||||
| case EEVEE_RENDER_PASS_VOLUME_LIGHT: | case EEVEE_RENDER_PASS_VOLUME_LIGHT: | ||||
| return RE_PASSNAME_VOLUME_LIGHT; | result.append(RE_PASSNAME_VOLUME_LIGHT); | ||||
| break; | |||||
| case EEVEE_RENDER_PASS_EMIT: | case EEVEE_RENDER_PASS_EMIT: | ||||
| return RE_PASSNAME_EMIT; | result.append(RE_PASSNAME_EMIT); | ||||
| break; | |||||
| case EEVEE_RENDER_PASS_ENVIRONMENT: | case EEVEE_RENDER_PASS_ENVIRONMENT: | ||||
| return RE_PASSNAME_ENVIRONMENT; | result.append(RE_PASSNAME_ENVIRONMENT); | ||||
| break; | |||||
| case EEVEE_RENDER_PASS_SHADOW: | case EEVEE_RENDER_PASS_SHADOW: | ||||
| return RE_PASSNAME_SHADOW; | result.append(RE_PASSNAME_SHADOW); | ||||
| break; | |||||
| case EEVEE_RENDER_PASS_AO: | case EEVEE_RENDER_PASS_AO: | ||||
| return RE_PASSNAME_AO; | result.append(RE_PASSNAME_AO); | ||||
| case EEVEE_RENDER_PASS_CRYPTOMATTE: | break; | ||||
| BLI_assert_msg(0, "Cryptomatte is not implemented yet."); | case EEVEE_RENDER_PASS_CRYPTOMATTE_OBJECT: | ||||
| return ""; /* TODO */ | build_cryptomatte_passes(RE_PASSNAME_CRYPTOMATTE_OBJECT); | ||||
| break; | |||||
| case EEVEE_RENDER_PASS_CRYPTOMATTE_ASSET: | |||||
| build_cryptomatte_passes(RE_PASSNAME_CRYPTOMATTE_ASSET); | |||||
| break; | |||||
| case EEVEE_RENDER_PASS_CRYPTOMATTE_MATERIAL: | |||||
| build_cryptomatte_passes(RE_PASSNAME_CRYPTOMATTE_MATERIAL); | |||||
| break; | |||||
| case EEVEE_RENDER_PASS_VECTOR: | case EEVEE_RENDER_PASS_VECTOR: | ||||
| return RE_PASSNAME_VECTOR; | result.append(RE_PASSNAME_VECTOR); | ||||
| break; | |||||
| default: | default: | ||||
| BLI_assert(0); | BLI_assert(0); | ||||
| return ""; | break; | ||||
| } | } | ||||
| return result; | |||||
| } | } | ||||
| private: | private: | ||||
| void init_aovs(); | void init_aovs(); | ||||
| void sync_mist(); | void sync_mist(); | ||||
| /** | /** | ||||
| * Precompute sample weights if they are uniform across the whole film extent. | * Precompute sample weights if they are uniform across the whole film extent. | ||||
| */ | */ | ||||
| void update_sample_table(); | void update_sample_table(); | ||||
| }; | }; | ||||
| /** \} */ | /** \} */ | ||||
| } // namespace blender::eevee | } // namespace blender::eevee | ||||
Make the Cryptomatte a friend of the Film class. But maybe better to merge the sorting to the Film struct.