diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2020-03-17 18:27:08 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2020-03-18 13:23:05 +0300 |
commit | fd53b72871e045dfebfb9ddbe2b3c491491aa913 (patch) | |
tree | 892721f97e6bff16c9d87bc3ffee295d2f4a77bc /source/blender/gpu/shaders/material | |
parent | b0a1cf2c9ae696b07f7a236bc855a5ab4a493dcb (diff) |
Objects: Eevee and workbench rendering of new Volume, Hair, PointCloud
Only the volume drawing part is really finished and exposed to the user. Hair
plugs into the existing hair rendering code and is fairly straightforward. The
pointcloud drawing is a hack using overlays rather than Eevee and workbench.
The most tricky part for volume rendering is the case where each volume grid
has a different transform, which requires an additional matrix in the shader
and non-trivial logic in Eevee volume drawing. In the common case were all the
transforms match we don't use the additional per-grid matrix in the shader.
Ref T73201, T68981
Differential Revision: https://developer.blender.org/D6955
Diffstat (limited to 'source/blender/gpu/shaders/material')
-rw-r--r-- | source/blender/gpu/shaders/material/gpu_shader_material_volume_info.glsl | 22 |
1 files changed, 19 insertions, 3 deletions
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 a80cd3cb329..e6d7b9d3721 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 @@ -4,18 +4,24 @@ uniform vec3 volumeColor = vec3(1.0); uniform vec2 volumeTemperature = vec2(0.0); /* Generic volume attribute. */ -void node_attribute_volume(sampler3D tex, out vec3 outvec) +void node_attribute_volume(sampler3D tex, mat4 transform, out vec3 outvec) { #if defined(MESH_SHADER) && defined(VOLUMETRICS) vec3 cos = volumeObjectLocalCoord; #else vec3 cos = vec3(0.0); #endif + + /* Optional per-grid transform. */ + if (transform[3][3] != 0.0) { + cos = (transform * vec4(cos, 1.0)).xyz; + } + outvec = texture(tex, cos).rgb; } /* Special color attribute for smoke. */ -void node_attribute_volume_color(sampler3D tex, out vec3 outvec) +void node_attribute_volume_color(sampler3D tex, mat4 transform, out vec3 outvec) { #if defined(MESH_SHADER) && defined(VOLUMETRICS) vec3 cos = volumeObjectLocalCoord; @@ -23,6 +29,11 @@ void node_attribute_volume_color(sampler3D tex, out vec3 outvec) vec3 cos = vec3(0.0); #endif + /* Optional per-grid transform. */ + if (transform[3][3] != 0.0) { + cos = (transform * vec4(cos, 1.0)).xyz; + } + /* Density is premultiplied for interpolation, divide it out here. */ vec4 value = texture(tex, cos).rgba; if (value.a > 1e-8) { @@ -33,7 +44,7 @@ void node_attribute_volume_color(sampler3D tex, out vec3 outvec) } /* Special temperature attribute for smoke. */ -void node_attribute_volume_temperature(sampler3D tex, out float outf) +void node_attribute_volume_temperature(sampler3D tex, mat4 transform, out float outf) { #if defined(MESH_SHADER) && defined(VOLUMETRICS) vec3 cos = volumeObjectLocalCoord; @@ -41,6 +52,11 @@ void node_attribute_volume_temperature(sampler3D tex, out float outf) vec3 cos = vec3(0.0); #endif + /* Optional per-grid transform. */ + if (transform[3][3] != 0.0) { + cos = (transform * vec4(cos, 1.0)).xyz; + } + float value = texture(tex, cos).r; if (volumeTemperature.x < volumeTemperature.y) { outf = (value > 0.01) ? |