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:
authorBrecht Van Lommel <brechtvanlommel@gmail.com>2018-02-22 20:51:20 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2018-02-23 21:10:02 +0300
commitaf061b4dac140c5acea21f69257bfc5c18b3fe1c (patch)
treeb37010940b6f984f866367621912296111c7424b /source/blender/gpu
parenta44b08a6c473c0aae9f98dc13f9d000e5ea639bc (diff)
Eeevee: add temperature grid support, make color grid unpremultiplied.
This matches similar changes done for Cycles.
Diffstat (limited to 'source/blender/gpu')
-rw-r--r--source/blender/gpu/GPU_material.h3
-rw-r--r--source/blender/gpu/intern/gpu_codegen.c2
-rw-r--r--source/blender/gpu/shaders/gpu_shader_material.glsl28
3 files changed, 28 insertions, 5 deletions
diff --git a/source/blender/gpu/GPU_material.h b/source/blender/gpu/GPU_material.h
index e2f40ff5c54..8f1ee7ccc59 100644
--- a/source/blender/gpu/GPU_material.h
+++ b/source/blender/gpu/GPU_material.h
@@ -110,7 +110,8 @@ typedef enum GPUBuiltin {
GPU_INVERSE_LOC_TO_VIEW_MATRIX = (1 << 14),
GPU_OBJECT_INFO = (1 << 15),
GPU_VOLUME_DENSITY = (1 << 16),
- GPU_VOLUME_FLAME = (1 << 17)
+ GPU_VOLUME_FLAME = (1 << 17),
+ GPU_VOLUME_TEMPERATURE = (1 << 18)
} GPUBuiltin;
typedef enum GPUOpenGLBuiltin {
diff --git a/source/blender/gpu/intern/gpu_codegen.c b/source/blender/gpu/intern/gpu_codegen.c
index 9e4daa2a036..ce75d944747 100644
--- a/source/blender/gpu/intern/gpu_codegen.c
+++ b/source/blender/gpu/intern/gpu_codegen.c
@@ -427,6 +427,8 @@ const char *GPU_builtin_name(GPUBuiltin builtin)
return "sampdensity";
else if (builtin == GPU_VOLUME_FLAME)
return "sampflame";
+ else if (builtin == GPU_VOLUME_TEMPERATURE)
+ return "unftemperature";
else
return "";
}
diff --git a/source/blender/gpu/shaders/gpu_shader_material.glsl b/source/blender/gpu/shaders/gpu_shader_material.glsl
index 7acd9aa1fd5..71333149634 100644
--- a/source/blender/gpu/shaders/gpu_shader_material.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_material.glsl
@@ -3153,7 +3153,13 @@ void node_attribute_volume_color(sampler3D tex, out vec4 outcol, out vec3 outvec
#else
vec3 cos = vec3(0.0);
#endif
- outvec = texture(tex, cos).rgb;
+
+ vec4 value = texture(tex, cos).rgba;
+ /* Density is premultiplied for interpolation, divide it out here. */
+ if (value.a > 0.0)
+ value.rgb /= value.a;
+
+ outvec = value.rgb;
outcol = vec4(outvec, 1.0);
outf = dot(vec3(1.0 / 3.0), outvec);
}
@@ -3165,9 +3171,23 @@ void node_attribute_volume_flame(sampler3D tex, out vec4 outcol, out vec3 outvec
#else
vec3 cos = vec3(0.0);
#endif
- outvec = texture(tex, cos).rrr;
- outcol = vec4(outvec, 1.0);
- outf = dot(vec3(1.0 / 3.0), outvec);
+ outf = texture(tex, cos).r;
+ outvec = vec3(outf, outf, outf);
+ outcol = vec4(outf, outf, outf, 1.0);
+}
+
+void node_attribute_volume_temperature(sampler3D tex, vec2 temperature, out vec4 outcol, out vec3 outvec, out float outf)
+{
+#if defined(EEVEE_ENGINE) && defined(MESH_SHADER) && defined(VOLUMETRICS)
+ vec3 cos = volumeObjectLocalCoord;
+#else
+ vec3 cos = vec3(0.0);
+#endif
+ float flame = texture(tex, cos).r;
+
+ outf = (flame > 0.01) ? temperature.x + flame * (temperature.y - temperature.x): 0.0;
+ outvec = vec3(outf, outf, outf);
+ outcol = vec4(outf, outf, outf, 1.0);
}
void node_attribute(vec3 attr, out vec4 outcol, out vec3 outvec, out float outf)