59 BL::Preferences &b_userpref,
60 BL::BlendData &b_data,
66 b_userpref(b_userpref),
68 b_render(b_engine.render()),
75 preview_osl(preview_osl),
76 python_thread_state(
NULL)
86 BL::Preferences &b_userpref,
87 BL::BlendData &b_data,
88 BL::SpaceView3D &b_v3d,
96 b_userpref(b_userpref),
98 b_render(b_engine.render()),
106 python_thread_state(
NULL)
171 this->
b_scene = b_depsgraph.scene_eval();
191 if (is_new_session) {
210 !this->b_render.use_persistent_data()) {
214 if (!is_new_session) {
230 if (is_new_session) {
247 b_null_region_view3d,
270 const char *shader_type = pass_type.c_str();
273 if (strcmp(shader_type,
"NORMAL") == 0)
275 else if (strcmp(shader_type,
"UV") == 0)
277 else if (strcmp(shader_type,
"ROUGHNESS") == 0)
279 else if (strcmp(shader_type,
"DIFFUSE_COLOR") == 0)
281 else if (strcmp(shader_type,
"GLOSSY_COLOR") == 0)
283 else if (strcmp(shader_type,
"TRANSMISSION_COLOR") == 0)
285 else if (strcmp(shader_type,
"EMIT") == 0)
289 else if (strcmp(shader_type,
"AO") == 0)
291 else if (strcmp(shader_type,
"COMBINED") == 0)
293 else if (strcmp(shader_type,
"SHADOW") == 0)
295 else if (strcmp(shader_type,
"DIFFUSE") == 0)
297 else if (strcmp(shader_type,
"GLOSSY") == 0)
299 else if (strcmp(shader_type,
"TRANSMISSION") == 0)
303 else if (strcmp(shader_type,
"ENVIRONMENT") == 0)
315 const char *layername,
316 const char *viewname)
318 return b_engine.begin_result(
x,
y,
w, h, layername, viewname);
325 bool do_merge_results)
327 b_engine.end_result(b_rr, (
int)cancel, (
int)highlight, (
int)do_merge_results);
345 if (b_rr.ptr.data ==
NULL) {
349 BL::RenderResult::layers_iterator b_single_rlay;
350 b_rr.layers.begin(b_single_rlay);
353 if (b_single_rlay == b_rr.layers.end())
363 int components = b_pass.channels();
366 pass_type, components, (
float *)b_pass.rect(), rtile.
num_samples);
371 else if (do_update_only) {
416 string prefix =
"cryptomatte/" + identifier.substr(0, 7) +
"/";
427 string prefix =
"cycles." + view_layer_name +
".";
430 b_rr.stamp_data_add_field((prefix +
"samples").c_str(),
435 b_rr.stamp_data_add_field((prefix +
"range_start_sample").c_str(),
437 b_rr.stamp_data_add_field((prefix +
"range_num_samples").c_str(),
444 view_layer_name +
".CryptoObject",
449 view_layer_name +
".CryptoMaterial",
454 view_layer_name +
".CryptoAsset",
459 double total_time, render_time;
461 b_rr.stamp_data_add_field((prefix +
"total_time").c_str(),
463 b_rr.stamp_data_add_field((prefix +
"render_time").c_str(),
465 b_rr.stamp_data_add_field((prefix +
"synchronization_time").c_str(),
493 b_engine, 0, 0, 1, 1, b_view_layer.name().c_str(),
NULL);
494 BL::RenderResult::layers_iterator b_single_rlay;
495 b_rr.layers.begin(b_single_rlay);
507 buffer_params.
passes = passes;
512 BL::RenderResult::views_iterator b_view_iter;
515 for (b_rr.views.begin(b_view_iter); b_view_iter != b_rr.views.end(); ++b_view_iter) {
520 for (b_rr.views.begin(b_view_iter); b_view_iter != b_rr.views.end();
521 ++b_view_iter, ++view_index) {
547 if (view_index == num_views - 1) {
553 if (view_index != 0) {
562 int effective_layer_samples;
564 if (samples != 0 && (!bound_samples || (samples < session_params.
samples)))
565 effective_layer_samples = samples;
567 effective_layer_samples = session_params.
samples;
586 printf(
"Render statistics:\n%s\n", stats.
full_report().c_str());
599 double total_time, render_time;
601 VLOG(1) <<
"Total render time: " << total_time;
602 VLOG(1) <<
"Render time (without synchronization): " << render_time;
613 if ((pass_filter & BL::BakeSettings::pass_filter_DIRECT) != 0)
615 if ((pass_filter & BL::BakeSettings::pass_filter_INDIRECT) != 0)
617 if ((pass_filter & BL::BakeSettings::pass_filter_COLOR) != 0)
620 if ((pass_filter & BL::BakeSettings::pass_filter_DIFFUSE) != 0)
622 if ((pass_filter & BL::BakeSettings::pass_filter_GLOSSY) != 0)
624 if ((pass_filter & BL::BakeSettings::pass_filter_TRANSMISSION) != 0)
627 if ((pass_filter & BL::BakeSettings::pass_filter_EMIT) != 0)
629 if ((pass_filter & BL::BakeSettings::pass_filter_AO) != 0)
637 const string &pass_type,
638 const int pass_filter,
639 const int bake_width,
640 const int bake_height)
668 bool object_found =
false;
670 if (ob->
name == b_object.name()) {
683 buffer_params.
width = bake_width;
684 buffer_params.
height = bake_height;
715 float exposure =
scene->
film->get_exposure();
722 if (range_start_sample != -1) {
723 sample -= range_start_sample;
726 if (!do_update_only) {
729 int components = b_pass.channels();
732 bool read = buffers->
get_pass_rect(b_pass.name(), exposure,
sample, components, &pixels[0]);
737 if (denoising_offset >= 0) {
739 denoising_offset, exposure,
sample, components, &pixels[0]);
744 memset(&pixels[0], 0, pixels.size() *
sizeof(
float));
747 b_pass.rect(&pixels[0]);
754 b_combined_pass.rect(&pixels[0]);
902 if (session_pause ==
false) {
924 &BL::RenderEngine::unbind_display_space_shader, &
b_engine);
958 string timestatus, status, substatus, kernel_status;
959 string scene_status =
"";
961 double total_time, remaining_time = 0, render_time;
970 remaining_time = (1.0 - (
double)progress) * (render_time / (
double)progress);
981 if (remaining_time > 0) {
985 timestatus +=
string_printf(
"Mem:%.2fM, Peak:%.2fM", (
double)mem_used, (
double)mem_peak);
987 if (status.size() > 0)
988 status =
" | " + status;
989 if (substatus.size() > 0)
990 status +=
" | " + substatus;
991 if (kernel_status.size() > 0)
992 status +=
" | " + kernel_status;
995 double current_time =
time_dt();
1000 b_engine.update_stats(
"", (timestatus + scene_status + status).c_str());
1001 b_engine.update_memory_stats(mem_used, mem_peak);
1006 b_engine.update_progress(progress);
1069 "Cycles warning: more sample chunks (%d) than samples (%d), "
1070 "this will cause some samples to be included in multiple chunks.\n",
1077 float range_start_sample, range_num_samples;
1081 range_num_samples = num_samples_per_chunk;
1087 range_num_samples = num_chunks * num_samples_per_chunk;
1092 int rounded_range_start_sample = (int)
floorf(range_start_sample + 0.5f);
1093 int rounded_range_num_samples =
max((
int)
floorf(range_num_samples + 0.5f), 1);
1096 if (rounded_range_start_sample + rounded_range_num_samples > num_samples) {
1097 rounded_range_num_samples = num_samples - rounded_range_num_samples;
1100 VLOG(1) <<
"Samples range start is " << range_start_sample <<
", "
1101 <<
"number of samples to render is " << range_num_samples;
typedef float(TangentPoint)[2]
typedef double(DMatrix)[4][4]
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 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
_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 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 y
struct RenderEngine RenderEngine
struct RenderLayer RenderLayer
struct RenderResult RenderResult
struct RenderPass RenderPass
static ShaderEvalType get_shader_type(const string &pass_type)
static void add_cryptomatte_layer(BL::RenderResult &b_rr, string name, string manifest)
static void end_render_result(BL::RenderEngine &b_engine, BL::RenderResult &b_rr, bool cancel, bool highlight, bool do_merge_results)
static int bake_pass_filter_get(const int pass_filter)
static BL::RenderResult begin_render_result(BL::RenderEngine &b_engine, int x, int y, int w, int h, const char *layername, const char *viewname)
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)
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
static unsigned long seed
void reset()
clear internal cached data and reset random seed
void set(Scene *scene, const std::string &object_name, ShaderEvalType type, int pass_filter)
void stamp_view_layer_metadata(Scene *scene, const string &view_layer_name)
void get_progress(float &progress, double &total_time, double &render_time)
BL::RenderSettings b_render
void get_kernel_status(string &kernel_status)
static bool print_render_stats
void update_bake_progress()
BL::RenderEngine b_engine
void synchronize(BL::Depsgraph &b_depsgraph)
static int end_resumable_chunk
void do_write_update_render_tile(RenderTile &rtile, bool do_update_only, bool do_read_only, bool highlight)
void write_render_result(BL::RenderLayer &b_rlay, RenderTile &rtile)
void builtin_images_load()
void update_status_progress()
void * python_thread_state
void free_blender_memory_if_possible()
static int start_resumable_chunk
BL::Preferences b_userpref
void read_render_tile(RenderTile &rtile)
static int current_resumable_chunk
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)
void update_render_tile(RenderTile &rtile, bool highlight)
void render(BL::Depsgraph &b_depsgraph)
void write_render_tile(RenderTile &rtile)
void update_render_result(BL::RenderLayer &b_rlay, RenderTile &rtile)
BlenderSession(BL::RenderEngine &b_engine, BL::Preferences &b_userpref, BL::BlendData &b_data, bool preview_osl)
void do_write_update_render_result(BL::RenderLayer &b_rlay, RenderTile &rtile, bool do_update_only)
static int num_resumable_chunks
void get_status(string &status, string &substatus)
BL::Depsgraph b_depsgraph
static DeviceTypeMask device_override
void update_resumable_tile_manager(int num_samples)
static BufferParams get_buffer_params(BL::RenderSettings &b_render, BL::SpaceView3D &b_v3d, BL::RegionView3D &b_rv3d, Camera *cam, int width, int height, const bool use_denoiser)
static bool get_session_pause(BL::Scene &b_scene, bool background)
static SessionParams get_session_params(BL::RenderEngine &b_engine, BL::Preferences &b_userpref, BL::Scene &b_scene, bool background, BL::ViewLayer b_view_layer=BL::ViewLayer(PointerRNA_NULL))
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)
int get_layer_bound_samples()
vector< Pass > sync_render_passes(BL::Scene &b_scene, BL::RenderLayer &b_render_layer, BL::ViewLayer &b_view_layer, bool adaptive_sampling, const DenoiseParams &denoising)
void sync_view(BL::SpaceView3D &b_v3d, BL::RegionView3D &b_rv3d, int width, int height)
static int get_denoising_pass(BL::RenderPass &b_pass)
static PassType get_pass_type(BL::RenderPass &b_pass)
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)
bool denoising_prefiltered_pass
bool denoising_clean_pass
string get_cryptomatte_objects(Scene *scene)
string get_cryptomatte_assets(Scene *scene)
static void add(PassType type, vector< Pass > &passes, const char *name=NULL)
void set_cancel_callback(function< void()> function)
void set_cancel(const string &cancel_message_)
void get_status(string &status_, string &substatus_)
void get_time(double &total_time_, double &render_time_)
string get_error_message()
void get_kernel_status(string &kernel_status_)
void set_update_callback(function< void()> function)
bool get_pass_rect(const string &name, float exposure, int sample, int components, float *pixels)
bool set_pass_rect(PassType type, int components, float *pixels, int samples)
bool get_denoising_pass_rect(int offset, float exposure, int sample, int components, float *pixels)
bool modified(const SceneParams ¶ms)
bool display_buffer_linear
bool modified(const SessionParams ¶ms)
void set_denoising_start_sample(int sample)
void collect_statistics(RenderStats *stats)
function< void(RenderTile &, bool)> update_render_tile_cb
bool draw(BufferParams ¶ms, DeviceDrawParams &draw_params)
void set_pause(bool pause)
void set_denoising(const DenoiseParams &denoising)
function< void(RenderTile &)> write_render_tile_cb
void reset(BufferParams ¶ms, int samples)
void set_samples(int samples)
function< void(RenderTile &)> read_bake_tile_cb
string get_cryptomatte_materials(Scene *scene)
void set_tile_order(TileOrder tile_order_)
void set_samples(int num_samples)
#define CCL_NAMESPACE_END
@ SHADER_EVAL_TRANSMISSION_COLOR
@ SHADER_EVAL_TRANSMISSION
@ SHADER_EVAL_DIFFUSE_COLOR
@ SHADER_EVAL_GLOSSY_COLOR
@ SHADER_EVAL_ENVIRONMENT
@ BAKE_FILTER_TRANSMISSION
static void error(const char *str)
static void sample(SocketReader *reader, int x, int y, float color[4])
std::string to_string(const T &n)
PointerRNA RNA_pointer_get(PointerRNA *ptr, const char *name)
void RNA_boolean_set(PointerRNA *ptr, const char *name, bool value)
const PointerRNA PointerRNA_NULL
function< void()> unbind_display_space_shader_cb
function< void()> bind_display_space_shader_cb
BakeManager * bake_manager
void enable_update_stats()
vector< Object * > objects
ObjectManager * object_manager
ShaderManager * shader_manager
__forceinline BoundBox merge(const BoundBox &bbox, const float3 &pt)
ccl_device_inline uint hash_uint2(uint kx, uint ky)
uint32_t util_murmur_hash3(const void *key, int len, uint32_t seed)
CCL_NAMESPACE_BEGIN string string_printf(const char *format,...)
string time_human_readable_from_seconds(const double seconds)
CCL_NAMESPACE_BEGIN double time_dt()