Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClément Foucault <foucault.clem@gmail.com>2018-10-08 18:20:02 +0300
committerClément Foucault <foucault.clem@gmail.com>2018-10-08 18:20:09 +0300
commite5c7c21630f9d67425bb3916cbc51deef185d2be (patch)
tree941be7912e9f31670e29c448e04d17178ed8cb51 /source/blender/draw/engines/workbench/shaders/workbench_volume_frag.glsl
parent8c4a7593f2189a57d348f4c3caf9fc1e3d552059 (diff)
Workbench: Smoke: Port back Flame display
The appearance is a bit different than 2.79 where the flame was just added on top of the smoke without correct blending. Now it's much more realistic and using volumetric integration. You can see the smoke actually masking the flame. The other difference is that the flame color was not using proper color managed blending. Now with the use of filmic it shows bright yellow. This could be adjusted and displayed as a user parameter in the future.
Diffstat (limited to 'source/blender/draw/engines/workbench/shaders/workbench_volume_frag.glsl')
-rw-r--r--source/blender/draw/engines/workbench/shaders/workbench_volume_frag.glsl9
1 files changed, 9 insertions, 0 deletions
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 fb3fcd2a4b6..0860660d8da 100644
--- a/source/blender/draw/engines/workbench/shaders/workbench_volume_frag.glsl
+++ b/source/blender/draw/engines/workbench/shaders/workbench_volume_frag.glsl
@@ -6,8 +6,11 @@ uniform mat4 ModelMatrix;
uniform vec3 OrcoTexCoFactors[2];
uniform sampler2D depthBuffer;
+
uniform sampler3D densityTexture;
uniform sampler3D shadowTexture;
+uniform sampler3D flameTexture;
+uniform sampler1D flameColorTexture;
uniform int samplesLen = 256;
uniform float stepLength; /* Step length in local space. */
@@ -65,6 +68,10 @@ float line_unit_box_intersect_dist(vec3 lineorigin, vec3 linedirection)
void volume_properties(vec3 ls_pos, out vec3 scattering, out float extinction)
{
vec3 co = ls_pos * 0.5 + 0.5;
+
+ float flame = texture(flameTexture, co).r;
+ vec4 emission = texture(flameColorTexture, flame);
+
float shadows = texture(shadowTexture, co).r;
vec4 density = texture(densityTexture, co); /* rgb: color, a: density */
density.a *= densityScale;
@@ -72,6 +79,8 @@ void volume_properties(vec3 ls_pos, out vec3 scattering, out float extinction)
scattering = density.rgb * density.a;
extinction = max(1e-4, dot(scattering, vec3(0.33333)));
scattering *= shadows * M_PI;
+ /* 800 is arbitrary and here to mimic old viewport. TODO make it a parameter */
+ scattering += pow(emission.rgb, vec3(2.2)) * emission.a * 800.0f;
}
void eval_volume_step(inout vec3 Lscat, float extinction, float step_len, out float Tr)