From 7a693626d63a52acd12e80209b634711154a2f9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Mon, 16 Jul 2018 15:01:44 +0200 Subject: Smoke: Port display to Workbench + object mode This does not fix the smokesim. It only port the drawing method. The Object mode engine is in charge of rendering the velocity debugging. Things left to do: - Flame rendering. - Color Ramp coloring of volume data. - View facing slicing (for now it's only doing sampling starting from the volume bounds which gives a squarish look) - Add option to enable dithering (currently on by default. --- source/blender/gpu/GPU_draw.h | 2 ++ source/blender/gpu/intern/gpu_draw.c | 46 ++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) (limited to 'source/blender/gpu') diff --git a/source/blender/gpu/GPU_draw.h b/source/blender/gpu/GPU_draw.h index ebce83d2a5f..028756bc739 100644 --- a/source/blender/gpu/GPU_draw.h +++ b/source/blender/gpu/GPU_draw.h @@ -101,7 +101,9 @@ void GPU_free_images_old(struct Main *bmain); /* smoke drawing functions */ void GPU_free_smoke(struct SmokeModifierData *smd); +void GPU_free_smoke_velocity(struct SmokeModifierData *smd); void GPU_create_smoke(struct SmokeModifierData *smd, int highres); +void GPU_create_smoke_velocity(struct SmokeModifierData *smd); /* Delayed free of OpenGL buffers by main thread */ void GPU_free_unused_buffers(struct Main *bmain); diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c index 7383868843d..e2c83d6fadf 100644 --- a/source/blender/gpu/intern/gpu_draw.c +++ b/source/blender/gpu/intern/gpu_draw.c @@ -971,6 +971,52 @@ void GPU_create_smoke(SmokeModifierData *smd, int highres) #endif // WITH_SMOKE } +void GPU_create_smoke_velocity(SmokeModifierData *smd) +{ +#ifdef WITH_SMOKE + if (smd->type & MOD_SMOKE_TYPE_DOMAIN) { + SmokeDomainSettings *sds = smd->domain; + + const float *vel_x = smoke_get_velocity_x(sds->fluid); + const float *vel_y = smoke_get_velocity_y(sds->fluid); + const float *vel_z = smoke_get_velocity_z(sds->fluid); + + if (ELEM(NULL, vel_x, vel_y, vel_z)) { + return; + } + + if (!sds->tex_velocity_x) { + sds->tex_velocity_x = GPU_texture_create_3D(sds->res[0], sds->res[1], sds->res[2], GPU_R16F, vel_x, NULL); + sds->tex_velocity_y = GPU_texture_create_3D(sds->res[0], sds->res[1], sds->res[2], GPU_R16F, vel_y, NULL); + sds->tex_velocity_z = GPU_texture_create_3D(sds->res[0], sds->res[1], sds->res[2], GPU_R16F, vel_z, NULL); + } + } +#else // WITH_SMOKE + smd->domain->tex_velocity_x = NULL; + smd->domain->tex_velocity_y = NULL; + smd->domain->tex_velocity_z = NULL; +#endif // WITH_SMOKE +} + +/* TODO Unify with the other GPU_free_smoke. */ +void GPU_free_smoke_velocity(SmokeModifierData *smd) +{ + if (smd->type & MOD_SMOKE_TYPE_DOMAIN && smd->domain) { + if (smd->domain->tex_velocity_x) + GPU_texture_free(smd->domain->tex_velocity_x); + + if (smd->domain->tex_velocity_y) + GPU_texture_free(smd->domain->tex_velocity_y); + + if (smd->domain->tex_velocity_z) + GPU_texture_free(smd->domain->tex_velocity_z); + + smd->domain->tex_velocity_x = NULL; + smd->domain->tex_velocity_y = NULL; + smd->domain->tex_velocity_z = NULL; + } +} + static LinkNode *image_free_queue = NULL; static void gpu_queue_image_for_free(Image *ima) -- cgit v1.2.3