Fix T60170: Eevee: smoke color does not apply permanently
This was because color is not present in the density texture if there is only one constant color. Adding it as a uniform.
This commit is contained in:
parent
bbc3ee09e4
commit
d0fb0d0a9d
Notes:
blender-bot
2023-02-14 07:36:17 +01:00
Referenced by issue #60170, eevee smoke color does not apply permanently
|
@ -525,6 +525,13 @@ void EEVEE_volumes_cache_object_add(EEVEE_ViewLayerData *sldata, EEVEE_Data *ved
|
|||
DRW_shgroup_uniform_texture_ref(grp, "sampflame", &sds->tex_flame);
|
||||
}
|
||||
|
||||
/* Constant Volume color. */
|
||||
static float white[3] = {1.0f, 1.0f, 1.0f};
|
||||
bool use_constant_color = ((sds->active_fields & SM_ACTIVE_COLORS) == 0 &&
|
||||
(sds->active_fields & SM_ACTIVE_COLOR_SET) != 0);
|
||||
|
||||
DRW_shgroup_uniform_vec3(grp, "volumeColor", (use_constant_color) ? sds->active_color : white, 1);
|
||||
|
||||
/* Output is such that 0..1 maps to 0..1000K */
|
||||
DRW_shgroup_uniform_vec2(grp, "unftemperature", &sds->flame_ignition, 1);
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ uniform float noiseOfs = 0.0f;
|
|||
uniform float stepLength; /* Step length in local space. */
|
||||
uniform float densityScale; /* Simple Opacity multiplicator. */
|
||||
uniform vec4 viewvecs[3];
|
||||
uniform vec3 activeColor;
|
||||
|
||||
uniform float slicePosition;
|
||||
uniform int sliceAxis; /* -1 is no slice, 0 is X, 1 is Y, 2 is Z. */
|
||||
|
@ -135,7 +136,7 @@ void volume_properties(vec3 ls_pos, out vec3 scattering, out float extinction)
|
|||
float shadows = sample_volume_texture(shadowTexture, co).r;
|
||||
vec4 density = sample_volume_texture(densityTexture, co); /* rgb: color, a: density */
|
||||
|
||||
scattering = density.rgb * (density.a * densityScale);
|
||||
scattering = density.rgb * (density.a * densityScale) * activeColor;
|
||||
extinction = max(1e-4, dot(scattering, vec3(0.33333)));
|
||||
|
||||
/* Scale shadows in log space and clamp them to avoid completely black shadows. */
|
||||
|
|
|
@ -191,10 +191,14 @@ void workbench_volume_cache_populate(WORKBENCH_Data *vedata, Scene *scene, Objec
|
|||
DRW_shgroup_uniform_texture(grp, "transferTexture", sds->tex_coba);
|
||||
}
|
||||
else {
|
||||
static float white[3] = {1.0f, 1.0f, 1.0f};
|
||||
bool use_constant_color = ((sds->active_fields & SM_ACTIVE_COLORS) == 0 &&
|
||||
(sds->active_fields & SM_ACTIVE_COLOR_SET) != 0);
|
||||
DRW_shgroup_uniform_texture(grp, "densityTexture", sds->tex);
|
||||
DRW_shgroup_uniform_texture(grp, "shadowTexture", sds->tex_shadow);
|
||||
DRW_shgroup_uniform_texture(grp, "flameTexture", (sds->tex_flame) ? sds->tex_flame : e_data.dummy_tex);
|
||||
DRW_shgroup_uniform_texture(grp, "flameColorTexture", (sds->tex_flame) ? sds->tex_flame_coba : e_data.dummy_coba_tex);
|
||||
DRW_shgroup_uniform_vec3(grp, "activeColor", (use_constant_color) ? sds->active_color : white, 1);
|
||||
}
|
||||
DRW_shgroup_uniform_texture_ref(grp, "depthBuffer", &dtxl->depth);
|
||||
DRW_shgroup_uniform_float_copy(grp, "densityScale", 10.0f * sds->display_thickness);
|
||||
|
|
|
@ -1701,6 +1701,8 @@ void node_attribute_volume_density(sampler3D tex, out vec4 outcol, out vec3 outv
|
|||
outf = dot(vec3(1.0 / 3.0), outvec);
|
||||
}
|
||||
|
||||
uniform vec3 volumeColor = vec3(1.0);
|
||||
|
||||
void node_attribute_volume_color(sampler3D tex, out vec4 outcol, out vec3 outvec, out float outf)
|
||||
{
|
||||
#if defined(MESH_SHADER) && defined(VOLUMETRICS)
|
||||
|
@ -1714,7 +1716,7 @@ void node_attribute_volume_color(sampler3D tex, out vec4 outcol, out vec3 outvec
|
|||
if (value.a > 1e-8)
|
||||
value.rgb /= value.a;
|
||||
|
||||
outvec = value.rgb;
|
||||
outvec = value.rgb * volumeColor;
|
||||
outcol = vec4(outvec, 1.0);
|
||||
outf = dot(vec3(1.0 / 3.0), outvec);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue