31 dummy_shadow_tx_.ensure_3d(
33 dummy_volume_tx_.ensure_3d(
35 dummy_coba_tx_.ensure_1d(
56 if (grid ==
nullptr) {
62 PassSortable::Sub &sub_ps = ps_.sub(
74 sub_ps.bind_texture(
"depth_buffer", &resources.
depth_tx);
75 sub_ps.bind_texture(
"stencil_tx", &stencil_tx_);
76 sub_ps.bind_texture(
"density_tx", grid->
texture);
78 sub_ps.bind_texture(
"shadow_tx", dummy_shadow_tx_);
79 sub_ps.push_constant(
"active_color",
color);
80 sub_ps.push_constant(
"density_fac", density_fac);
97 manager, resources, sub_ps, ob_ref, scene_state.
sample, slice_count, world_size);
112 if (!settings.
fluid) {
116 bool can_load =
false;
119 can_load = settings.
tex_field !=
nullptr;
132 PassSortable::Sub &sub_ps = ps_.sub(
133 "Volume Modifier SubPass",
141 sub_ps.bind_texture(
"flame_tx", settings.
tex_flame ? settings.
tex_flame : dummy_volume_tx_);
142 sub_ps.bind_texture(
"flame_color_tx",
154 sub_ps.push_constant(
"show_flags", show_flags);
155 sub_ps.push_constant(
"show_pressure", show_pressure);
156 sub_ps.push_constant(
"show_phi", show_phi);
157 sub_ps.push_constant(
"grid_scale", settings.
grid_scale);
160 sub_ps.bind_texture(
"flag_tx", settings.
tex_field);
161 sub_ps.bind_texture(
"density_tx", dummy_volume_tx_);
164 sub_ps.bind_texture(
"flag_tx", dummy_flag_tx_);
165 sub_ps.bind_texture(
"density_tx", settings.
tex_field);
168 if (!show_flags && !show_pressure && !show_phi) {
169 sub_ps.bind_texture(
"transfer_tx", settings.
tex_coba);
172 sub_ps.bind_texture(
"transfer_tx", dummy_coba_tx_);
179 sub_ps.push_constant(
"active_color",
182 sub_ps.bind_texture(
"density_tx",
184 sub_ps.bind_texture(
"shadow_tx", settings.
tex_shadow);
188 sub_ps.bind_texture(
"depth_buffer", &resources.
depth_tx);
189 sub_ps.bind_texture(
"stencil_tx", &stencil_tx_);
201 manager, resources, sub_ps, ob_ref, scene_state.
sample, slice_count, world_size);
215 manager.
submit(ps_, view);
218void VolumePass::draw_slice_ps(
Manager &manager,
220 PassSortable::Sub &ps,
234 float step_length = std::max(1e-16f, dimensions[axis] * 0.05f);
237 ps.push_constant(
"slice_position", slice_depth);
238 ps.push_constant(
"slice_axis", axis);
239 ps.push_constant(
"step_length", step_length);
244void VolumePass::draw_volume_ps(
Manager &manager,
245 SceneResources &resources,
246 PassSortable::Sub &ps,
255 int max_slice = std::max({
UNPACK3(slice_count)});
256 float step_length =
math::length((1.0f / slice_count) * world_size);
259 ps.push_constant(
"samples_len", max_slice);
260 ps.push_constant(
"step_length", step_length);
261 ps.push_constant(
"noise_ofs",
float(noise_offset));
263 ps.draw(resources.volume_cube_batch, manager.
unique_handle(ob_ref));
Volume data-block rendering and viewport drawing utilities.
#define GPU_ATTACHMENT_TEXTURE(_texture)
#define GPU_ATTACHMENT_NONE
ResourceHandleRange unique_handle(const ObjectRef &ref)
void submit(PassSimple &pass, View &view)
float4x4 object_to_world(int instance_index) const
gpu::Texture * stencil_view(bool cube_as_array=false)
static View & default_get()
const float4x4 & viewinv(int view_id=0) const
static ShaderCache & get()
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)
float dot(VecOp< float, D >, VecOp< float, D >) RET
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)
@ FLUID_DOMAIN_FIELD_FLAGS
@ FLUID_DOMAIN_FIELD_PHI_OBSTACLE
@ FLUID_DOMAIN_FIELD_PHI_IN
@ FLUID_DOMAIN_FIELD_PRESSURE
@ FLUID_DOMAIN_FIELD_PHI_OUT
@ VOLUME_AXIS_SLICE_SINGLE
void DRW_smoke_ensure_coba_field(FluidModifierData *fmd)
MatBase< float, 4, 4 > float4x4
@ FLUID_DOMAIN_ACTIVE_COLORS
@ FLUID_DOMAIN_ACTIVE_COLOR_SET
VecBase< float, 4 > float4
void BLI_halton_1d(unsigned int prime, double offset, int n, double *r)
VecBase< int32_t, 3 > int3
@ GPU_TEXTURE_USAGE_SHADER_READ
T & DRW_object_get_data_for_drawing(const Object &object)
MINLINE int axis_dominant_v3_single(const float vec[3])
void BKE_object_dimensions_get(const Object *ob, float r_vec[3])
bool BKE_volume_load(const Volume *volume, const Main *bmain)
@ DRW_STATE_BLEND_ALPHA_PREMUL
void DRW_smoke_ensure(FluidModifierData *fmd, int highres)
const bke::VolumeGridData * BKE_volume_grid_active_get_for_read(const Volume *volume)
float BKE_volume_density_scale(const Volume *volume, const float matrix[4][4])
VecBase< float, 3 > float3
void GPU_texture_get_mipmap_size(gpu::Texture *texture, int mip_level, int *r_size)
FLUID_DisplayInterpolationMethod interp_method
eFluidDomain_AxisSliceMethod axis_slice_method
eFluidDomain_CobaField coba_field
gpu::Texture * tex_density
eFluidDomain_ActiveFields active_fields
eFluidDomain_SliceAxis slice_axis
gpu::Texture * tex_shadow
gpu::Texture * tex_flame_coba
VolumeDisplayInterpMethod interpolation_method
AxisAlignedSlicingMethod axis_slice_method
float4x4 texture_to_object
float4x4 object_to_texture
UniformBuffer< WorldData > world_buf
gpu::Batch * volume_cube_batch