From 593ae2c8f4abce2aab3a7a7b54322b9ab69710ff Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Mon, 17 Dec 2012 20:37:10 +0000 Subject: Fix #33505: various issues * Motion blur with shutter time > 1 did result in the correct evaluation of some modifiers because it set the subframe to values > 1, and some places assume the current frame to be set to the integer coordinate and the subframe to be a value between 0 and 1. * Shape keys did not take subframe time offsets into account. * Point density texture was using an current frame value that was never set. --- source/blender/blenkernel/intern/key.c | 8 ++++---- source/blender/render/intern/include/render_types.h | 1 - source/blender/render/intern/source/pipeline.c | 14 +++++++++++--- source/blender/render/intern/source/pointdensity.c | 2 +- 4 files changed, 16 insertions(+), 9 deletions(-) (limited to 'source') diff --git a/source/blender/blenkernel/intern/key.c b/source/blender/blenkernel/intern/key.c index 782d796b8a7..ad95f09826a 100644 --- a/source/blender/blenkernel/intern/key.c +++ b/source/blender/blenkernel/intern/key.c @@ -1078,7 +1078,7 @@ static void do_mesh_key(Scene *scene, Object *ob, Key *key, char *out, const int if (key->slurph && key->type != KEY_RELATIVE) { const float ctime_scaled = key->ctime / 100.0f; float delta = (float)key->slurph / tot; - float cfra = (float)scene->r.cfra; + float cfra = (float)scene->r.cfra + scene->r.subframe; int step, a; if (tot > 100 && slurph_opt) { @@ -1176,7 +1176,7 @@ static void do_curve_key(Scene *scene, Object *ob, Key *key, char *out, const in if (key->slurph && key->type != KEY_RELATIVE) { const float ctime_scaled = key->ctime / 100.0f; float delta = (float)key->slurph / tot; - float cfra = (float)scene->r.cfra; + float cfra = (float)scene->r.cfra + scene->r.subframe; Nurb *nu; int i = 0, remain = 0; int step, a; @@ -1258,7 +1258,7 @@ static void do_latt_key(Scene *scene, Object *ob, Key *key, char *out, const int if (key->slurph && key->type != KEY_RELATIVE) { const float ctime_scaled = key->ctime / 100.0f; float delta = (float)key->slurph / tot; - float cfra = (float)scene->r.cfra; + float cfra = (float)scene->r.cfra + scene->r.subframe; int a; for (a = 0; a < tot; a++, cfra += delta) { @@ -1373,7 +1373,7 @@ float *do_ob_key(Scene *scene, Object *ob) } else { /* do shapekey local drivers */ - float ctime = (float)scene->r.cfra; // XXX this needs to be checked + float ctime = (float)scene->r.cfra + scene->r.subframe; BKE_animsys_evaluate_animdata(scene, &key->id, key->adt, ctime, ADT_RECALC_DRIVERS); diff --git a/source/blender/render/intern/include/render_types.h b/source/blender/render/intern/include/render_types.h index 6ed8d6a7b6c..742241676dc 100644 --- a/source/blender/render/intern/include/render_types.h +++ b/source/blender/render/intern/include/render_types.h @@ -198,7 +198,6 @@ struct Render ListBase strandsurface; /* use this instead of R.r.cfra */ - float cfra; float mblur_offs, field_offs; /* render database */ diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index e22a90cacb5..413d7cb959e 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -942,6 +942,9 @@ void RE_TileProcessor(Render *re) static void do_render_3d(Render *re) { + float cfra; + int cfra_backup; + /* try external */ if (RE_engine_render(re, 0)) return; @@ -949,9 +952,13 @@ static void do_render_3d(Render *re) /* internal */ RE_parts_clamp(re); -// re->cfra= cfra; /* <- unused! */ - re->scene->r.subframe = re->mblur_offs + re->field_offs; - + /* add motion blur and fields offset to frames */ + cfra_backup = re->scene->r.cfra; + + cfra = re->scene->r.cfra + re->mblur_offs + re->field_offs; + re->scene->r.cfra = floorf(cfra); + re->scene->r.subframe = cfra - floorf(cfra); + /* lock drawing in UI during data phase */ if (re->draw_lock) re->draw_lock(re->dlh, 1); @@ -976,6 +983,7 @@ static void do_render_3d(Render *re) /* free all render verts etc */ RE_Database_Free(re); + re->scene->r.cfra = cfra_backup; re->scene->r.subframe = 0.f; } diff --git a/source/blender/render/intern/source/pointdensity.c b/source/blender/render/intern/source/pointdensity.c index a540cdb85d5..3ca4015ff7b 100644 --- a/source/blender/render/intern/source/pointdensity.c +++ b/source/blender/render/intern/source/pointdensity.c @@ -447,7 +447,7 @@ int pointdensitytex(Tex *tex, const float texvec[3], TexResult *texres) turb = BLI_gTurbulence(pd->noise_size, texvec[0]+age, texvec[1]+age, texvec[2]+age, pd->noise_depth, 0, pd->noise_basis); } else if (pd->noise_influence == TEX_PD_NOISE_TIME) { - time = R.cfra / (float)R.r.efra; + time = R.r.cfra / (float)R.r.efra; turb = BLI_gTurbulence(pd->noise_size, texvec[0]+time, texvec[1]+time, texvec[2]+time, pd->noise_depth, 0, pd->noise_basis); //turb = BLI_turbulence(pd->noise_size, texvec[0]+time, texvec[1]+time, texvec[2]+time, pd->noise_depth); } -- cgit v1.2.3