37 if (volume_grid ==
nullptr) {
42 if (grid ==
nullptr) {
53 false, volume->display.interpolation_method,
false, use_slice));
56 const float density_scale = volume->display.density *
59 sub_ps.bind_texture(
"depthBuffer", &resources.
depth_tx);
60 sub_ps.bind_texture(
"stencil_tx", &stencil_tx_);
61 sub_ps.bind_texture(
"densityTexture", grid->texture);
63 sub_ps.bind_texture(
"shadowTexture", dummy_shadow_tx_);
64 sub_ps.push_constant(
"activeColor", color);
65 sub_ps.push_constant(
"densityScale", density_scale);
66 sub_ps.push_constant(
"volumeObjectToTexture",
float4x4(grid->object_to_texture));
67 sub_ps.push_constant(
"volumeTextureToObject",
float4x4(grid->texture_to_object));
71 manager, sub_ps, ob_ref, volume->display.slice_axis, volume->display.slice_depth);
74 float4x4 texture_to_world = ob->object_to_world() *
float4x4(grid->texture_to_object);
81 draw_volume_ps(manager, sub_ps, ob_ref, scene_state.
sample, slice_count, world_size);
96 if (!settings.fluid) {
100 bool can_load =
false;
101 if (settings.use_coba) {
103 can_load = settings.tex_field !=
nullptr;
107 can_load = settings.tex_density !=
nullptr || settings.tex_color !=
nullptr;
121 ShaderCache::get().volume_get(
true, settings.interp_method, settings.use_coba, use_slice));
124 if (settings.use_coba) {
127 const bool show_phi =
ELEM(settings.coba_field,
133 sub_ps.push_constant(
"showFlags", show_flags);
134 sub_ps.push_constant(
"showPressure", show_pressure);
135 sub_ps.push_constant(
"showPhi", show_phi);
136 sub_ps.push_constant(
"gridScale", settings.grid_scale);
139 sub_ps.bind_texture(
"flagTexture", settings.tex_field);
142 sub_ps.bind_texture(
"densityTexture", settings.tex_field);
145 if (!show_flags && !show_pressure && !show_phi) {
146 sub_ps.bind_texture(
"transferTexture", settings.tex_coba);
153 sub_ps.push_constant(
"activeColor",
154 use_constant_color ?
float3(settings.active_color) :
float3(1));
156 sub_ps.bind_texture(
"densityTexture",
157 settings.tex_color ? settings.tex_color : settings.tex_density);
158 sub_ps.bind_texture(
"flameTexture",
159 settings.tex_flame ? settings.tex_flame : dummy_volume_tx_);
160 sub_ps.bind_texture(
"flameColorTexture",
161 settings.tex_flame ? settings.tex_flame_coba : dummy_coba_tx_);
162 sub_ps.bind_texture(
"shadowTexture", settings.tex_shadow);
165 sub_ps.push_constant(
"densityScale", 10.0f * settings.display_thickness);
166 sub_ps.bind_texture(
"depthBuffer", &resources.
depth_tx);
167 sub_ps.bind_texture(
"stencil_tx", &stencil_tx_);
170 draw_slice_ps(manager, sub_ps, ob_ref, settings.slice_axis, settings.slice_depth);
176 float3 slice_count =
float3(settings.res) * std::max(0.001f, settings.slice_per_voxel);
178 draw_volume_ps(manager, sub_ps, ob_ref, scene_state.
sample, slice_count, world_size);
192 manager.
submit(ps_, view);
195void VolumePass::draw_slice_ps(
208 float step_length = std::max(1e-16f, dimensions[axis] * 0.05f);
218void VolumePass::draw_volume_ps(Manager &manager,
228 int max_slice = std::max({
UNPACK3(slice_count)});
229 float step_length =
math::length((1.0f / slice_count) * world_size);
232 ps.push_constant(
"samplesLen", max_slice);
233 ps.push_constant(
"stepLength", step_length);
234 ps.push_constant(
"noiseOfs",
float(noise_offset));
void BKE_object_dimensions_get(Object *ob, float r_vec[3])
const blender::bke::VolumeGridData * BKE_volume_grid_active_get_for_read(const Volume *volume)
bool BKE_volume_load(const Volume *volume, const Main *bmain)
Volume data-block rendering and viewport drawing utilities.
float BKE_volume_density_scale(const Volume *volume, const float matrix[4][4])
MINLINE int axis_dominant_v3_single(const float vec[3])
void BLI_halton_1d(unsigned int prime, double offset, int n, double *r)
@ FLUID_DOMAIN_FIELD_PHI_OUT
@ FLUID_DOMAIN_FIELD_PHI_OBSTACLE
@ FLUID_DOMAIN_FIELD_FLAGS
@ FLUID_DOMAIN_FIELD_PRESSURE
@ FLUID_DOMAIN_FIELD_PHI_IN
@ FLUID_DOMAIN_ACTIVE_COLORS
@ FLUID_DOMAIN_ACTIVE_COLOR_SET
#define GPU_ATTACHMENT_TEXTURE(_texture)
#define GPU_ATTACHMENT_NONE
@ GPU_TEXTURE_USAGE_SHADER_READ
void GPU_texture_get_mipmap_size(GPUTexture *texture, int mip_level, int *r_size)
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)
ResourceHandle resource_handle(const ObjectRef &ref, float inflate_bounds=0.0f)
bool ensure_1d(eGPUTextureFormat format, int 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 draw(gpu::Batch *batch, uint instance_len=-1, uint vertex_len=-1, uint vertex_first=-1, ResourceHandle handle={0}, uint custom_id=0)
PassBase< DrawCommandBufType > & sub(const char *name)
void state_set(DRWState state, int clip_plane_count=0)
void bind_ubo(const char *name, GPUUniformBuf *buffer)
void push_constant(const char *name, const float &data)
void shader_set(GPUShader *shader)
detail::PassBase< command::DrawMultiBuf > Sub
GPUShader * volume_get(bool smoke, int interpolation, bool coba, bool slice)
static ShaderCache & get()
GPUTexture * extract(Manager &manager, Texture &stencil_src)
void sync(SceneResources &resources)
void object_sync_volume(Manager &manager, SceneResources &resources, const SceneState &scene_state, ObjectRef &ob_ref, float3 color)
void draw(Manager &manager, View &view, SceneResources &resources)
void object_sync_modifier(Manager &manager, SceneResources &resources, const SceneState &scene_state, ObjectRef &ob_ref, ModifierData *md)
blender::gpu::Batch * DRW_cache_quad_get()
blender::gpu::Batch * DRW_cache_cube_get()
void DRW_smoke_ensure_coba_field(FluidModifierData *fmd)
void DRW_smoke_ensure(FluidModifierData *fmd, int highres)
void DRW_view_viewmat_get(const DRWView *view, float mat[4][4], bool inverse)
@ DRW_STATE_BLEND_ALPHA_PREMUL
RAYTRACE_GROUP_SIZE additional_info("eevee_shared", "eevee_gbuffer_data", "eevee_global_ubo", "eevee_sampling_data", "eevee_utility_texture", "eevee_hiz_data", "draw_view") .specialization_constant(Type RAYTRACE_GROUP_SIZE in_sh_0_tx in_sh_2_tx screen_normal_tx GPU_RGBA8
DRWVolumeGrid * DRW_volume_batch_cache_get_grid(Volume *volume, const bke::VolumeGridData *volume_grid)
T length(const VecBase< T, Size > &a)
VecBase< T, 3 > to_scale(const MatBase< T, NumCol, NumRow > &mat)
MatBase< float, 4, 4 > float4x4
VecBase< float, 4 > float4
VecBase< int32_t, 3 > int3
VecBase< float, 3 > float3
const c_style_mat & ptr() const
StencilViewWorkaround stencil_view
UniformBuffer< WorldData > world_buf