46void *Instance::debug_scope_render_sample =
nullptr;
47void *Instance::debug_scope_irradiance_setup =
nullptr;
48void *Instance::debug_scope_irradiance_sample =
nullptr;
79 rcti visible_rect = rect;
90 if (!is_default_border && use_border) {
114 if (
draw_ctx->is_viewport_image_render()) {
116 visible_rect.
xmax = vp_size[0];
117 visible_rect.
ymax = vp_size[1];
118 visible_rect.
xmin = visible_rect.
ymin = 0;
129 const rcti *output_rect,
130 const rcti *visible_rect,
132 Depsgraph *depsgraph_,
149 update_eval_members();
170 if (output_res !=
film.display_extent_get()) {
176 if (offset !=
film.get_data().offset || extent !=
film.get_data().extent) {
196 film.init(output_res, output_rect);
234 bool ready =
shaders.request_specializations(
265 update_eval_members();
274 rcti empty_rect{0, 0, 0, 0};
297void Instance::set_time(
float time)
301 update_eval_members();
304void Instance::update_eval_members()
375 const bool is_renderable_type =
ELEM(ob->
type,
389 if (!is_renderable_type || (!partsys_is_visible && !object_is_visible)) {
395 if (partsys_is_visible && ob !=
draw_ctx->object_edit) {
399 ob_ref, ob->object_to_world());
400 sync.sync_curves(ob, hair_handle, ob_ref, _res_handle, &md, &particle_sys);
405 if (object_is_visible) {
408 lights.sync_light(ob, ob_handle);
411 if (!
sync.sync_sculpt(ob, ob_handle, ob_ref)) {
412 sync.sync_mesh(ob, ob_handle, ob_ref);
416 sync.sync_pointcloud(ob, ob_handle, ob_ref);
419 sync.sync_volume(ob, ob_handle, ob_ref);
422 sync.sync_curves(ob, ob_handle, ob_ref);
442 bool use_volume =
volume.will_enable();
498 return (
materials.queued_shaders_count == 0) && (
materials.queued_textures_count == 0) &&
509 return (
materials.queued_shaders_count == 0) && (
materials.queued_textures_count == 0) &&
519void Instance::render_sample()
543 DebugScope debug_scope(debug_scope_render_sample,
"EEVEE.render_sample");
563void Instance::render_read_result(RenderLayer *render_layer,
const char *view_name)
569 if (pass_type == 0) {
574 for (
int64_t pass_offset : IndexRange(pass_names.
size())) {
576 render_layer, pass_names[pass_offset].c_str(), view_name);
580 float *
result =
film.read_pass(pass_type, pass_offset);
618 for (
const std::string &vector_pass_name :
626 sizeof(
float) * 4 * vector_rp->
rectx * vector_rp->
recty);
643 if (!info_.empty()) {
651 this->render_sample();
653 if ((
sampling.sample_index() == 1) || ((
sampling.sample_index() % 25) == 0) ||
657 std::string re_info =
"Rendering " + std::to_string(
sampling.sample_index()) +
" / " +
658 std::to_string(
sampling.sample_count()) +
" samples";
674 if (
G.background ==
false && first_read) {
686 this->
film.cryptomatte_sort();
690 if (!info_.empty()) {
692 engine,
RPT_(
"Errors during render. See the System Console for more info."));
693 printf(
"%s", info_.c_str());
721 this->
film.write_viewport_compositor_passes();
732 if (
materials.queued_textures_count > 0) {
735 if (
materials.queued_shaders_count > 0) {
744 "Setting Preferences > System > Shader Compilation Method to Subprocess might improve "
745 "compilation time.");
750 else if (
materials.queued_optimize_shaders_count > 0) {
763 this->render_sample();
764 }
while (!
sampling.finished_viewport());
768 this->
film.write_viewport_compositor_passes();
797#define CHECK_PASS_LEGACY(name, type, channels, chanid) \
798 if (view_layer->passflag & (SCE_PASS_##name)) { \
799 RE_engine_register_pass( \
800 engine, scene, view_layer, RE_PASSNAME_##name, channels, chanid, type); \
803#define CHECK_PASS_EEVEE(name, type, channels, chanid) \
804 if (view_layer->eevee.render_passes & (EEVEE_RENDER_PASS_##name)) { \
805 RE_engine_register_pass( \
806 engine, scene, view_layer, RE_PASSNAME_##name, channels, chanid, type); \
847 if (
view_layer->cryptomatte_flag & cryptomatte_layer) {
873 auto custom_pipeline_wrapper = [&](
FunctionRef<void()> callback) {
881 auto context_wrapper = [&](
FunctionRef<void()> callback) {
889 custom_pipeline_wrapper([&]() {
892 while ((
materials.queued_shaders_count > 0) || (
materials.queued_textures_count > 0)) {
909 DebugScope debug_scope(debug_scope_irradiance_setup,
"EEVEE.irradiance_setup");
939 float time_per_sample_ms_smooth = 16.0f;
942 context_wrapper([&]() {
943 DebugScope debug_scope(debug_scope_irradiance_sample,
"EEVEE.irradiance_sample");
947 int time_budget_ms =
G.background ? 32 : 16;
949 int sample_count_in_batch =
ceilf(time_budget_ms /
max(0.1f, time_per_sample_ms_smooth));
951 sample_count_in_batch =
min_iii(32, sample_count_in_batch, remaining_samples);
956 for (
int i = 0;
i < sample_count_in_batch && !
sampling.finished();
i++) {
975 float time_per_sample_ms =
float(time_it_end_ms - time_it_begin_ms) / sample_count_in_batch;
977 time_per_sample_ms_smooth =
interpolate(time_per_sample_ms_smooth, time_per_sample_ms, 0.7f);
980 result_update(
volume_probes.bake.read_result_packed(), 1.0f);
985 if (time_since_last_update_ms > 1.0) {
987 result_update(
volume_probes.bake.read_result_unpacked(), progress);
General operations, lookup, etc. for blender objects.
#define LISTBASE_FOREACH(type, var, list)
MINLINE int min_iii(int a, int b, int c)
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)
void BLI_rctf_init(struct rctf *rect, float xmin, float xmax, float ymin, float ymax)
BLI_INLINE int BLI_rcti_size_x(const struct rcti *rct)
BLI_INLINE float BLI_rctf_size_x(const struct rctf *rct)
BLI_INLINE float BLI_rctf_size_y(const struct rctf *rct)
bool BLI_rctf_compare(const struct rctf *rect_a, const struct rctf *rect_b, float limit)
char * STRNCPY(char(&dst)[N], const char *src)
void BLI_mutex_lock(ThreadMutex *mutex)
void BLI_mutex_unlock(ThreadMutex *mutex)
Platform independent time functions.
double BLI_time_now_seconds(void)
#define SET_FLAG_FROM_TEST(value, test, flag)
#define CLOG_INFO(clg_ref,...)
uint64_t DEG_get_update_count(const Depsgraph *depsgraph)
Scene * DEG_get_evaluated_scene(const Depsgraph *graph)
ViewLayer * DEG_get_evaluated_view_layer(const Depsgraph *graph)
T * DEG_get_evaluated(const Depsgraph *depsgraph, T *id)
eViewLayerCryptomatteFlags
@ VIEW_LAYER_CRYPTOMATTE_MATERIAL
@ VIEW_LAYER_CRYPTOMATTE_ASSET
@ VIEW_LAYER_CRYPTOMATTE_OBJECT
#define EEVEE_RENDER_PASS_MAX_BIT
@ EEVEE_RENDER_PASS_CRYPTOMATTE_MATERIAL
@ EEVEE_RENDER_PASS_CRYPTOMATTE_OBJECT
@ EEVEE_RENDER_PASS_CRYPTOMATTE_ASSET
@ EEVEE_RENDER_PASS_VECTOR
struct ViewLayerAOV ViewLayerAOV
#define RE_PASSNAME_COMBINED
@ SCE_EEVEE_SHADOW_JITTERED_VIEWPORT
void DRW_submission_end()
void DRW_render_context_disable(Render *render)
void DRW_submission_start()
void DRW_render_context_enable(Render *render)
const rcti * ED_region_visible_rect(ARegion *region)
void ED_view3d_calc_camera_border(const Scene *scene, const Depsgraph *depsgraph, const ARegion *region, const View3D *v3d, const RegionView3D *rv3d, bool no_shift, rctf *r_viewborder)
bool GPU_use_subprocess_compilation()
void GPU_render_step(bool force_resource_release=false)
GPUBackendType GPU_backend_get_type()
void GPU_framebuffer_viewport_reset(blender::gpu::FrameBuffer *fb)
void GPU_framebuffer_clear_color_depth(blender::gpu::FrameBuffer *fb, const float clear_col[4], float clear_depth)
void GPU_pass_cache_wait_for_all()
int GPU_texture_height(const blender::gpu::Texture *texture)
int GPU_texture_width(const blender::gpu::Texture *texture)
BPy_StructRNA * depsgraph
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
static View & default_get()
static bool do_merge_direct_indirect_eval(const Instance &inst)
static bool do_split_direct_indirect_radiance(const Instance &inst)
static const Vector< std::string > pass_to_render_pass_names(eViewLayerEEVEEPassType pass_type, const ViewLayer *view_layer)
VolumeProbeModule volume_probes
void render_frame(RenderEngine *engine, RenderLayer *render_layer, const char *view_name)
void draw(Manager &manager) final
bool is_viewport_compositor_enabled
SphereProbeModule sphere_probes
ShaderGroups loaded_shaders
AmbientOcclusion ambient_occlusion
RayTraceModule raytracing
void info_append_i18n(const char *msg, Args &&...args)
SubsurfaceModule subsurface
Object * camera_eval_object
ShaderGroups needed_shaders
void light_bake_irradiance(Object &probe, FunctionRef< void()> context_enable, FunctionRef< void()> context_disable, FunctionRef< bool()> stop, FunctionRef< void(LightProbeGridCacheFrame *, float progress)> result_update)
bool needs_lightprobe_sphere_passes() const
bool needs_planar_probe_passes() const
void object_sync(ObjectRef &ob_ref, Manager &manager) final
RenderBuffers render_buffers
const RenderLayer * render_layer
const DRWContext * draw_ctx
bool is_viewport_image_render
const RegionView3D * rv3d
void store_metadata(RenderResult *render_result)
DepthOfField depth_of_field
PlanarProbeModule planar_probes
void draw_viewport_image_render()
static void update_passes(RenderEngine *engine, Scene *scene, ViewLayer *view_layer)
bool is_loaded(ShaderGroups groups) const
bool do_lightprobe_sphere_sync() const
UniformDataModule uniform_data
LightProbeModule light_probes
MotionBlurModule motion_blur
void init_light_bake(Depsgraph *depsgraph, draw::Manager *manager)
Object * camera_orig_object
bool do_planar_probe_sync() const
int64_t queued_textures_count
int64_t queued_shaders_count
bool finished_viewport() const
bool do_render_sync() const
const DRWContext * DRW_context_get()
void DRW_custom_pipeline_begin(DRWContext &draw_ctx, Depsgraph *)
void DRW_render_object_iter(RenderEngine *engine, Depsgraph *depsgraph, std::function< void(blender::draw::ObjectRef &, RenderEngine *, Depsgraph *)> callback)
bool DRW_object_is_renderable(const Object *ob)
int DRW_object_visibility_in_active_context(const Object *ob)
void DRW_render_set_time(RenderEngine *engine, Depsgraph *depsgraph, int frame, float subframe)
void DRW_custom_pipeline_end(DRWContext &draw_ctx)
void DRW_viewport_request_redraw()
Simple API to draw debug shapes and log in the viewport.
blender::draw::Manager * DRW_manager_get()
#define CHECK_PASS_EEVEE(name, type, channels, chanid)
#define CHECK_PASS_LEGACY(name, type, channels, chanid)
void RE_engine_update_stats(RenderEngine *engine, const char *stats, const char *info)
void RE_engine_set_error_message(RenderEngine *engine, const char *msg)
void RE_engine_register_pass(RenderEngine *engine, Scene *scene, ViewLayer *view_layer, const char *name, int channels, const char *chanid, eNodeSocketDatatype type)
void RE_engine_update_progress(RenderEngine *engine, float progress)
@ DEFERRED_CAPTURE_SHADERS
@ DEFERRED_LIGHTING_SHADERS
@ IRRADIANCE_BAKE_SHADERS
@ DEFERRED_PLANAR_SHADERS
void foreach_hair_particle_handle(Instance &inst, ObjectRef &ob_ref, ObjectHandle ob_handle, HairHandleCallback callback)
T interpolate(const T &a, const T &b, const FactorT &t)
bool assign_if_different(T &old_value, T new_value)
VecBase< float, 4 > float4
VecBase< int32_t, 2 > int2
VecBase< float, 2 > float2
void RE_pass_set_buffer_data(RenderPass *pass, float *data)
RenderPass * RE_pass_find_by_name(RenderLayer *rl, const char *name, const char *viewname)
blender::gpu::FrameBuffer * default_fb
blender::gpu::Texture * color
ImBufFloatBuffer float_buffer