diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2019-03-14 00:35:54 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2019-03-14 01:15:11 +0300 |
commit | d0fb0d0a9d0d698a499d7e38943696a43a7e456e (patch) | |
tree | 22a118d2b1858da9228baad4161d46c0a9175a5e /source | |
parent | bbc3ee09e44bfaba1ca2d4ab6a6bf2a51976cdae (diff) |
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.
Diffstat (limited to 'source')
4 files changed, 16 insertions, 2 deletions
diff --git a/source/blender/draw/engines/eevee/eevee_volumes.c b/source/blender/draw/engines/eevee/eevee_volumes.c index cf12863565f..7297b6fbdda 100644 --- a/source/blender/draw/engines/eevee/eevee_volumes.c +++ b/source/blender/draw/engines/eevee/eevee_volumes.c @@ -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); } diff --git a/source/blender/draw/engines/workbench/shaders/workbench_volume_frag.glsl b/source/blender/draw/engines/workbench/shaders/workbench_volume_frag.glsl index 0d2d2187a85..c99787eaee8 100644 --- a/source/blender/draw/engines/workbench/shaders/workbench_volume_frag.glsl +++ b/source/blender/draw/engines/workbench/shaders/workbench_volume_frag.glsl @@ -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. */ diff --git a/source/blender/draw/engines/workbench/workbench_volume.c b/source/blender/draw/engines/workbench/workbench_volume.c index fa5ed3408d6..90d68cebe24 100644 --- a/source/blender/draw/engines/workbench/workbench_volume.c +++ b/source/blender/draw/engines/workbench/workbench_volume.c @@ -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); diff --git a/source/blender/gpu/shaders/gpu_shader_material.glsl b/source/blender/gpu/shaders/gpu_shader_material.glsl index df1a0b9e2a8..d91b6b77b86 100644 --- a/source/blender/gpu/shaders/gpu_shader_material.glsl +++ b/source/blender/gpu/shaders/gpu_shader_material.glsl @@ -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); } |