Cycles: enable Alembic procedural for final renders

The Alembic procedural was only enabled during viewport renders
originally because it did not have any caching strategy. Now that
is does, we can allow its usage in final renders.

This also removes the `dag_eval_mode` argument passing to
`ModifierTypeInfo.dependsOnTime` which was originally added to detect if
we are doing a viewport render for enabling the procedural.

Differential Revision: https://developer.blender.org/D14520
This commit is contained in:
Kévin Dietrich 2022-04-01 15:27:11 +02:00
parent 5c80543c43
commit e81d7bfcc9
27 changed files with 34 additions and 83 deletions

View File

@ -621,10 +621,8 @@ void BlenderSync::sync_objects(BL::Depsgraph &b_depsgraph,
bool has_subdivision_modifier = false;
BL::MeshSequenceCacheModifier b_mesh_cache(PointerRNA_NULL);
/* Experimental as Blender does not have good support for procedurals at the moment, also
* only available in preview renders since currently do not have a good cache policy, the
* data being loaded at once for all the frames. */
if (experimental && b_v3d) {
/* Experimental as Blender does not have good support for procedurals at the moment. */
if (experimental) {
b_mesh_cache = object_mesh_cache_find(b_ob, &has_subdivision_modifier);
use_procedural = b_mesh_cache && b_mesh_cache.cache_file().use_render_procedural();
}

View File

@ -51,8 +51,7 @@ void BKE_cachefile_reader_free(struct CacheFile *cache_file, struct CacheReader
* load the data directly if they support it.
*/
bool BKE_cache_file_uses_render_procedural(const struct CacheFile *cache_file,
struct Scene *scene,
int dag_eval_mode);
struct Scene *scene);
/* Add a layer to the cache_file. Return NULL if the filename is already that of an existing layer
* or if the number of layers exceeds the maximum allowed layer count. */

View File

@ -301,10 +301,8 @@ typedef struct ModifierTypeInfo {
* changes.
*
* This function is optional (assumes false if not present).
*
* The dag_eval_mode should be of type eEvaluationMode.
*/
bool (*dependsOnTime)(struct Scene *scene, struct ModifierData *md, int dag_eval_mode);
bool (*dependsOnTime)(struct Scene *scene, struct ModifierData *md);
/**
* True when a deform modifier uses normals, the requiredDataMask
@ -421,7 +419,7 @@ void BKE_modifier_copydata(const struct ModifierData *md, struct ModifierData *t
void BKE_modifier_copydata_ex(const struct ModifierData *md,
struct ModifierData *target,
int flag);
bool BKE_modifier_depends_ontime(struct Scene *scene, struct ModifierData *md, int dag_eval_mode);
bool BKE_modifier_depends_ontime(struct Scene *scene, struct ModifierData *md);
bool BKE_modifier_supports_mapping(struct ModifierData *md);
bool BKE_modifier_supports_cage(struct Scene *scene, struct ModifierData *md);
bool BKE_modifier_couldbe_cage(struct Scene *scene, struct ModifierData *md);

View File

@ -621,10 +621,7 @@ void BKE_object_groups_clear(struct Main *bmain, struct Scene *scene, struct Obj
*/
struct KDTree_3d *BKE_object_as_kdtree(struct Object *ob, int *r_tot);
bool BKE_object_modifier_use_time(struct Scene *scene,
struct Object *ob,
struct ModifierData *md,
int dag_eval_mode);
bool BKE_object_modifier_use_time(struct Scene *scene, struct Object *ob, struct ModifierData *md);
/**
* \note this function should eventually be replaced by depsgraph functionality.

View File

@ -417,9 +417,7 @@ float BKE_cachefile_time_offset(const CacheFile *cache_file, const float time, c
return cache_file->is_sequence ? frame : frame / fps - time_offset;
}
bool BKE_cache_file_uses_render_procedural(const CacheFile *cache_file,
Scene *scene,
const int dag_eval_mode)
bool BKE_cache_file_uses_render_procedural(const CacheFile *cache_file, Scene *scene)
{
RenderEngineType *render_engine_type = RE_engines_find(scene->r.engine);
@ -428,9 +426,7 @@ bool BKE_cache_file_uses_render_procedural(const CacheFile *cache_file,
return false;
}
/* The render time procedural is only enabled during viewport rendering. */
const bool is_final_render = (eEvaluationMode)dag_eval_mode == DAG_EVAL_RENDER;
return cache_file->use_render_procedural && !is_final_render;
return cache_file->use_render_procedural;
}
CacheFileLayer *BKE_cachefile_add_layer(CacheFile *cache_file, const char filename[1024])

View File

@ -5412,7 +5412,7 @@ static void transformcache_evaluate(bConstraint *con, bConstraintOb *cob, ListBa
}
/* Do not process data if using a render time procedural. */
if (BKE_cache_file_uses_render_procedural(cache_file, scene, DEG_get_mode(cob->depsgraph))) {
if (BKE_cache_file_uses_render_procedural(cache_file, scene)) {
return;
}

View File

@ -233,11 +233,11 @@ bool BKE_modifier_unique_name(ListBase *modifiers, ModifierData *md)
return false;
}
bool BKE_modifier_depends_ontime(Scene *scene, ModifierData *md, const int dag_eval_mode)
bool BKE_modifier_depends_ontime(Scene *scene, ModifierData *md)
{
const ModifierTypeInfo *mti = BKE_modifier_get_info(md->type);
return mti->dependsOnTime && mti->dependsOnTime(scene, md, dag_eval_mode);
return mti->dependsOnTime && mti->dependsOnTime(scene, md);
}
bool BKE_modifier_supports_mapping(ModifierData *md)

View File

@ -5236,12 +5236,9 @@ KDTree_3d *BKE_object_as_kdtree(Object *ob, int *r_tot)
/** \name Object Modifier Utilities
* \{ */
bool BKE_object_modifier_use_time(Scene *scene,
Object *ob,
ModifierData *md,
const int dag_eval_mode)
bool BKE_object_modifier_use_time(Scene *scene, Object *ob, ModifierData *md)
{
if (BKE_modifier_depends_ontime(scene, md, dag_eval_mode)) {
if (BKE_modifier_depends_ontime(scene, md)) {
return true;
}

View File

@ -2088,7 +2088,7 @@ void DepsgraphRelationBuilder::build_object_data_geometry(Object *object)
ctx.node = reinterpret_cast<::DepsNodeHandle *>(&handle);
mti->updateDepsgraph(md, &ctx);
}
if (BKE_object_modifier_use_time(scene_, object, md, graph_->mode)) {
if (BKE_object_modifier_use_time(scene_, object, md)) {
TimeSourceKey time_src_key;
add_relation(time_src_key, obdata_ubereval_key, "Time Source");
}

View File

@ -46,9 +46,7 @@ static void initData(ModifierData *md)
MEMCPY_STRUCT_AFTER(bmd, DNA_struct_default_get(BuildModifierData), modifier);
}
static bool dependsOnTime(struct Scene *UNUSED(scene),
ModifierData *UNUSED(md),
const int UNUSED(dag_eval_mode))
static bool dependsOnTime(struct Scene *UNUSED(scene), ModifierData *UNUSED(md))
{
return true;
}

View File

@ -201,9 +201,7 @@ static void copyData(const ModifierData *md, ModifierData *target, const int fla
tclmd->solver_result = NULL;
}
static bool dependsOnTime(struct Scene *UNUSED(scene),
ModifierData *UNUSED(md),
const int UNUSED(dag_eval_mode))
static bool dependsOnTime(struct Scene *UNUSED(scene), ModifierData *UNUSED(md))
{
return true;
}

View File

@ -80,9 +80,7 @@ static void freeData(ModifierData *md)
}
}
static bool dependsOnTime(struct Scene *UNUSED(scene),
ModifierData *UNUSED(md),
const int UNUSED(dag_eval_mode))
static bool dependsOnTime(struct Scene *UNUSED(scene), ModifierData *UNUSED(md))
{
return true;
}

View File

@ -80,9 +80,7 @@ static void requiredDataMask(Object *UNUSED(ob),
}
}
static bool dependsOnTime(struct Scene *UNUSED(scene),
ModifierData *md,
const int UNUSED(dag_eval_mode))
static bool dependsOnTime(struct Scene *UNUSED(scene), ModifierData *md)
{
DisplaceModifierData *dmd = (DisplaceModifierData *)md;

View File

@ -142,9 +142,7 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
}
}
static bool dependsOnTime(struct Scene *UNUSED(scene),
ModifierData *UNUSED(md),
const int UNUSED(dag_eval_mode))
static bool dependsOnTime(struct Scene *UNUSED(scene), ModifierData *UNUSED(md))
{
return true;
}

