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
This commit is contained in:
@@ -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) ?
|
||||
|
||||
Reference in New Issue
Block a user