blob: 677881abd71d7ea86b28f15581f04aa70d66a6b9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
/**
* Apply heterogeneous volume lighting and evaluates homogeneous volumetrics if needed.
*
* We read volume parameters from the gbuffer and consider them constant for the whole volume.
* This only applies to solid objects not volumes.
**/
#pragma BLENDER_REQUIRE(common_view_lib.glsl)
#pragma BLENDER_REQUIRE(common_math_lib.glsl)
#pragma BLENDER_REQUIRE(eevee_bsdf_lib.glsl)
#pragma BLENDER_REQUIRE(eevee_culling_iter_lib.glsl)
#pragma BLENDER_REQUIRE(eevee_shadow_lib.glsl)
#pragma BLENDER_REQUIRE(eevee_gbuffer_lib.glsl)
#pragma BLENDER_REQUIRE(eevee_volume_eval_lib.glsl)
#pragma BLENDER_REQUIRE(eevee_shader_shared.hh)
layout(std140) uniform lights_block
{
LightData lights[CULLING_ITEM_BATCH];
};
layout(std140) uniform lights_culling_block
{
CullingData light_culling;
};
layout(std140) uniform shadows_block
{
ShadowData shadows[CULLING_ITEM_BATCH];
};
uniform sampler2D transparency_data_tx;
uniform usampler2D volume_data_tx;
uniform usampler2D lights_culling_tx;
uniform sampler2DArray utility_tx;
uniform sampler2DShadow shadow_atlas_tx;
uniform usampler2D shadow_tilemaps_tx;
utility_tx_fetch_define(utility_tx) utility_tx_sample_define(utility_tx)
in vec4 uvcoordsvar;
layout(location = 0) out vec4 out_combined;
layout(location = 1) out vec3 out_volume;
void main(void)
{
ClosureVolume volume_data = gbuffer_load_volume_data(volume_data_tx, uvcoordsvar.xy);
/* For volumes from solid objects. */
// float depth_max = linear_z(texture(depth_max_tx, uv).r);
// float depth_min = linear_z(texture(depth_min_tx, uv).r);
/* Refine bounds to skip empty areas. */
// float dist_from_bbox = intersect_bbox_ray(P, V, bbox);
// depth_min = max(dist_from_bbox, depth_min);
vec3 volume_radiance;
if (volume_data.anisotropy == VOLUME_HETEROGENEOUS) {
volume_radiance = volume_data.scattering;
}
else {
// volume_eval_homogeneous(P, depth_min, depth_max, volume_radiance);
volume_radiance = vec3(0.0);
}
/* Apply transmittance of surface on volumetric radiance because
* the volume is behind the surface. */
ClosureTransparency transparency_data = gbuffer_load_transparency_data(transparency_data_tx,
uvcoordsvar.xy);
volume_radiance *= transparency_data.transmittance;
out_combined = vec4(volume_radiance, 0.0);
out_volume = volume_radiance;
}
|