Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/engines/eevee/eevee_volumes.c
| Show All 22 Lines | |||||
| */ | */ | ||||
| #include "DRW_render.h" | #include "DRW_render.h" | ||||
| #include "BLI_rand.h" | #include "BLI_rand.h" | ||||
| #include "BLI_string_utils.h" | #include "BLI_string_utils.h" | ||||
| #include "DNA_object_force_types.h" | #include "DNA_object_force_types.h" | ||||
| #include "DNA_smoke_types.h" | #include "DNA_fluid_types.h" | ||||
| #include "DNA_world_types.h" | #include "DNA_world_types.h" | ||||
| #include "BKE_modifier.h" | #include "BKE_modifier.h" | ||||
| #include "BKE_mesh.h" | #include "BKE_mesh.h" | ||||
| #include "BKE_smoke.h" | #include "BKE_fluid.h" | ||||
| #include "ED_screen.h" | #include "ED_screen.h" | ||||
| #include "DEG_depsgraph_query.h" | #include "DEG_depsgraph_query.h" | ||||
| #include "eevee_private.h" | #include "eevee_private.h" | ||||
| #include "GPU_draw.h" | #include "GPU_draw.h" | ||||
| #include "GPU_extensions.h" | #include "GPU_extensions.h" | ||||
| Show All 13 Lines | static struct { | ||||
| GPUTexture *depth_src; | GPUTexture *depth_src; | ||||
| GPUTexture *dummy_density; | GPUTexture *dummy_density; | ||||
| GPUTexture *dummy_flame; | GPUTexture *dummy_flame; | ||||
| GPUTexture *dummy_scatter; | GPUTexture *dummy_scatter; | ||||
| GPUTexture *dummy_transmit; | GPUTexture *dummy_transmit; | ||||
| /* List of all smoke domains rendered within this frame. */ | /* List of all fluid simulation / smoke domains rendered within this frame. */ | ||||
| ListBase smoke_domains; | ListBase smoke_domains; | ||||
| } e_data = {NULL}; /* Engine data */ | } e_data = {NULL}; /* Engine data */ | ||||
| extern char datatoc_bsdf_common_lib_glsl[]; | extern char datatoc_bsdf_common_lib_glsl[]; | ||||
| extern char datatoc_common_uniforms_lib_glsl[]; | extern char datatoc_common_uniforms_lib_glsl[]; | ||||
| extern char datatoc_common_view_lib_glsl[]; | extern char datatoc_common_view_lib_glsl[]; | ||||
| extern char datatoc_octahedron_lib_glsl[]; | extern char datatoc_octahedron_lib_glsl[]; | ||||
| extern char datatoc_irradiance_lib_glsl[]; | extern char datatoc_irradiance_lib_glsl[]; | ||||
| ▲ Show 20 Lines • Show All 350 Lines • ▼ Show 20 Lines | void EEVEE_volumes_cache_object_add(EEVEE_ViewLayerData *sldata, | ||||
| DRW_shgroup_uniform_block(grp, "grid_block", sldata->grid_ubo); | DRW_shgroup_uniform_block(grp, "grid_block", sldata->grid_ubo); | ||||
| DRW_shgroup_uniform_block(grp, "common_block", sldata->common_ubo); | DRW_shgroup_uniform_block(grp, "common_block", sldata->common_ubo); | ||||
| DRW_shgroup_uniform_vec3(grp, "volumeOrcoLoc", texcoloc, 1); | DRW_shgroup_uniform_vec3(grp, "volumeOrcoLoc", texcoloc, 1); | ||||
| DRW_shgroup_uniform_vec3(grp, "volumeOrcoSize", texcosize, 1); | DRW_shgroup_uniform_vec3(grp, "volumeOrcoSize", texcosize, 1); | ||||
| /* Smoke Simulation */ | /* Smoke Simulation */ | ||||
| if (((ob->base_flag & BASE_FROM_DUPLI) == 0) && | if (((ob->base_flag & BASE_FROM_DUPLI) == 0) && | ||||
| (md = modifiers_findByType(ob, eModifierType_Smoke)) && | (md = modifiers_findByType(ob, eModifierType_Fluid)) && | ||||
| (modifier_isEnabled(scene, md, eModifierMode_Realtime)) && | (modifier_isEnabled(scene, md, eModifierMode_Realtime)) && | ||||
| ((SmokeModifierData *)md)->domain != NULL) { | ((FluidModifierData *)md)->domain != NULL) { | ||||
| SmokeModifierData *smd = (SmokeModifierData *)md; | FluidModifierData *mmd = (FluidModifierData *)md; | ||||
| SmokeDomainSettings *sds = smd->domain; | FluidDomainSettings *mds = mmd->domain; | ||||
| /* Don't show smoke before simulation starts, this could be made an option in the future. */ | /* Don't try to show liquid domains here. */ | ||||
| const bool show_smoke = ((int)DEG_get_ctime(draw_ctx->depsgraph) >= | if (!mds->fluid || !(mds->type == FLUID_DOMAIN_TYPE_GAS)) { | ||||
| sds->point_cache[0]->startframe); | return; | ||||
| } | |||||
| if (sds->fluid && show_smoke) { | /* Don't show smoke before simulation starts, this could be made an option in the future. */ | ||||
| const bool show_highres = BKE_smoke_show_highres(scene, sds); | /* (sebbas): Always show smoke for manta */ | ||||
| if (!sds->wt || !show_highres) { | /* const bool show_smoke = ((int)DEG_get_ctime(draw_ctx->depsgraph) >= | ||||
| GPU_create_smoke(smd, 0); | * mds->point_cache[0]->startframe); */ | ||||
| if (mds->fluid && (mds->type == FLUID_DOMAIN_TYPE_GAS) /* && show_smoke */) { | |||||
| if (!(mds->flags & FLUID_DOMAIN_USE_NOISE)) { | |||||
| GPU_create_smoke(mmd, 0); | |||||
| } | } | ||||
| else if (sds->wt && show_highres) { | else if (mds->flags & FLUID_DOMAIN_USE_NOISE) { | ||||
| GPU_create_smoke(smd, 1); | GPU_create_smoke(mmd, 1); | ||||
| } | } | ||||
| BLI_addtail(&e_data.smoke_domains, BLI_genericNodeN(smd)); | BLI_addtail(&e_data.smoke_domains, BLI_genericNodeN(mmd)); | ||||
| } | } | ||||
| DRW_shgroup_uniform_texture_ref( | DRW_shgroup_uniform_texture_ref( | ||||
| grp, "sampdensity", sds->tex ? &sds->tex : &e_data.dummy_density); | grp, "sampdensity", mds->tex ? &mds->tex : &e_data.dummy_density); | ||||
| DRW_shgroup_uniform_texture_ref( | DRW_shgroup_uniform_texture_ref( | ||||
| grp, "sampflame", sds->tex_flame ? &sds->tex_flame : &e_data.dummy_flame); | grp, "sampflame", mds->tex_flame ? &mds->tex_flame : &e_data.dummy_flame); | ||||
| /* Constant Volume color. */ | /* Constant Volume color. */ | ||||
| bool use_constant_color = ((sds->active_fields & SM_ACTIVE_COLORS) == 0 && | static float white[3] = {1.0f, 1.0f, 1.0f}; | ||||
| (sds->active_fields & SM_ACTIVE_COLOR_SET) != 0); | bool use_constant_color = ((mds->active_fields & FLUID_DOMAIN_ACTIVE_COLORS) == 0 && | ||||
| (mds->active_fields & FLUID_DOMAIN_ACTIVE_COLOR_SET) != 0); | |||||
| DRW_shgroup_uniform_vec3( | DRW_shgroup_uniform_vec3( | ||||
| grp, "volumeColor", (use_constant_color) ? sds->active_color : white, 1); | grp, "volumeColor", (use_constant_color) ? mds->active_color : white, 1); | ||||
| /* Output is such that 0..1 maps to 0..1000K */ | /* Output is such that 0..1 maps to 0..1000K */ | ||||
| DRW_shgroup_uniform_vec2(grp, "unftemperature", &sds->flame_ignition, 1); | DRW_shgroup_uniform_vec2(grp, "unftemperature", &mds->flame_ignition, 1); | ||||
| } | } | ||||
| else { | else { | ||||
| DRW_shgroup_uniform_texture(grp, "sampdensity", e_data.dummy_density); | DRW_shgroup_uniform_texture(grp, "sampdensity", e_data.dummy_density); | ||||
| DRW_shgroup_uniform_texture(grp, "sampflame", e_data.dummy_flame); | DRW_shgroup_uniform_texture(grp, "sampflame", e_data.dummy_flame); | ||||
| DRW_shgroup_uniform_vec3(grp, "volumeColor", white, 1); | DRW_shgroup_uniform_vec3(grp, "volumeColor", white, 1); | ||||
| DRW_shgroup_uniform_vec2(grp, "unftemperature", (float[2]){0.0f, 1.0f}, 1); | DRW_shgroup_uniform_vec2(grp, "unftemperature", (float[2]){0.0f, 1.0f}, 1); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 211 Lines • ▼ Show 20 Lines | if ((effects->enabled_effects & EFFECT_VOLUMETRIC) != 0) { | ||||
| GPU_framebuffer_bind(fbl->main_fb); | GPU_framebuffer_bind(fbl->main_fb); | ||||
| } | } | ||||
| } | } | ||||
| void EEVEE_volumes_free_smoke_textures(void) | void EEVEE_volumes_free_smoke_textures(void) | ||||
| { | { | ||||
| /* Free Smoke Textures after rendering */ | /* Free Smoke Textures after rendering */ | ||||
| for (LinkData *link = e_data.smoke_domains.first; link; link = link->next) { | for (LinkData *link = e_data.smoke_domains.first; link; link = link->next) { | ||||
| SmokeModifierData *smd = (SmokeModifierData *)link->data; | FluidModifierData *mmd = (FluidModifierData *)link->data; | ||||
| GPU_free_smoke(smd); | GPU_free_smoke(mmd); | ||||
| } | } | ||||
| BLI_freelistN(&e_data.smoke_domains); | BLI_freelistN(&e_data.smoke_domains); | ||||
| } | } | ||||
| void EEVEE_volumes_free(void) | void EEVEE_volumes_free(void) | ||||
| { | { | ||||
| MEM_SAFE_FREE(e_data.volumetric_common_lib); | MEM_SAFE_FREE(e_data.volumetric_common_lib); | ||||
| MEM_SAFE_FREE(e_data.volumetric_common_lights_lib); | MEM_SAFE_FREE(e_data.volumetric_common_lights_lib); | ||||
| Show All 13 Lines | |||||