[Bf-blender-cvs] [da71d831c3f] temp-eeveelightcache: Merge remote-tracking branch 'origin/blender2.8' into temp-eeveelightcache
Clément Foucault
noreply at git.blender.org
Thu Jul 5 00:17:42 CEST 2018
Commit: da71d831c3f8b75ce51a7cca1f9da980992f7967
Author: Clément Foucault
Date: Wed Jul 4 16:01:28 2018 +0200
Branches: temp-eeveelightcache
https://developer.blender.org/rBda71d831c3f8b75ce51a7cca1f9da980992f7967
Merge remote-tracking branch 'origin/blender2.8' into temp-eeveelightcache
# Conflicts:
# source/blender/draw/engines/eevee/eevee_lightprobes.c
===================================================================
===================================================================
diff --cc source/blender/blenkernel/BKE_world.h
index 28f5f97073b,f703fefec97..6a9a75828e5
--- a/source/blender/blenkernel/BKE_world.h
+++ b/source/blender/blenkernel/BKE_world.h
@@@ -44,5 -44,10 +44,4 @@@ struct World *BKE_world_copy(struct Mai
struct World *BKE_world_localize(struct World *wrld);
void BKE_world_make_local(struct Main *bmain, struct World *wrld, const bool lib_local);
-/* Evaluation. */
-
-struct Depsgraph;
-
-void BKE_world_eval(struct Depsgraph *depsgraph, struct World *world);
-
#endif
-
diff --cc source/blender/blenkernel/intern/object.c
index debe7b8283a,61d38a4e937..84b1d41a788
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@@ -454,11 -449,15 +451,8 @@@ void BKE_object_free(Object *ob
BKE_rigidbody_free_object(ob, NULL);
BKE_rigidbody_free_constraint(ob);
- if (ob->soft) {
- sbFree(ob->soft);
- ob->soft = NULL;
- }
+ sbFree(ob);
- for (ObjectEngineData *oed = ob->drawdata.first; oed; oed = oed->next) {
- if (oed->free != NULL) {
- oed->free(oed);
- }
- }
- BLI_freelistN(&ob->drawdata);
-
BKE_sculptsession_free(ob);
BLI_freelistN(&ob->pc_ids);
diff --cc source/blender/draw/engines/eevee/eevee_lightprobes.c
index 17dda20f4d4,0b97496700a..1e8daeaa958
--- a/source/blender/draw/engines/eevee/eevee_lightprobes.c
+++ b/source/blender/draw/engines/eevee/eevee_lightprobes.c
@@@ -1054,30 -1081,19 +1054,17 @@@ void EEVEE_lightbake_filter_glossy
/* 2 - Let gpu create Mipmaps for Filtered Importance Sampling. */
/* Bind next framebuffer to be able to gen. mips for probe_rt. */
- EEVEE_downsample_cube_buffer(vedata, sldata->probe_rt, (int)(pinfo->lod_rt_max));
+ EEVEE_downsample_cube_buffer(vedata, rt_color, (int)(pinfo->lod_rt_max));
/* 3 - Render to probe array to the specified layer, do prefiltering. */
- float mipsize = pinfo->cubemap_res;
- const int maxlevel = (int)floorf(log2f(pinfo->cubemap_res));
- const int min_lod_level = 3;
- for (int i = 0; i < maxlevel - min_lod_level; i++) {
+ int mipsize = GPU_texture_width(light_cache->cube_tx.tex);
+ for (int i = 0; i < maxlevel + 1; i++) {
float bias = (i == 0) ? -1.0f : 1.0f;
- pinfo->texel_size = 1.0f / mipsize;
- pinfo->padding_size = powf(2.0f, (float)(maxlevel - min_lod_level - 1 - i));
+ pinfo->texel_size = 1.0f / (float)mipsize;
+ pinfo->padding_size = (float)(1 << (maxlevel - i - 1));
- /* XXX : WHY THE HECK DO WE NEED THIS ??? */
- /* padding is incorrect without this! float precision issue? */
- if (pinfo->padding_size > 32) {
- pinfo->padding_size += 5;
- }
- if (pinfo->padding_size > 16) {
- pinfo->padding_size += 4;
- }
- else if (pinfo->padding_size > 8) {
- pinfo->padding_size += 2;
- }
- else if (pinfo->padding_size > 4) {
- pinfo->padding_size += 1;
- }
+ pinfo->padding_size *= pinfo->texel_size;
pinfo->layer = probe_idx;
- pinfo->roughness = (float)i / ((float)maxlevel - 4.0f);
+ pinfo->roughness = i / (float)maxlevel;
pinfo->roughness *= pinfo->roughness; /* Disney Roughness */
pinfo->roughness *= pinfo->roughness; /* Distribute Roughness accros lod more evenly */
CLAMP(pinfo->roughness, 1e-8f, 0.99999f); /* Avoid artifacts */
diff --cc source/blender/draw/intern/draw_manager.c
index 7c4bd4a32a2,ea25739e52d..5fabb856346
--- a/source/blender/draw/intern/draw_manager.c
+++ b/source/blender/draw/intern/draw_manager.c
@@@ -2011,12 -1877,8 +2020,9 @@@ void DRW_draw_depth_loop
drw_engines_init();
DRW_hair_init();
- /* TODO : tag to refresh by the dependency graph */
- /* ideally only refresh when objects are added/removed */
- /* or render properties / materials change */
- if (cache_is_dirty) {
+ {
drw_engines_cache_init();
+ drw_engines_world_update(scene);
DEG_OBJECT_ITER_FOR_RENDER_ENGINE_BEGIN(depsgraph, ob)
{
diff --cc source/blender/editors/render/render_shading.c
index 0d36ddb0ead,31f25720f8d..53cafc7bb4e
--- a/source/blender/editors/render/render_shading.c
+++ b/source/blender/editors/render/render_shading.c
@@@ -675,124 -673,9 +675,124 @@@ void SCENE_OT_view_layer_remove(wmOpera
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
}
+/********************** light cache operators *********************/
+
+/* catch esc */
+static int light_cache_bake_modal(bContext *C, wmOperator *op, const wmEvent *event)
+{
+ Scene *scene = (Scene *) op->customdata;
+
+ /* no running blender, remove handler and pass through */
+ if (0 == WM_jobs_test(CTX_wm_manager(C), scene, WM_JOB_TYPE_RENDER)) {
+ return OPERATOR_FINISHED | OPERATOR_PASS_THROUGH;
+ }
+
+ /* running render */
+ switch (event->type) {
+ case ESCKEY:
+ return OPERATOR_RUNNING_MODAL;
+ }
+ return OPERATOR_PASS_THROUGH;
+}
+
+static void light_cache_bake_cancel(bContext *C, wmOperator *op)
+{
+ wmWindowManager *wm = CTX_wm_manager(C);
+ Scene *scene = (Scene *) op->customdata;
+
+ /* kill on cancel, because job is using op->reports */
+ WM_jobs_kill_type(wm, scene, WM_JOB_TYPE_RENDER);
+}
+
+/* executes blocking render */
+static int light_cache_bake_exec(bContext *C, wmOperator *UNUSED(op))
+{
+ ViewLayer *view_layer = CTX_data_view_layer(C);
+ Main *bmain = CTX_data_main(C);
+ Scene *scene = CTX_data_scene(C);
+
+ G.is_break = false;
+
+ /* TODO abort if selected engine is not eevee. */
+ void *rj = EEVEE_lightbake_job_data_alloc(bmain, view_layer, scene, false);
+ short stop = 0, do_update; float progress; /* Not actually used. */
+ EEVEE_lightbake_job(rj, &stop, &do_update, &progress);
+ EEVEE_lightbake_job_data_free(rj);
+
+ // no redraw needed, we leave state as we entered it
+ ED_update_for_newframe(bmain, CTX_data_depsgraph(C));
+
+ WM_event_add_notifier(C, NC_SCENE | ND_RENDER_RESULT, scene);
+
+ return OPERATOR_FINISHED;
+}
+
+static int light_cache_bake_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
+{
+ wmWindowManager *wm = CTX_wm_manager(C);
+ ViewLayer *view_layer = CTX_data_view_layer(C);
+ Main *bmain = CTX_data_main(C);
+ Scene *scene = CTX_data_scene(C);
+
+ /* only one render job at a time */
+ if (WM_jobs_test(wm, scene, WM_JOB_TYPE_RENDER))
+ return OPERATOR_CANCELLED;
+
+ if (WM_jobs_test(wm, scene, WM_JOB_TYPE_LIGHT_BAKE))
+ return OPERATOR_CANCELLED;
+
+ /* TODO abort if selected engine is not eevee. */
+ void *rj = EEVEE_lightbake_job_data_alloc(bmain, view_layer, scene, true);
+
+ if (rj == NULL) {
+ /* TODO display reason of faillure Blabla */
+ return OPERATOR_CANCELLED;
+ }
+
+ wmJob *wm_job = WM_jobs_get(wm, CTX_wm_window(C), scene, "Bake Lighting",
+ WM_JOB_EXCL_RENDER | WM_JOB_PRIORITY | WM_JOB_PROGRESS, WM_JOB_TYPE_LIGHT_BAKE);
+ WM_jobs_customdata_set(wm_job, rj, EEVEE_lightbake_job_data_free);
+ WM_jobs_timer(wm_job, 0.4, NC_OBJECT | ND_DRAW, 0);
+ WM_jobs_callbacks(wm_job, EEVEE_lightbake_job, NULL, EEVEE_lightbake_update, NULL);
+
+ /* add modal handler for ESC */
+ WM_event_add_modal_handler(C, op);
+
+ /* store actual owner of job, so modal operator could check for it,
+ * the reason of this is that active scene could change when rendering
+ * several layers from compositor [#31800]
+ */
+ op->customdata = scene;
+
+ G.is_break = false;
+
+ WM_jobs_start(CTX_wm_manager(C), wm_job);
+
+ WM_cursor_wait(0);
+
+ return OPERATOR_RUNNING_MODAL;
+}
+
+void SCENE_OT_light_cache_bake(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Bake Light Cache";
+ ot->idname = "SCENE_OT_light_cache_bake";
+ ot->description = "Bake the active view layer lighting";
+
+ /* api callbacks */
+ ot->invoke = light_cache_bake_invoke;
+ ot->modal = light_cache_bake_modal;
+ ot->cancel = light_cache_bake_cancel;
+ ot->exec = light_cache_bake_exec;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+}
+
/********************** render view operators *********************/
- static int render_view_remove_poll(bContext *C)
+ static bool render_view_remove_poll(bContext *C)
{
Scene *scene = CTX_data_scene(C);
More information about the Bf-blender-cvs
mailing list