View File

@ -71,9 +71,7 @@ static void copyData(const ModifierData *md, ModifierData *target, const int fla
temd->facepa = NULL;
}
static bool dependsOnTime(struct Scene *UNUSED(scene),
ModifierData *UNUSED(md),
const int UNUSED(dag_eval_mode))
static bool dependsOnTime(struct Scene *UNUSED(scene), ModifierData *UNUSED(md))
{
return true;
}

View File

@ -151,9 +151,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
#endif /* WITH_FLUID */
}
static bool dependsOnTime(struct Scene *UNUSED(scene),
ModifierData *UNUSED(md),
const int UNUSED(dag_eval_mode))
static bool dependsOnTime(struct Scene *UNUSED(scene), ModifierData *UNUSED(md))
{
return true;
}

View File

@ -54,9 +54,7 @@ static void initData(ModifierData *md)
MEMCPY_STRUCT_AFTER(mcmd, DNA_struct_default_get(MeshCacheModifierData), modifier);
}
static bool dependsOnTime(struct Scene *UNUSED(scene),
ModifierData *md,
const int UNUSED(dag_eval_mode))
static bool dependsOnTime(struct Scene *UNUSED(scene), ModifierData *md)
{
MeshCacheModifierData *mcmd = (MeshCacheModifierData *)md;
return (mcmd->play_mode == MOD_MESHCACHE_PLAY_CFEA);

View File

@ -169,7 +169,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
/* Do not process data if using a render procedural, return a box instead for displaying in the
* viewport. */
if (BKE_cache_file_uses_render_procedural(cache_file, scene, DEG_get_mode(ctx->depsgraph))) {
if (BKE_cache_file_uses_render_procedural(cache_file, scene)) {
return generate_bounding_box_mesh(ctx->object, org_mesh);
}
@ -263,13 +263,13 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
#endif
}
static bool dependsOnTime(Scene *scene, ModifierData *md, const int dag_eval_mode)
static bool dependsOnTime(Scene *scene, ModifierData *md)
{
#if defined(WITH_USD) || defined(WITH_ALEMBIC)
MeshSeqCacheModifierData *mcmd = reinterpret_cast<MeshSeqCacheModifierData *>(md);
/* Do not evaluate animations if using the render engine procedural. */
return (mcmd->cache_file != nullptr) &&
!BKE_cache_file_uses_render_procedural(mcmd->cache_file, scene, dag_eval_mode);
!BKE_cache_file_uses_render_procedural(mcmd->cache_file, scene);
#else
UNUSED_VARS(scene, md, dag_eval_mode);
return false;

View File

@ -316,9 +316,7 @@ static bool check_tree_for_time_node(const bNodeTree &tree,
return false;
}
static bool dependsOnTime(struct Scene *UNUSED(scene),
ModifierData *md,
const int UNUSED(dag_eval_mode))
static bool dependsOnTime(struct Scene *UNUSED(scene), ModifierData *md)
{
const NodesModifierData *nmd = reinterpret_cast<NodesModifierData *>(md);
const bNodeTree *tree = nmd->node_group;

View File

@ -47,9 +47,7 @@ static void deformVerts(ModifierData *UNUSED(md),
ctx->depsgraph, scene, ctx->object, DEG_get_ctime(ctx->depsgraph), vertexCos, verts_num);
}
static bool dependsOnTime(struct Scene *UNUSED(scene),
ModifierData *UNUSED(md),
const int UNUSED(dag_eval_mode))
static bool dependsOnTime(struct Scene *UNUSED(scene), ModifierData *UNUSED(md))
{
return true;
}

View File

@ -83,9 +83,7 @@ static void freeData(ModifierData *md)
}
}
static bool dependsOnTime(struct Scene *UNUSED(scene),
ModifierData *UNUSED(md),
const int UNUSED(dag_eval_mode))
static bool dependsOnTime(struct Scene *UNUSED(scene), ModifierData *UNUSED(md))
{
return true;
}

