36 for (; tile_size <= 16; tile_size *= 2) {
49 "Warning: Volume rendering data could not be allocated. Now using a resolution of 1:{} "
74 previous_objects_ = current_objects_;
75 current_objects_.clear();
80 if (!use_reprojection_) {
85 valid_history_ =
false;
93 if (!use_reprojection_) {
98 valid_history_ =
false;
121 integration_start = -integration_end;
127 integration_start =
math::max(integration_start, -volume_bounds.value().max);
128 integration_end =
math::min(integration_end, -volume_bounds.value().min);
132 float near = -
math::max(integration_start, camera_clip_start - 1e-4f);
133 float far = -
math::min(integration_end, camera_clip_end + 1e-4f);
139 valid_history_ =
false;
142 if (valid_history_) {
144 if (current_objects_ != previous_objects_) {
145 valid_history_ =
false;
151 sample_distribution = 4.0f *
math::max(1.0f - sample_distribution, 1e-2f);
153 data_.
depth_near = (far - near *
exp2(1.0f / sample_distribution)) / (far - near);
164 occupancy_tx_.
free();
165 prop_scattering_tx_.
free();
166 prop_extinction_tx_.
free();
167 prop_emission_tx_.
free();
168 prop_phase_tx_.
free();
169 prop_phase_weight_tx_.
free();
170 scatter_tx_.current().free();
171 scatter_tx_.previous().free();
172 extinction_tx_.current().free();
173 extinction_tx_.previous().free();
174 integrated_scatter_tx_.
free();
175 integrated_transmit_tx_.
free();
178 result.scattering_tx_ = dummy_scatter_tx_;
179 result.transmittance_tx_ = dummy_transmit_tx_;
192 valid_history_ =
false;
199 use_lights_ = has_scatter;
224 int hit_list_layer = 1;
227 hit_list_size = data_.
tex_size.xy();
240 bool created =
false;
247 valid_history_ =
false;
254 result.scattering_tx_ = integrated_scatter_tx_;
255 result.transmittance_tx_ = integrated_transmit_tx_;
256 properties.scattering_tx_ = prop_scattering_tx_;
257 properties.extinction_tx_ = prop_extinction_tx_;
260 properties.phase_weight_tx_ = prop_phase_weight_tx_;
281 scatter_ps_.
bind_image(
"in_scattering_img", &prop_scattering_tx_);
282 scatter_ps_.
bind_image(
"in_extinction_img", &prop_extinction_tx_);
283 scatter_ps_.
bind_texture(
"extinction_tx", &prop_extinction_tx_);
284 scatter_ps_.
bind_image(
"in_emission_img", &prop_emission_tx_);
285 scatter_ps_.
bind_image(
"in_phase_img", &prop_phase_tx_);
286 scatter_ps_.
bind_image(
"in_phase_weight_img", &prop_phase_weight_tx_);
287 scatter_ps_.
bind_texture(
"scattering_history_tx", &scatter_tx_.previous(), history_sampler);
288 scatter_ps_.
bind_texture(
"extinction_history_tx", &extinction_tx_.previous(), history_sampler);
289 scatter_ps_.
bind_image(
"out_scattering_img", &scatter_tx_.current());
290 scatter_ps_.
bind_image(
"out_extinction_img", &extinction_tx_.current());
296 integration_ps_.
init();
300 integration_ps_.
bind_texture(
"in_scattering_tx", &scatter_tx_.current());
301 integration_ps_.
bind_texture(
"in_extinction_tx", &extinction_tx_.current());
302 integration_ps_.
bind_image(
"out_scattering_img", &integrated_scatter_tx_);
303 integration_ps_.
bind_image(
"out_transmittance_img", &integrated_transmit_tx_);
329 int exponential_frame_count = 16;
332 exponential_frame_count = 0;
334 else if (!use_reprojection_) {
336 exponential_frame_count = 0;
343 exponential_frame_count = 3;
349 exponential_frame_count = 3;
354 exponential_frame_count = 8;
359 exponential_frame_count = 0;
362 if (!valid_history_) {
363 history_frame_count_ = 0;
369 history_frame_count_ =
math::min(history_frame_count_, exponential_frame_count);
373 float history_opacity = history_frame_count_ / (history_frame_count_ + 1.0f);
379 float left, right, bottom,
top, near, far;
388 right =
left + volume_size.x;
389 top = bottom + volume_size.y;
391 float4x4 winmat_infinite, winmat_finite;
394 winmat_infinite = main_view.
is_persp() ?
398 winmat_finite = main_view.
is_persp() ?
424 occupancy_fb_.
bind();
427 volume_view.
sync(main_view.
viewmat(), winmat_infinite);
432 if (!current_objects_.is_empty()) {
455 extinction_tx_.swap();
461 history_viewmat_ = main_view.
viewmat();
466 valid_history_ =
true;
467 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()
void GPU_debug_group_end()
void GPU_debug_group_begin(const char *name)
#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 dispatch(int group_len)
void barrier(eGPUBarrier type)
void state_set(DRWState state, int clip_plane_count=0)
void draw_procedural(GPUPrimType primitive, uint instance_len, uint vertex_len, uint vertex_first=-1, ResourceHandleRange handle={0}, uint custom_id=0)
void shader_set(GPUShader *shader)
bool is_orthographic() const
const CameraData & data_get() const
bool is_perspective() const
bool is_camera_object() const
const FilmData & get_data()
int2 render_extent_get() const
struct blender::eevee::HiZBuffer::@178 front
VolumeProbeModule volume_probes
SphereProbeModule sphere_probes
void info_append_i18n(const char *msg, Args &&...args)
RenderBuffers render_buffers
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)
void object_sync(const ObjectHandle &ob_handle)
struct blender::eevee::VolumeModule::@180 properties
void world_sync(const WorldHandle &world_handle)
struct blender::eevee::VolumeModule::@181 occupancy
struct blender::eevee::VolumeModule::@179 result
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
#define RBUFS_UTILITY_TEX_SLOT
#define VOLUME_GROUP_SIZE
#define VOLUME_INTEGRATION_GROUP_SIZE
@ 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