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:
Diffstat (limited to 'source/blender/gpu/shaders')
-rw-r--r--source/blender/gpu/shaders/gpu_shader_common_obinfos_lib.glsl11
-rw-r--r--source/blender/gpu/shaders/material/gpu_shader_material_volume_info.glsl77
2 files changed, 27 insertions, 61 deletions
diff --git a/source/blender/gpu/shaders/gpu_shader_common_obinfos_lib.glsl b/source/blender/gpu/shaders/gpu_shader_common_obinfos_lib.glsl
index aa1d437c307..9e1527a9e7f 100644
--- a/source/blender/gpu/shaders/gpu_shader_common_obinfos_lib.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_common_obinfos_lib.glsl
@@ -1,7 +1,8 @@
-/* Need to be included after common_view_lib.glsl for resource_id. */
+#pragma BLENDER_REQUIRE(common_view_lib.glsl)
+
#ifndef GPU_OBINFOS_UBO
-#define GPU_OBINFOS_UBO
+# define GPU_OBINFOS_UBO
struct ObjectInfos {
vec4 drw_OrcoTexCoFactors[2];
vec4 drw_ObjectColor;
@@ -13,7 +14,7 @@ layout(std140) uniform infoBlock
/* DRW_RESOURCE_CHUNK_LEN = 512 */
ObjectInfos drw_infos[512];
};
-#define OrcoTexCoFactors (drw_infos[resource_id].drw_OrcoTexCoFactors)
-#define ObjectInfo (drw_infos[resource_id].drw_Infos)
-#define ObjectColor (drw_infos[resource_id].drw_ObjectColor)
+# define OrcoTexCoFactors (drw_infos[resource_id].drw_OrcoTexCoFactors)
+# define ObjectInfo (drw_infos[resource_id].drw_Infos)
+# define ObjectColor (drw_infos[resource_id].drw_ObjectColor)
#endif
diff --git a/source/blender/gpu/shaders/material/gpu_shader_material_volume_info.glsl b/source/blender/gpu/shaders/material/gpu_shader_material_volume_info.glsl
index 501aeb6f34e..a80cd3cb329 100644
--- a/source/blender/gpu/shaders/material/gpu_shader_material_volume_info.glsl
+++ b/source/blender/gpu/shaders/material/gpu_shader_material_volume_info.glsl
@@ -1,18 +1,21 @@
-void node_attribute_volume_density(sampler3D tex, out vec4 outcol, out vec3 outvec, out float outf)
+
+/* Uniforms to convert smoke grid values into standard range. */
+uniform vec3 volumeColor = vec3(1.0);
+uniform vec2 volumeTemperature = vec2(0.0);
+
+/* Generic volume attribute. */
+void node_attribute_volume(sampler3D tex, out vec3 outvec)
{
#if defined(MESH_SHADER) && defined(VOLUMETRICS)
vec3 cos = volumeObjectLocalCoord;
#else
vec3 cos = vec3(0.0);
#endif
- outvec = texture(tex, cos).aaa;
- outcol = vec4(outvec, 1.0);
- outf = avg(outvec);
+ outvec = texture(tex, cos).rgb;
}
-uniform vec3 volumeColor = vec3(1.0);
-
-void node_attribute_volume_color(sampler3D tex, out vec4 outcol, out vec3 outvec, out float outf)
+/* Special color attribute for smoke. */
+void node_attribute_volume_color(sampler3D tex, out vec3 outvec)
{
#if defined(MESH_SHADER) && defined(VOLUMETRICS)
vec3 cos = volumeObjectLocalCoord;
@@ -20,69 +23,31 @@ void node_attribute_volume_color(sampler3D tex, out vec4 outcol, out vec3 outvec
vec3 cos = vec3(0.0);
#endif
- vec4 value = texture(tex, cos).rgba;
/* Density is premultiplied for interpolation, divide it out here. */
+ vec4 value = texture(tex, cos).rgba;
if (value.a > 1e-8) {
value.rgb /= value.a;
}
outvec = value.rgb * volumeColor;
- outcol = vec4(outvec, 1.0);
- outf = avg(outvec);
}
-void node_attribute_volume_flame(sampler3D tex, out vec4 outcol, out vec3 outvec, out float outf)
+/* Special temperature attribute for smoke. */
+void node_attribute_volume_temperature(sampler3D tex, out float outf)
{
#if defined(MESH_SHADER) && defined(VOLUMETRICS)
vec3 cos = volumeObjectLocalCoord;
#else
vec3 cos = vec3(0.0);
#endif
- 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(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_volume_info(sampler3D densitySampler,
- sampler3D flameSampler,
- vec2 temperature,
- out vec4 outColor,
- out float outDensity,
- out float outFlame,
- out float outTemprature)
-{
-#if defined(MESH_SHADER) && defined(VOLUMETRICS)
- vec3 p = volumeObjectLocalCoord;
-#else
- vec3 p = vec3(0.0);
-#endif
-
- vec4 density = texture(densitySampler, p);
- outDensity = density.a;
-
- /* Density is premultiplied for interpolation, divide it out here. */
- if (density.a > 1e-8) {
- density.rgb /= density.a;
+ float value = texture(tex, cos).r;
+ if (volumeTemperature.x < volumeTemperature.y) {
+ outf = (value > 0.01) ?
+ volumeTemperature.x + value * (volumeTemperature.y - volumeTemperature.x) :
+ 0.0;
+ }
+ else {
+ outf = value;
}
- outColor = vec4(density.rgb * volumeColor, 1.0);
-
- float flame = texture(flameSampler, p).r;
- outFlame = flame;
-
- outTemprature = (flame > 0.01) ? temperature.x + flame * (temperature.y - temperature.x) : 0.0;
}