View File

@ -82,9 +82,7 @@ static void foreachTexLink(ModifierData *md, Object *ob, TexWalkFunc walk, void
walk(userData, ob, md, "texture");
}
static bool dependsOnTime(struct Scene *UNUSED(scene),
ModifierData *md,
const int UNUSED(dag_eval_mode))
static bool dependsOnTime(struct Scene *UNUSED(scene), ModifierData *md)
{
VolumeDisplaceModifierData *vdmd = reinterpret_cast<VolumeDisplaceModifierData *>(md);
if (vdmd->texture) {

View File

@ -103,9 +103,7 @@ static void matrix_from_obj_pchan(float mat[4][4],
}
}
static bool dependsOnTime(struct Scene *UNUSED(scene),
ModifierData *md,
const int UNUSED(dag_eval_mode))
static bool dependsOnTime(struct Scene *UNUSED(scene), ModifierData *md)
{
WarpModifierData *wmd = (WarpModifierData *)md;

View File

@ -55,9 +55,7 @@ static void initData(ModifierData *md)
MEMCPY_STRUCT_AFTER(wmd, DNA_struct_default_get(WaveModifierData), modifier);
}
static bool dependsOnTime(struct Scene *UNUSED(scene),
ModifierData *UNUSED(md),
const int UNUSED(dag_eval_mode))
static bool dependsOnTime(struct Scene *UNUSED(scene), ModifierData *UNUSED(md))
{
return true;
}

View File

@ -97,9 +97,7 @@ static void requiredDataMask(Object *UNUSED(ob),
/* No need to ask for CD_PREVIEW_MLOOPCOL... */
}
static bool dependsOnTime(struct Scene *UNUSED(scene),
ModifierData *md,
const int UNUSED(dag_eval_mode))
static bool dependsOnTime(struct Scene *UNUSED(scene), ModifierData *md)
{
WeightVGEditModifierData *wmd = (WeightVGEditModifierData *)md;

View File

@ -145,9 +145,7 @@ static void requiredDataMask(Object *UNUSED(ob),
/* No need to ask for CD_PREVIEW_MLOOPCOL... */
}
static bool dependsOnTime(struct Scene *UNUSED(scene),
ModifierData *md,
const int UNUSED(dag_eval_mode))
static bool dependsOnTime(struct Scene *UNUSED(scene), ModifierData *md)
{
WeightVGMixModifierData *wmd = (WeightVGMixModifierData *)md;

View File

@ -347,9 +347,7 @@ static void requiredDataMask(Object *UNUSED(ob),
/* No need to ask for CD_PREVIEW_MLOOPCOL... */
}
static bool dependsOnTime(struct Scene *UNUSED(scene),
ModifierData *md,
const int UNUSED(dag_eval_mode))
static bool dependsOnTime(struct Scene *UNUSED(scene), ModifierData *md)
{
WeightVGProximityModifierData *wmd = (WeightVGProximityModifierData *)md;