37 for (; tile_size <= 16; tile_size *= 2) {
50 "Warning: Volume rendering data could not be allocated. Now using a resolution of 1:{} "
75 previous_objects_ = current_objects_;
76 current_objects_.clear();
81 if (!use_reprojection_) {
86 valid_history_ =
false;
94 if (!use_reprojection_) {
99 valid_history_ =
false;
116 integration_start = -integration_end;
122 integration_start =
math::max(integration_start, -volume_bounds.value().max);
123 integration_end =
math::min(integration_end, -volume_bounds.value().min);
127 float near = -
math::max(integration_start, camera_clip_start - 1e-4f);
128 float far = -
math::min(integration_end, camera_clip_end + 1e-4f);
134 valid_history_ =
false;
137 if (valid_history_) {
139 if (current_objects_ != previous_objects_) {
140 valid_history_ =
false;
146 sample_distribution = 4.0f *
math::max(1.0f - sample_distribution, 1e-2f);
148 data_.
depth_near = (far - near * exp2(1.0f / sample_distribution)) / (far - near);
159 occupancy_tx_.
free();
160 prop_scattering_tx_.
free();
161 prop_extinction_tx_.
free();
162 prop_emission_tx_.
free();
163 prop_phase_tx_.
free();
164 prop_phase_weight_tx_.
free();
165 scatter_tx_.current().free();
166 scatter_tx_.previous().free();
167 extinction_tx_.current().free();
168 extinction_tx_.previous().free();
169 integrated_scatter_tx_.
free();
170 integrated_transmit_tx_.
free();
173 result.scattering_tx_ = dummy_scatter_tx_;
174 result.transmittance_tx_ = dummy_transmit_tx_;
187 valid_history_ =
false;
194 use_lights_ = has_scatter;
219 int hit_list_layer = 1;
222 hit_list_size = data_.
tex_size.xy();
235 bool created =
false;
242 valid_history_ =
false;
249 result.scattering_tx_ = integrated_scatter_tx_;
250 result.transmittance_tx_ = integrated_transmit_tx_;
251 properties.scattering_tx_ = prop_scattering_tx_;
252 properties.extinction_tx_ = prop_extinction_tx_;
255 properties.phase_weight_tx_ = prop_phase_weight_tx_;
276 scatter_ps_.
bind_image(
"in_scattering_img", &prop_scattering_tx_);
277 scatter_ps_.
bind_image(
"in_extinction_img", &prop_extinction_tx_);
278 scatter_ps_.
bind_texture(
"extinction_tx", &prop_extinction_tx_);
279 scatter_ps_.
bind_image(
"in_emission_img", &prop_emission_tx_);
280 scatter_ps_.
bind_image(
"in_phase_img", &prop_phase_tx_);
281 scatter_ps_.
bind_image(
"in_phase_weight_img", &prop_phase_weight_tx_);
282 scatter_ps_.
bind_texture(
"scattering_history_tx", &scatter_tx_.previous(), history_sampler);
283 scatter_ps_.
bind_texture(
"extinction_history_tx", &extinction_tx_.previous(), history_sampler);
284 scatter_ps_.
bind_image(
"out_scattering_img", &scatter_tx_.current());
285 scatter_ps_.
bind_image(
"out_extinction_img", &extinction_tx_.current());
291 integration_ps_.
init();
295 integration_ps_.
bind_texture(
"in_scattering_tx", &scatter_tx_.current());
296 integration_ps_.
bind_texture(
"in_extinction_tx", &extinction_tx_.current());
297 integration_ps_.
bind_image(
"out_scattering_img", &integrated_scatter_tx_);
298 integration_ps_.
bind_image(
"out_transmittance_img", &integrated_transmit_tx_);
324 int exponential_frame_count = 16;
327 exponential_frame_count = 0;
329 else if (!use_reprojection_) {
331 exponential_frame_count = 0;
338 exponential_frame_count = 3;
344 exponential_frame_count = 3;
349 exponential_frame_count = 8;
354 exponential_frame_count = 0;
357 if (!valid_history_) {
358 history_frame_count_ = 0;
364 history_frame_count_ =
math::min(history_frame_count_, exponential_frame_count);
368 float history_opacity = history_frame_count_ / (history_frame_count_ + 1.0f);
374 float left, right, bottom,
top, near, far;
379 float2 render_size =
float2(right - left, top - bottom);
383 right = left + volume_size.x;
384 top = bottom + volume_size.y;
386 float4x4 winmat_infinite, winmat_finite;
389 winmat_infinite = main_view.
is_persp() ?
393 winmat_finite = main_view.
is_persp() ?
419 occupancy_fb_.
bind();
422 volume_view.
sync(main_view.
viewmat(), winmat_infinite);
427 if (!current_objects_.is_empty()) {
450 extinction_tx_.swap();
456 history_viewmat_ = main_view.
viewmat();
461 valid_history_ =
true;
462 history_frame_count_ += 1;
MINLINE uint divide_ceil_u(uint a, uint b)
MINLINE int clamp_i(int value, int min, int max)
void projmat_dimensions(const float winmat[4][4], float *r_left, float *r_right, float *r_bottom, float *r_top, float *r_near, float *r_far)
@ SCE_EEVEE_VOLUME_CUSTOM_RANGE
@ SCE_EEVEE_VOLUMETRIC_SHADOWS
@ SCE_EEVEE_TAA_REPROJECTION
int GPU_max_texture_3d_size()
#define GPU_ATTACHMENT_TEXTURE(_texture)
#define GPU_ATTACHMENT_NONE
@ GPU_BARRIER_TEXTURE_FETCH
@ GPU_BARRIER_SHADER_IMAGE_ACCESS
@ GPU_TEXTURE_USAGE_SHADER_READ
@ GPU_TEXTURE_USAGE_SHADER_WRITE
@ GPU_TEXTURE_USAGE_ATTACHMENT
@ GPU_TEXTURE_USAGE_ATOMIC
@ GPU_SAMPLER_EXTEND_MODE_EXTEND
@ GPU_SAMPLER_FILTERING_LINEAR
void ensure(GPUAttachment depth=GPU_ATTACHMENT_NONE, GPUAttachment color1=GPU_ATTACHMENT_NONE, GPUAttachment color2=GPU_ATTACHMENT_NONE, GPUAttachment color3=GPU_ATTACHMENT_NONE, GPUAttachment color4=GPU_ATTACHMENT_NONE, GPUAttachment color5=GPU_ATTACHMENT_NONE, GPUAttachment color6=GPU_ATTACHMENT_NONE, GPUAttachment color7=GPU_ATTACHMENT_NONE, GPUAttachment color8=GPU_ATTACHMENT_NONE)
void submit(PassSimple &pass, View &view)
void clear(float4 values)
bool ensure_2d(eGPUTextureFormat format, int2 extent, eGPUTextureUsage usage=GPU_TEXTURE_USAGE_GENERAL, const float *data=nullptr, int mip_len=1)
bool ensure_3d(eGPUTextureFormat format, int3 extent, eGPUTextureUsage usage=GPU_TEXTURE_USAGE_GENERAL, const float *data=nullptr, int mip_len=1)
void visibility_test(bool enable)
bool is_persp(int view_id=0) const
const float4x4 & winmat(int view_id=0) const
const float4x4 & viewmat(int view_id=0) const
const float4x4 & viewinv(int view_id=0) const
void sync(const float4x4 &view_mat, const float4x4 &win_mat, int view_id=0)
void bind_texture(const char *name, GPUTexture *texture, GPUSamplerState state=sampler_auto)
void bind_resources(U &resources)
void bind_image(const char *name, GPUTexture *image)
void draw_procedural(GPUPrimType primitive, uint instance_len, uint vertex_len, uint vertex_first=-1, ResourceHandle handle={0}, uint custom_id=0)
void dispatch(int group_len)
void barrier(eGPUBarrier type)
void state_set(DRWState state, int clip_plane_count=0)
void shader_set(GPUShader *shader)
bool is_orthographic() const
const CameraData & data_get() const
bool is_perspective() const
bool is_camera_object() const
int2 render_extent_get() const
struct blender::eevee::HiZBuffer::@195 front
VolumeProbeModule volume_probes
SphereProbeModule sphere_probes
void info_append_i18n(const char *msg, Args &&...args)
bool is_transforming() const
RenderBuffers render_buffers
bool is_image_render() const
bool is_navigating() const
UniformDataModule uniform_data
WorldVolumePipeline world_volume
UtilityTexture utility_tx
DeferredPipeline deferred
TextureFromPool combined_tx
float2 rng_2d_get(eSamplingDimension starting_dimension) const
GPUShader * static_shader_get(eShaderType shader_type)
void set_view(View &view, int2 extent)
void set_view(View &view)
struct blender::eevee::VolumeModule::@197 properties
void object_sync(const ObjectHandle &ob_handle)
struct blender::eevee::VolumeModule::@198 occupancy
void world_sync(const WorldHandle &world_handle)
void draw_resolve(View &view)
void draw_compute(View &main_view, int2 extent)
void draw_prepass(View &main_view)
std::optional< Bounds< float > > object_integration_range() const
bool has_absorption() const
void render(View &view, Texture &occupancy_tx)
bool use_hit_list() const
void set_view(View &view)
bool has_volume_absorption() const
bool has_volume_scatter() const
void DRW_stats_group_start(const char *name)
void DRW_stats_group_end()
#define RBUFS_UTILITY_TEX_SLOT
#define VOLUME_GROUP_SIZE
#define VOLUME_INTEGRATION_GROUP_SIZE
DOF_TILES_FLATTEN_GROUP_SIZE coc_tx GPU_R11F_G11F_B10F
draw_view push_constant(Type::INT, "radiance_src") .push_constant(Type capture_info_buf storage_buf(1, Qualifier::READ, "ObjectBounds", "bounds_buf[]") .push_constant(Type draw_view int
SHADOW_TILEMAP_RES tiles_buf[] statistics_buf render_view_buf[SHADOW_VIEW_MAX] GPU_R32UI
@ VOLUME_SCATTER_WITH_LIGHTS
MatBase< T, 4, 4 > orthographic(T left, T right, T bottom, T top, T near_clip, T far_clip)
Create an orthographic projection matrix using OpenGL coordinate convention: Maps each axis range to ...
MatBase< T, 4, 4 > orthographic_infinite(T left, T right, T bottom, T top)
Create an orthographic projection matrix using OpenGL coordinate convention: Maps each axis range to ...
MatBase< T, 4, 4 > translate(const MatBase< T, 4, 4 > &mat, const VecBase< T, 2 > &offset)
Translate a projection matrix after creation in the screen plane. Usually used for anti-aliasing jitt...
MatBase< T, 4, 4 > perspective_infinite(T left, T right, T bottom, T top, T near_clip)
Create a perspective projection matrix using OpenGL coordinate convention: Maps each axis range to [-...
MatBase< T, 4, 4 > perspective(T left, T right, T bottom, T top, T near_clip, T far_clip)
Create a perspective projection matrix using OpenGL coordinate convention: Maps each axis range to [-...
T reduce_max(const VecBase< T, Size > &a)
VecBase< T, Size > divide_ceil(const VecBase< T, Size > &a, const VecBase< T, Size > &b)
T min(const T &a, const T &b)
CartesianBasis invert(const CartesianBasis &basis)
T max(const T &a, const T &b)
VecBase< uint32_t, 4 > uint4
bool assign_if_different(T &old_value, T new_value)
VecBase< int32_t, 2 > int2
VecBase< float, 2 > float2
VecBase< int32_t, 3 > int3
VecBase< float, 3 > float3
float volumetric_light_clamp
float volumetric_sample_distribution
int volumetric_shadow_samples
const c_style_mat & ptr() const
float2 main_view_extent_inv
float4x4 history_winmat_stable
float history_depth_distribution
packed_float3 inv_tex_size
float4x4 curr_view_to_past_view