diff options
author | Brecht Van Lommel <brecht> | 2020-03-11 15:56:28 +0300 |
---|---|---|
committer | Brecht Van Lommel <brecht@blender.org> | 2020-03-11 16:42:46 +0300 |
commit | c8acb6dd6c58c6a85ab18d26f02973437cb2f700 (patch) | |
tree | c45a1b47d8692b7b633507d97f325fa5c2f5a3c8 /intern/mantaflow | |
parent | f3a33a92987fd648f194898c3789f573fdadca6f (diff) |
Smoke: put density/color in separate textures, fixes for workbench shader
This is more in line with standard grids and means we don't have to make
many special exceptions in the upcoming change for arbitrary number of volume
grids support in Eevee.
The workbench shader was also changed to fix bugs where squared density was
used, and the smoke color would affect the density so that black smoke would
be invisible. This can change the look of smoke in workbench significantly.
When using the color grid when smoke has a constant color, the color grid
will no longer be premultiplied by the density. If the color is constant
we want to be able not to store a grid at all. This breaks one test for
Cycles and Eevee, but the setup in that test using a color without density
does not make sense. It suffers from artifacts since the unpremultiplied
color grid by itself will not have smooth boundaries.
Differential Revision: https://developer.blender.org/D6951
Diffstat (limited to 'intern/mantaflow')
-rw-r--r-- | intern/mantaflow/extern/manta_fluid_API.h | 16 | ||||
-rw-r--r-- | intern/mantaflow/intern/manta_fluid_API.cpp | 43 |
2 files changed, 23 insertions, 36 deletions
diff --git a/intern/mantaflow/extern/manta_fluid_API.h b/intern/mantaflow/extern/manta_fluid_API.h index 5ed94d99edd..48d42504994 100644 --- a/intern/mantaflow/extern/manta_fluid_API.h +++ b/intern/mantaflow/extern/manta_fluid_API.h @@ -132,14 +132,14 @@ void manta_smoke_turbulence_export(struct MANTA *smoke, float **tcw2); void manta_smoke_get_rgba(struct MANTA *smoke, float *data, int sequential); void manta_smoke_turbulence_get_rgba(struct MANTA *smoke, float *data, int sequential); -void manta_smoke_get_rgba_from_density(struct MANTA *smoke, - float color[3], - float *data, - int sequential); -void manta_smoke_turbulence_get_rgba_from_density(struct MANTA *smoke, - float color[3], - float *data, - int sequential); +void manta_smoke_get_rgba_fixed_color(struct MANTA *smoke, + float color[3], + float *data, + int sequential); +void manta_smoke_turbulence_get_rgba_fixed_color(struct MANTA *smoke, + float color[3], + float *data, + int sequential); void manta_smoke_ensure_heat(struct MANTA *smoke, struct FluidModifierData *mmd); void manta_smoke_ensure_fire(struct MANTA *smoke, struct FluidModifierData *mmd); void manta_smoke_ensure_colors(struct MANTA *smoke, struct FluidModifierData *mmd); diff --git a/intern/mantaflow/intern/manta_fluid_API.cpp b/intern/mantaflow/intern/manta_fluid_API.cpp index 7e3e4520485..89c69bebc51 100644 --- a/intern/mantaflow/intern/manta_fluid_API.cpp +++ b/intern/mantaflow/intern/manta_fluid_API.cpp @@ -455,14 +455,9 @@ static void get_rgba( for (i = 0; i < total_cells; i++) { float alpha = a[i]; - if (alpha) { - data[i * m] = r[i]; - data[i * m + i_g] = g[i]; - data[i * m + i_b] = b[i]; - } - else { - data[i * m] = data[i * m + i_g] = data[i * m + i_b] = 0.0f; - } + data[i * m] = r[i] * alpha; + data[i * m + i_g] = g[i] * alpha; + data[i * m + i_b] = b[i] * alpha; data[i * m + i_a] = alpha; } } @@ -489,8 +484,7 @@ void manta_smoke_turbulence_get_rgba(MANTA *smoke, float *data, int sequential) sequential); } -static void get_rgba_from_density( - float color[3], float *a, int total_cells, float *data, int sequential) +static void get_rgba_fixed_color(float color[3], int total_cells, float *data, int sequential) { int i; int m = 4, i_g = 1, i_b = 2, i_a = 3; @@ -502,31 +496,24 @@ static void get_rgba_from_density( } for (i = 0; i < total_cells; i++) { - float alpha = a[i]; - if (alpha) { - data[i * m] = color[0] * alpha; - data[i * m + i_g] = color[1] * alpha; - data[i * m + i_b] = color[2] * alpha; - } - else { - data[i * m] = data[i * m + i_g] = data[i * m + i_b] = 0.0f; - } - data[i * m + i_a] = alpha; + data[i * m] = color[0]; + data[i * m + i_g] = color[1]; + data[i * m + i_b] = color[2]; + data[i * m + i_a] = 1.0f; } } -void manta_smoke_get_rgba_from_density(MANTA *smoke, float color[3], float *data, int sequential) +void manta_smoke_get_rgba_fixed_color(MANTA *smoke, float color[3], float *data, int sequential) { - get_rgba_from_density(color, smoke->getDensity(), smoke->getTotalCells(), data, sequential); + get_rgba_fixed_color(color, smoke->getTotalCells(), data, sequential); } -void manta_smoke_turbulence_get_rgba_from_density(MANTA *smoke, - float color[3], - float *data, - int sequential) +void manta_smoke_turbulence_get_rgba_fixed_color(MANTA *smoke, + float color[3], + float *data, + int sequential) { - get_rgba_from_density( - color, smoke->getDensityHigh(), smoke->getTotalCellsHigh(), data, sequential); + get_rgba_fixed_color(color, smoke->getTotalCellsHigh(), data, sequential); } void manta_smoke_ensure_heat(MANTA *smoke, struct FluidModifierData *mmd) |