Cycles Volume Render: add flags to quickly detect when objects have a volume shader.

This commit is contained in:
Brecht Van Lommel
2013-12-28 02:27:48 +01:00
parent a35db17cee
commit 37c4d6a50a
5 changed files with 42 additions and 16 deletions

View File

@@ -218,6 +218,7 @@ void ShaderManager::device_update_common(Device *device, DeviceScene *dscene, Sc
uint *shader_flag = dscene->shader_flag.resize(shader_flag_size);
uint i = 0;
bool has_converter_blackbody = false;
bool has_volumes = false;
foreach(Shader *shader, scene->shaders) {
uint flag = 0;
@@ -226,8 +227,19 @@ void ShaderManager::device_update_common(Device *device, DeviceScene *dscene, Sc
flag |= SD_USE_MIS;
if(shader->has_surface_transparent && shader->use_transparent_shadow)
flag |= SD_HAS_TRANSPARENT_SHADOW;
if(shader->has_volume)
if(shader->has_volume) {
flag |= SD_HAS_VOLUME;
has_volumes = true;
/* in this case we can assume transparent surface */
if(!shader->has_surface)
flag |= SD_HAS_ONLY_VOLUME;
/* todo: this could check more fine grained, to skip useless volumes
* enclosed inside an opaque bsdf, although we still need to handle
* the case with camera inside volumes too */
flag |= SD_HAS_TRANSPARENT_SHADOW;
}
if(shader->homogeneous_volume)
flag |= SD_HOMOGENEOUS_VOLUME;
if(shader->has_bssrdf_bump)
@@ -263,6 +275,9 @@ void ShaderManager::device_update_common(Device *device, DeviceScene *dscene, Sc
blackbody_table_offset = TABLE_OFFSET_INVALID;
}
/* volumes */
KernelIntegrator *kintegrator = &dscene->data.integrator;
kintegrator->use_volumes = has_volumes;
}
void ShaderManager::device_free_common(Device *device, DeviceScene *dscene, Scene *scene)