22 #include "util/color.h"
45 BL::Preferences &b_userpref,
46 BL::BlendData &b_data,
52 b_userpref(b_userpref),
54 b_render(b_engine.render()),
61 preview_osl(preview_osl),
62 python_thread_state(
NULL),
63 use_developer_ui(false)
73 BL::Preferences &b_userpref,
74 BL::BlendData &b_data,
75 BL::SpaceView3D &b_v3d,
83 b_userpref(b_userpref),
85 b_render(b_engine.render()),
93 python_thread_state(
NULL),
94 use_developer_ui(b_userpref.experimental().use_cycles_debug() &&
95 b_userpref.
view().show_developer_ui())
163 this->
b_scene = b_depsgraph.scene_eval();
183 if (is_new_session) {
202 !this->b_render.use_persistent_data()) {
206 if (!is_new_session) {
220 if (is_new_session) {
272 string prefix =
"cryptomatte/" + identifier.substr(0, 7) +
"/";
283 string prefix =
"cycles." + view_layer_name +
".";
286 b_rr.stamp_data_add_field((prefix +
"samples").c_str(),
292 if (
session->tile_manager.range_num_samples != -1) {
293 b_rr.stamp_data_add_field((prefix +
"range_start_sample").c_str(),
295 b_rr.stamp_data_add_field((prefix +
"range_num_samples").c_str(),
303 view_layer_name +
".CryptoObject",
308 view_layer_name +
".CryptoMaterial",
313 view_layer_name +
".CryptoAsset",
318 double total_time, render_time;
320 b_rr.stamp_data_add_field((prefix +
"total_time").c_str(),
322 b_rr.stamp_data_add_field((prefix +
"render_time").c_str(),
324 b_rr.stamp_data_add_field((prefix +
"synchronization_time").c_str(),
353 BL::RenderResult::layers_iterator b_single_rlay;
354 b_rr.layers.begin(b_single_rlay);
368 BL::RenderResult::views_iterator b_view_iter;
371 for (b_rr.views.begin(b_view_iter); b_view_iter != b_rr.views.end(); ++b_view_iter) {
376 for (b_rr.views.begin(b_view_iter); b_view_iter != b_rr.views.end();
377 ++b_view_iter, ++view_index) {
380 buffer_params.
layer = b_view_layer.name();
406 if (view_index == num_views - 1) {
412 if (view_index != 0) {
423 if (samples != 0 && (!bound_samples || (samples < session_params.
samples))) {
424 effective_session_params.
samples = samples;
428 session->
reset(effective_session_params, buffer_params);
441 printf(
"Render statistics:\n%s\n", stats.
full_report().c_str());
452 b_engine.end_result(b_rr,
true,
false,
false);
457 b_engine.tile_highlight_clear_all();
459 double total_time, render_time;
461 VLOG_INFO <<
"Total render time: " << total_time;
462 VLOG_INFO <<
"Render time (without synchronization): " << render_time;
472 if (!
b_render.use_persistent_data()) {
514 const char *bake_type = bake_type_str.c_str();
517 bool use_direct_light =
false;
518 bool use_indirect_light =
false;
519 bool include_albedo =
false;
522 if (strcmp(bake_type,
"POSITION") == 0) {
525 else if (strcmp(bake_type,
"NORMAL") == 0) {
528 else if (strcmp(bake_type,
"UV") == 0) {
531 else if (strcmp(bake_type,
"ROUGHNESS") == 0) {
534 else if (strcmp(bake_type,
"EMIT") == 0) {
538 else if (strcmp(bake_type,
"ENVIRONMENT") == 0) {
542 else if (strcmp(bake_type,
"AO") == 0) {
546 else if (strcmp(bake_type,
"COMBINED") == 0) {
549 use_direct_light = (bake_filter & BL::BakeSettings::pass_filter_DIRECT) != 0;
550 use_indirect_light = (bake_filter & BL::BakeSettings::pass_filter_INDIRECT) != 0;
551 include_albedo = (bake_filter & BL::BakeSettings::pass_filter_COLOR);
553 integrator->set_use_diffuse((bake_filter & BL::BakeSettings::pass_filter_DIFFUSE) != 0);
554 integrator->set_use_glossy((bake_filter & BL::BakeSettings::pass_filter_GLOSSY) != 0);
555 integrator->set_use_transmission((bake_filter & BL::BakeSettings::pass_filter_TRANSMISSION) !=
557 integrator->set_use_emission((bake_filter & BL::BakeSettings::pass_filter_EMIT) != 0);
560 else if (strcmp(bake_type,
"SHADOW") == 0) {
562 use_direct_light =
true;
565 else if (strcmp(bake_type,
"DIFFUSE") == 0) {
566 if ((bake_filter & BL::BakeSettings::pass_filter_DIRECT) &&
567 bake_filter & BL::BakeSettings::pass_filter_INDIRECT) {
569 use_direct_light =
true;
570 use_indirect_light =
true;
572 else if (bake_filter & BL::BakeSettings::pass_filter_DIRECT) {
574 use_direct_light =
true;
576 else if (bake_filter & BL::BakeSettings::pass_filter_INDIRECT) {
578 use_indirect_light =
true;
584 include_albedo = (bake_filter & BL::BakeSettings::pass_filter_COLOR);
586 else if (strcmp(bake_type,
"GLOSSY") == 0) {
587 if ((bake_filter & BL::BakeSettings::pass_filter_DIRECT) &&
588 bake_filter & BL::BakeSettings::pass_filter_INDIRECT) {
590 use_direct_light =
true;
591 use_indirect_light =
true;
593 else if (bake_filter & BL::BakeSettings::pass_filter_DIRECT) {
595 use_direct_light =
true;
597 else if (bake_filter & BL::BakeSettings::pass_filter_INDIRECT) {
599 use_indirect_light =
true;
605 include_albedo = (bake_filter & BL::BakeSettings::pass_filter_COLOR);
607 else if (strcmp(bake_type,
"TRANSMISSION") == 0) {
608 if ((bake_filter & BL::BakeSettings::pass_filter_DIRECT) &&
609 bake_filter & BL::BakeSettings::pass_filter_INDIRECT) {
611 use_direct_light =
true;
612 use_indirect_light =
true;
614 else if (bake_filter & BL::BakeSettings::pass_filter_DIRECT) {
616 use_direct_light =
true;
618 else if (bake_filter & BL::BakeSettings::pass_filter_INDIRECT) {
620 use_indirect_light =
true;
626 include_albedo = (bake_filter & BL::BakeSettings::pass_filter_COLOR);
635 pass->set_name(ustring(
"Combined"));
636 pass->set_type(
type);
637 pass->set_include_albedo(include_albedo);
640 integrator->set_use_direct_light(use_direct_light);
641 integrator->set_use_indirect_light(use_indirect_light);
648 const string &bake_type,
649 const int bake_filter,
650 const int bake_width,
651 const int bake_height)
684 bool object_found =
false;
687 if (ob->
name == b_object.name()) {
700 buffer_params.
width = bake_width;
701 buffer_params.
height = bake_height;
806 const int pass_index = space_image.image_user().multilayer_pass();
809 if (!b_display_pass) {
822 scene->
film->set_display_pass(pass->get_type());
828 BL::Array<float, 2> zoom = space_image.zoom();
887 if (session_pause ==
false) {
920 b_engine.update_progress((
float)progress);
927 string timestatus, status, substatus;
928 string scene_status =
"";
930 double total_time, remaining_time = 0, render_time;
950 if (remaining_time > 0) {
954 timestatus +=
string_printf(
"Mem:%.2fM, Peak:%.2fM", (
double)mem_used, (
double)mem_peak);
956 if (status.size() > 0)
957 status =
" | " + status;
958 if (substatus.size() > 0)
959 status +=
" | " + substatus;
962 double current_time =
time_dt();
967 b_engine.update_stats(
"", (timestatus + scene_status + status).c_str());
968 b_engine.update_memory_stats(mem_used, mem_peak);
973 b_engine.update_progress((
float)progress);
1062 unique_ptr<BlenderDisplayDriver> display_driver = make_unique<BlenderDisplayDriver>(
b_engine,
typedef float(TangentPoint)[2]
struct Depsgraph Depsgraph
struct ViewLayer ViewLayer
struct RegionView3D RegionView3D
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei height
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum type
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei width
struct RenderEngine RenderEngine
struct RenderLayer RenderLayer
struct RenderResult RenderResult
struct RenderPass RenderPass
static void add_cryptomatte_layer(BL::RenderResult &b_rr, string name, string manifest)
static bool bake_setup_pass(Scene *scene, const string &bake_type_str, const int bake_filter)
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
static unsigned long seed
void set(Scene *scene, const std::string &object_name)
void set_zoom(float zoom_x, float zoom_y)
void stamp_view_layer_metadata(Scene *scene, const string &view_layer_name)
BL::RenderSettings b_render
static bool print_render_stats
bool check_and_report_session_error()
void update_bake_progress()
BL::RenderEngine b_engine
void full_buffer_written(string_view filename)
void synchronize(BL::Depsgraph &b_depsgraph)
vector< string > full_buffer_files_
void ensure_display_driver_if_needed()
void builtin_images_load()
void update_status_progress()
void * python_thread_state
void free_blender_memory_if_possible()
void view_draw(int w, int h)
struct BlenderSession::@1229 draw_state_
BL::Preferences b_userpref
void reset_session(BL::BlendData &b_data, BL::Depsgraph &b_depsgraph)
void bake(BL::Depsgraph &b_depsgrah, BL::Object &b_object, const string &pass_type, const int custom_flag, const int bake_width, const int bake_height)
BlenderDisplayDriver * display_driver_
void render(BL::Depsgraph &b_depsgraph)
void draw(BL::SpaceImageEditor &space_image)
BlenderSession(BL::RenderEngine &b_engine, BL::Preferences &b_userpref, BL::BlendData &b_data, bool preview_osl)
void render_frame_finish()
void get_status(string &status, string &substatus)
void get_progress(double &progress, double &total_time, double &render_time)
BL::Depsgraph b_depsgraph
static DeviceTypeMask device_override
static bool get_session_pause(BL::Scene &b_scene, bool background)
void sync_recalc(BL::Depsgraph &b_depsgraph, BL::SpaceView3D &b_v3d)
static SceneParams get_scene_params(BL::Scene &b_scene, bool background)
void sync_camera(BL::RenderSettings &b_render, BL::Object &b_override, int width, int height, const char *viewname)
void sync_render_passes(BL::RenderLayer &b_render_layer, BL::ViewLayer &b_view_layer)
int get_layer_bound_samples()
static BufferParams get_buffer_params(BL::SpaceView3D &b_v3d, BL::RegionView3D &b_rv3d, Camera *cam, int width, int height)
void sync_view(BL::SpaceView3D &b_v3d, BL::RegionView3D &b_rv3d, int width, int height)
void sync_data(BL::RenderSettings &b_render, BL::Depsgraph &b_depsgraph, BL::SpaceView3D &b_v3d, BL::Object &b_override, int width, int height, void **python_thread_state)
void reset(BL::BlendData &b_data, BL::Scene &b_scene)
static SessionParams get_session_params(BL::RenderEngine &b_engine, BL::Preferences &b_userpref, BL::Scene &b_scene, bool background)
string get_cryptomatte_objects(Scene *scene)
string get_cryptomatte_assets(Scene *scene)
static const Pass * find(const vector< Pass * > &passes, const string &name)
void set_cancel_callback(function< void()> function)
void get_status(string &status_, string &substatus_) const
void set_cancel(const string &cancel_message_)
void get_time(double &total_time_, double &render_time_) const
double get_progress() const
string get_error_message() const
void set_update_callback(function< void()> function)
bool modified(const SceneParams ¶ms) const
bool modified(const SessionParams ¶ms) const
void collect_statistics(RenderStats *stats)
void set_pause(bool pause)
void process_full_buffer_from_disk(string_view filename)
void set_display_driver(unique_ptr< DisplayDriver > driver)
void set_time_limit(double time_limit)
void cancel(bool quick=false)
double get_estimated_remaining_time() const
function< void(string_view)> full_buffer_written_cb
void reset(const SessionParams &session_params, const BufferParams &buffer_params)
void set_output_driver(unique_ptr< OutputDriver > driver)
void set_samples(int samples)
string get_cryptomatte_materials(Scene *scene)
#define CCL_NAMESPACE_END
static int render_resolution_x(BL::RenderSettings &b_render)
static int render_resolution_y(BL::RenderSettings &b_render)
static void render_add_metadata(BL::RenderResult &b_rr, string name, string value)
static const char * to_string(const Interpolation &interp)
ccl_device_inline uint hash_uint2(uint kx, uint ky)
ccl_gpu_kernel_postfix ccl_global float int int int int float bool reset
clear internal cached data and reset random seed
@ PASS_TRANSMISSION_DIRECT
@ PASS_TRANSMISSION_COLOR
@ PASS_TRANSMISSION_INDIRECT
static void error(const char *str)
uint32_t util_murmur_hash3(const void *key, int len, uint32_t seed)
bool path_remove(const string &path)
PointerRNA RNA_pointer_get(PointerRNA *ptr, const char *name)
void RNA_boolean_set(PointerRNA *ptr, const char *name, bool value)
const PointerRNA PointerRNA_NULL
CCL_NAMESPACE_BEGIN string string_printf(const char *format,...)
BakeManager * bake_manager
T * create_node(Args &&...args)
MotionType need_motion() const
void enable_update_stats()
vector< Object * > objects
ObjectManager * object_manager
ShaderManager * shader_manager
std::unique_lock< std::mutex > thread_scoped_lock
string time_human_readable_from_seconds(const double seconds)
CCL_NAMESPACE_BEGIN double time_dt()