Overlay-Next: Fluid
Straight-forward port. Rel #102179 Pull Request: https://projects.blender.org/blender/blender/pulls/126878
This commit is contained in:
committed by
Clément Foucault
parent
e22b931cfb
commit
cfb261928c
@@ -296,6 +296,7 @@ set(SRC
|
||||
engines/overlay/overlay_next_curve.hh
|
||||
engines/overlay/overlay_next_empty.hh
|
||||
engines/overlay/overlay_next_facing.hh
|
||||
engines/overlay/overlay_next_fluid.hh
|
||||
engines/overlay/overlay_next_force_field.hh
|
||||
engines/overlay/overlay_next_grease_pencil.hh
|
||||
engines/overlay/overlay_next_grid.hh
|
||||
|
||||
258
source/blender/draw/engines/overlay/overlay_next_fluid.hh
Normal file
258
source/blender/draw/engines/overlay/overlay_next_fluid.hh
Normal file
@@ -0,0 +1,258 @@
|
||||
/* SPDX-FileCopyrightText: 2024 Blender Authors
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
/** \file
|
||||
* \ingroup overlay
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "DNA_fluid_types.h"
|
||||
#include "DNA_modifier_types.h"
|
||||
|
||||
#include "BKE_modifier.hh"
|
||||
|
||||
#include "overlay_next_private.hh"
|
||||
|
||||
namespace blender::draw::overlay {
|
||||
|
||||
class Fluids {
|
||||
private:
|
||||
const SelectionType selection_type_;
|
||||
|
||||
PassSimple fluid_ps_ = {"fluid_ps_"};
|
||||
PassSimple::Sub *velocity_needle_ps_ = nullptr;
|
||||
PassSimple::Sub *velocity_mac_ps_ = nullptr;
|
||||
PassSimple::Sub *velocity_streamline_ps_ = nullptr;
|
||||
PassSimple::Sub *grid_lines_flags_ps_ = nullptr;
|
||||
PassSimple::Sub *grid_lines_flat_ps_ = nullptr;
|
||||
PassSimple::Sub *grid_lines_range_ps_ = nullptr;
|
||||
|
||||
ShapeInstanceBuf<ExtraInstanceData> cube_buf_ = {selection_type_, "cube_buf_"};
|
||||
|
||||
int dominant_axis = -1;
|
||||
|
||||
public:
|
||||
Fluids(const SelectionType selection_type) : selection_type_(selection_type){};
|
||||
|
||||
void begin_sync(Resources &res, const State &state)
|
||||
{
|
||||
/* Against design. Should not sync depending on view. */
|
||||
float3 camera_direction = View("WorkaroundView", DRW_view_default_get()).viewinv().z_axis();
|
||||
dominant_axis = math::dominant_axis(camera_direction);
|
||||
|
||||
{
|
||||
auto &pass = fluid_ps_;
|
||||
pass.init();
|
||||
pass.state_set(DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL |
|
||||
state.clipping_state);
|
||||
res.select_bind(pass);
|
||||
|
||||
/* TODO(fclem): Use either specialization constants or push constants to reduce the amount of
|
||||
* shader variants. */
|
||||
velocity_needle_ps_ = &fluid_ps_.sub("Velocity Needles");
|
||||
velocity_needle_ps_->shader_set(res.shaders.fluid_velocity_needle.get());
|
||||
|
||||
velocity_mac_ps_ = &fluid_ps_.sub("Velocity Mac");
|
||||
velocity_mac_ps_->shader_set(res.shaders.fluid_velocity_mac.get());
|
||||
|
||||
velocity_streamline_ps_ = &fluid_ps_.sub("Velocity Line");
|
||||
velocity_streamline_ps_->shader_set(res.shaders.fluid_velocity_streamline.get());
|
||||
|
||||
grid_lines_flags_ps_ = &fluid_ps_.sub("Velocity Mac");
|
||||
grid_lines_flags_ps_->shader_set(res.shaders.fluid_grid_lines_flags.get());
|
||||
|
||||
grid_lines_flat_ps_ = &fluid_ps_.sub("Velocity Needles");
|
||||
grid_lines_flat_ps_->shader_set(res.shaders.fluid_grid_lines_flat.get());
|
||||
|
||||
grid_lines_range_ps_ = &fluid_ps_.sub("Velocity Line");
|
||||
grid_lines_range_ps_->shader_set(res.shaders.fluid_grid_lines_range.get());
|
||||
}
|
||||
|
||||
cube_buf_.clear();
|
||||
}
|
||||
|
||||
void object_sync(Manager &manager, const ObjectRef &ob_ref, Resources &res, const State &state)
|
||||
{
|
||||
Object *ob = ob_ref.object;
|
||||
|
||||
/* Do not show for dupli objects as the fluid is baked for the original object. */
|
||||
if (ob->base_flag & (BASE_FROM_SET | BASE_FROM_DUPLI)) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* NOTE: There can only be one fluid modifier per object. */
|
||||
ModifierData *md = BKE_modifiers_findby_type(ob, eModifierType_Fluid);
|
||||
|
||||
if (md == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
FluidModifierData *fmd = (FluidModifierData *)md;
|
||||
FluidDomainSettings *fds = fmd->domain;
|
||||
|
||||
if (fds == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
const bool is_active_frame_after_cache_start = state.scene->r.cfra >= fds->cache_frame_start;
|
||||
const bool is_active_frame_before_cache_end = state.scene->r.cfra >= fds->cache_frame_start;
|
||||
const bool is_active_frame_in_cache_range = is_active_frame_after_cache_start &&
|
||||
is_active_frame_before_cache_end;
|
||||
if (!is_active_frame_in_cache_range) {
|
||||
return;
|
||||
}
|
||||
|
||||
ResourceHandle res_handle = manager.resource_handle(ob_ref);
|
||||
select::ID sel_id = res.select_id(ob_ref);
|
||||
|
||||
/* Small cube showing voxel size. */
|
||||
{
|
||||
float3 min = float3(fds->p0) + float3(fds->cell_size) * float3(int3(fds->res_min));
|
||||
float4x4 voxel_cube_mat = math::from_loc_scale<float4x4>(min, float3(fds->cell_size) / 2.0f);
|
||||
/* Move small cube into the domain, otherwise its centered on corner of domain object. */
|
||||
voxel_cube_mat = math::translate(voxel_cube_mat, float3(1.0f));
|
||||
voxel_cube_mat = ob->object_to_world() * voxel_cube_mat;
|
||||
|
||||
const float4 &color = res.object_wire_color(ob_ref, state);
|
||||
cube_buf_.append({voxel_cube_mat, color, 1.0f}, sel_id);
|
||||
}
|
||||
|
||||
/* No volume data to display. */
|
||||
if (fds->fluid == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
int slice_axis = slide_axis_get(*fds);
|
||||
|
||||
const bool draw_velocity = (fds->draw_velocity && is_active_frame_after_cache_start);
|
||||
if (draw_velocity) {
|
||||
int lines_per_voxel = -1;
|
||||
PassSimple::Sub *sub_pass = nullptr;
|
||||
switch (fds->vector_draw_type) {
|
||||
default:
|
||||
case VECTOR_DRAW_STREAMLINE:
|
||||
sub_pass = velocity_streamline_ps_;
|
||||
lines_per_voxel = 1;
|
||||
break;
|
||||
case VECTOR_DRAW_NEEDLE:
|
||||
sub_pass = velocity_needle_ps_;
|
||||
lines_per_voxel = 6;
|
||||
break;
|
||||
case VECTOR_DRAW_MAC:
|
||||
sub_pass = velocity_mac_ps_;
|
||||
lines_per_voxel = 3;
|
||||
break;
|
||||
}
|
||||
|
||||
int total_lines = lines_per_voxel * math::reduce_mul(int3(fds->res));
|
||||
if (slice_axis != -1) {
|
||||
/* Remove the sliced dimension. */
|
||||
total_lines /= fds->res[slice_axis];
|
||||
}
|
||||
|
||||
DRW_smoke_ensure_velocity(fmd);
|
||||
|
||||
PassSimple::Sub &sub = *sub_pass;
|
||||
sub.bind_texture("velocityX", fds->tex_velocity_x);
|
||||
sub.bind_texture("velocityY", fds->tex_velocity_y);
|
||||
sub.bind_texture("velocityZ", fds->tex_velocity_z);
|
||||
sub.push_constant("displaySize", fds->vector_scale);
|
||||
sub.push_constant("slicePosition", fds->slice_depth);
|
||||
sub.push_constant("cellSize", float3(fds->cell_size));
|
||||
sub.push_constant("domainOriginOffset", float3(fds->p0));
|
||||
sub.push_constant("adaptiveCellOffset", int3(fds->res_min));
|
||||
sub.push_constant("sliceAxis", slice_axis);
|
||||
sub.push_constant("scaleWithMagnitude", bool(fds->vector_scale_with_magnitude));
|
||||
sub.push_constant("isCellCentered", (fds->vector_field == FLUID_DOMAIN_VECTOR_FIELD_FORCE));
|
||||
if (fds->vector_draw_type == VECTOR_DRAW_MAC) {
|
||||
sub.push_constant("drawMACX", (fds->vector_draw_mac_components & VECTOR_DRAW_MAC_X));
|
||||
sub.push_constant("drawMACY", (fds->vector_draw_mac_components & VECTOR_DRAW_MAC_Y));
|
||||
sub.push_constant("drawMACZ", (fds->vector_draw_mac_components & VECTOR_DRAW_MAC_Z));
|
||||
}
|
||||
sub.push_constant("in_select_id", int(sel_id.get()));
|
||||
sub.draw_procedural(GPU_PRIM_LINES, 1, total_lines * 2, -1, res_handle);
|
||||
}
|
||||
|
||||
/* Show gridlines only for slices with no interpolation. */
|
||||
const bool show_gridlines = fds->show_gridlines &&
|
||||
(fds->axis_slice_method == AXIS_SLICE_SINGLE) &&
|
||||
(fds->interp_method == FLUID_DISPLAY_INTERP_CLOSEST ||
|
||||
fds->coba_field == FLUID_DOMAIN_FIELD_FLAGS);
|
||||
if (show_gridlines) {
|
||||
PassSimple::Sub *sub_pass = nullptr;
|
||||
switch (fds->gridlines_color_field) {
|
||||
default:
|
||||
case FLUID_GRIDLINE_COLOR_TYPE_FLAGS:
|
||||
DRW_fluid_ensure_flags(fmd);
|
||||
|
||||
sub_pass = grid_lines_flags_ps_;
|
||||
sub_pass->bind_texture("flagTexture", fds->tex_flags);
|
||||
break;
|
||||
case FLUID_GRIDLINE_COLOR_TYPE_RANGE:
|
||||
if (fds->use_coba && (fds->coba_field != FLUID_DOMAIN_FIELD_FLAGS)) {
|
||||
DRW_fluid_ensure_flags(fmd);
|
||||
DRW_fluid_ensure_range_field(fmd);
|
||||
|
||||
sub_pass = grid_lines_range_ps_;
|
||||
sub_pass->bind_texture("flagTexture", fds->tex_flags);
|
||||
sub_pass->bind_texture("fieldTexture", fds->tex_range_field);
|
||||
sub_pass->push_constant("lowerBound", fds->gridlines_lower_bound);
|
||||
sub_pass->push_constant("upperBound", fds->gridlines_upper_bound);
|
||||
sub_pass->push_constant("rangeColor", float4(fds->gridlines_range_color));
|
||||
sub_pass->push_constant("cellFilter", int(fds->gridlines_cell_filter));
|
||||
break;
|
||||
}
|
||||
/* Otherwise, fallback to none color type. */
|
||||
ATTR_FALLTHROUGH;
|
||||
case FLUID_GRIDLINE_COLOR_TYPE_NONE:
|
||||
sub_pass = grid_lines_flat_ps_;
|
||||
break;
|
||||
}
|
||||
|
||||
PassSimple::Sub &sub = *sub_pass;
|
||||
sub.push_constant("volumeSize", int3(fds->res));
|
||||
sub.push_constant("slicePosition", fds->slice_depth);
|
||||
sub.push_constant("cellSize", float3(fds->cell_size));
|
||||
sub.push_constant("domainOriginOffset", float3(fds->p0));
|
||||
sub.push_constant("adaptiveCellOffset", int3(fds->res_min));
|
||||
sub.push_constant("sliceAxis", slice_axis);
|
||||
sub.push_constant("in_select_id", int(sel_id.get()));
|
||||
|
||||
BLI_assert(slice_axis != -1);
|
||||
int lines_per_voxel = 4;
|
||||
int total_lines = lines_per_voxel * math::reduce_mul(int3(fds->res)) / fds->res[slice_axis];
|
||||
sub.draw_procedural(GPU_PRIM_LINES, 1, total_lines * 2, -1, res_handle);
|
||||
}
|
||||
}
|
||||
|
||||
void end_sync(Resources &res, ShapeCache &shapes, const State & /*state*/)
|
||||
{
|
||||
fluid_ps_.shader_set(res.shaders.extra_shape.get());
|
||||
fluid_ps_.bind_ubo("globalsBlock", &res.globals_buf);
|
||||
|
||||
cube_buf_.end_sync(fluid_ps_, shapes.cube.get());
|
||||
}
|
||||
|
||||
void draw(Framebuffer &framebuffer, Manager &manager, View &view)
|
||||
{
|
||||
GPU_framebuffer_bind(framebuffer);
|
||||
manager.submit(fluid_ps_, view);
|
||||
}
|
||||
|
||||
private:
|
||||
/* Return axis index or -1 if no slice. */
|
||||
int slide_axis_get(FluidDomainSettings &fluid_domain_settings) const
|
||||
{
|
||||
if (fluid_domain_settings.axis_slice_method != AXIS_SLICE_SINGLE) {
|
||||
return -1;
|
||||
}
|
||||
if (fluid_domain_settings.slice_axis == SLICE_AXIS_AUTO) {
|
||||
return dominant_axis;
|
||||
}
|
||||
return fluid_domain_settings.slice_axis - 1;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace blender::draw::overlay
|
||||
@@ -96,6 +96,7 @@ void Instance::begin_sync()
|
||||
layer.empties.begin_sync();
|
||||
layer.facing.begin_sync(resources, state);
|
||||
layer.force_fields.begin_sync();
|
||||
layer.fluids.begin_sync(resources, state);
|
||||
layer.lattices.begin_sync(resources, state);
|
||||
layer.lights.begin_sync();
|
||||
layer.light_probes.begin_sync(resources, state);
|
||||
@@ -129,15 +130,7 @@ void Instance::object_sync(ObjectRef &ob_ref, Manager &manager)
|
||||
regular;
|
||||
|
||||
if (needs_prepass) {
|
||||
switch (ob_ref.object->type) {
|
||||
case OB_MESH:
|
||||
case OB_SURF:
|
||||
case OB_CURVES:
|
||||
case OB_FONT:
|
||||
case OB_CURVES_LEGACY:
|
||||
layer.prepass.object_sync(manager, ob_ref, resources);
|
||||
break;
|
||||
}
|
||||
layer.prepass.object_sync(manager, ob_ref, resources);
|
||||
}
|
||||
|
||||
if (in_edit_mode && !state.hide_overlays) {
|
||||
@@ -202,11 +195,12 @@ void Instance::object_sync(ObjectRef &ob_ref, Manager &manager)
|
||||
layer.speakers.object_sync(ob_ref, resources, state);
|
||||
break;
|
||||
}
|
||||
layer.bounds.object_sync(ob_ref, resources, state);
|
||||
layer.facing.object_sync(manager, ob_ref, state);
|
||||
layer.force_fields.object_sync(ob_ref, resources, state);
|
||||
layer.bounds.object_sync(ob_ref, resources, state);
|
||||
layer.relations.object_sync(ob_ref, resources, state);
|
||||
layer.fluids.object_sync(manager, ob_ref, resources, state);
|
||||
layer.particles.object_sync(manager, ob_ref, resources, state);
|
||||
layer.relations.object_sync(ob_ref, resources, state);
|
||||
|
||||
if (object_is_selected(ob_ref) && !in_edit_paint_mode) {
|
||||
outline.object_sync(manager, ob_ref, state);
|
||||
@@ -227,6 +221,7 @@ void Instance::end_sync()
|
||||
layer.light_probes.end_sync(resources, shapes, state);
|
||||
layer.metaballs.end_sync(resources, shapes, state);
|
||||
layer.relations.end_sync(resources, state);
|
||||
layer.fluids.end_sync(resources, shapes, state);
|
||||
layer.speakers.end_sync(resources, shapes, state);
|
||||
};
|
||||
end_sync_layer(regular);
|
||||
@@ -351,6 +346,7 @@ void Instance::draw(Manager &manager)
|
||||
layer.lattices.draw(framebuffer, manager, view);
|
||||
layer.metaballs.draw(framebuffer, manager, view);
|
||||
layer.relations.draw(framebuffer, manager, view);
|
||||
layer.fluids.draw(framebuffer, manager, view);
|
||||
layer.particles.draw(framebuffer, manager, view);
|
||||
layer.meshes.draw(framebuffer, manager, view);
|
||||
};
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "overlay_next_curve.hh"
|
||||
#include "overlay_next_empty.hh"
|
||||
#include "overlay_next_facing.hh"
|
||||
#include "overlay_next_fluid.hh"
|
||||
#include "overlay_next_force_field.hh"
|
||||
#include "overlay_next_grease_pencil.hh"
|
||||
#include "overlay_next_grid.hh"
|
||||
@@ -64,6 +65,7 @@ class Instance {
|
||||
Curves curves;
|
||||
Empties empties = {selection_type_};
|
||||
Facing facing = {selection_type_};
|
||||
Fluids fluids = {selection_type_};
|
||||
ForceFields force_fields = {selection_type_};
|
||||
GreasePencil grease_pencil;
|
||||
Lattices lattices;
|
||||
|
||||
@@ -51,9 +51,30 @@ class Prepass {
|
||||
if (!enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (ob_ref.object->dt < OB_SOLID) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* TODO(fclem) This function should contain what `basic_cache_populate` contained. */
|
||||
|
||||
gpu::Batch *geom = DRW_cache_object_surface_get(ob_ref.object);
|
||||
gpu::Batch *geom = nullptr;
|
||||
switch (ob_ref.object->type) {
|
||||
case OB_MESH:
|
||||
geom = DRW_cache_mesh_surface_get(ob_ref.object);
|
||||
break;
|
||||
case OB_VOLUME:
|
||||
if (selection_type_ == SelectionType::DISABLED) {
|
||||
/* Disable during display, only enable for selection. */
|
||||
/* TODO(fclem): Would be nice to have even when not selecting to occlude overlays. */
|
||||
return;
|
||||
}
|
||||
geom = DRW_cache_volume_selection_surface_get(ob_ref.object);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (geom) {
|
||||
ResourceHandle res_handle = manager.resource_handle(ob_ref);
|
||||
ps_.draw(geom, res_handle, res.select_id(ob_ref).get());
|
||||
|
||||
@@ -206,6 +206,12 @@ class ShaderModule {
|
||||
ShaderPtr extra_loose_points;
|
||||
ShaderPtr extra_ground_line;
|
||||
ShaderPtr facing;
|
||||
ShaderPtr fluid_grid_lines_flags;
|
||||
ShaderPtr fluid_grid_lines_flat;
|
||||
ShaderPtr fluid_grid_lines_range;
|
||||
ShaderPtr fluid_velocity_streamline;
|
||||
ShaderPtr fluid_velocity_mac;
|
||||
ShaderPtr fluid_velocity_needle;
|
||||
ShaderPtr lattice_points;
|
||||
ShaderPtr lattice_wire;
|
||||
ShaderPtr particle_dot;
|
||||
|
||||
@@ -226,6 +226,42 @@ ShaderModule::ShaderModule(const SelectionType selection_type, const bool clippi
|
||||
"draw_view", "draw_modelmat_new", "draw_resource_handle_new", "draw_globals");
|
||||
});
|
||||
|
||||
fluid_grid_lines_flags = selectable_shader(
|
||||
"overlay_volume_gridlines_flags", [](gpu::shader::ShaderCreateInfo &info) {
|
||||
info.additional_infos_.clear();
|
||||
info.additional_info("draw_volume_new", "draw_view", "overlay_volume_gridlines");
|
||||
});
|
||||
|
||||
fluid_grid_lines_flat = selectable_shader(
|
||||
"overlay_volume_gridlines_flat", [](gpu::shader::ShaderCreateInfo &info) {
|
||||
info.additional_infos_.clear();
|
||||
info.additional_info("draw_volume_new", "draw_view", "overlay_volume_gridlines");
|
||||
});
|
||||
|
||||
fluid_grid_lines_range = selectable_shader(
|
||||
"overlay_volume_gridlines_range", [](gpu::shader::ShaderCreateInfo &info) {
|
||||
info.additional_infos_.clear();
|
||||
info.additional_info("draw_volume_new", "draw_view", "overlay_volume_gridlines");
|
||||
});
|
||||
|
||||
fluid_velocity_streamline = selectable_shader(
|
||||
"overlay_volume_velocity_streamline", [](gpu::shader::ShaderCreateInfo &info) {
|
||||
info.additional_infos_.clear();
|
||||
info.additional_info("draw_volume_new", "draw_view", "overlay_volume_velocity");
|
||||
});
|
||||
|
||||
fluid_velocity_mac = selectable_shader(
|
||||
"overlay_volume_velocity_mac", [](gpu::shader::ShaderCreateInfo &info) {
|
||||
info.additional_infos_.clear();
|
||||
info.additional_info("draw_volume_new", "draw_view", "overlay_volume_velocity");
|
||||
});
|
||||
|
||||
fluid_velocity_needle = selectable_shader(
|
||||
"overlay_volume_velocity_needle", [](gpu::shader::ShaderCreateInfo &info) {
|
||||
info.additional_infos_.clear();
|
||||
info.additional_info("draw_volume_new", "draw_view", "overlay_volume_velocity");
|
||||
});
|
||||
|
||||
extra_shape = selectable_shader("overlay_extra", [](gpu::shader::ShaderCreateInfo &info) {
|
||||
info.storage_buf(0, Qualifier::READ, "ExtraInstanceData", "data_buf[]");
|
||||
info.define("color", "data_buf[gl_InstanceID].color_");
|
||||
|
||||
@@ -983,7 +983,8 @@ GPUShader *OVERLAY_shader_volume_velocity(bool use_needle, bool use_mac)
|
||||
"overlay_volume_velocity_mac");
|
||||
}
|
||||
else if (!sh_data->volume_velocity_sh) {
|
||||
sh_data->volume_velocity_sh = GPU_shader_create_from_info_name("overlay_volume_velocity");
|
||||
sh_data->volume_velocity_sh = GPU_shader_create_from_info_name(
|
||||
"overlay_volume_velocity_streamline");
|
||||
}
|
||||
|
||||
if (use_needle) {
|
||||
@@ -1007,7 +1008,8 @@ GPUShader *OVERLAY_shader_volume_gridlines(bool color_with_flags, bool color_ran
|
||||
"overlay_volume_gridlines_range");
|
||||
}
|
||||
else if (!sh_data->volume_gridlines_sh) {
|
||||
sh_data->volume_gridlines_sh = GPU_shader_create_from_info_name("overlay_volume_gridlines");
|
||||
sh_data->volume_gridlines_sh = GPU_shader_create_from_info_name(
|
||||
"overlay_volume_gridlines_flat");
|
||||
}
|
||||
|
||||
if (color_with_flags) {
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
GPU_SHADER_INTERFACE_INFO(overlay_volume_velocity_iface, "").smooth(Type::VEC4, "finalColor");
|
||||
|
||||
GPU_SHADER_CREATE_INFO(overlay_volume_velocity)
|
||||
.do_static_compilation(true)
|
||||
.sampler(0, ImageType::FLOAT_3D, "velocityX")
|
||||
.sampler(1, ImageType::FLOAT_3D, "velocityY")
|
||||
.sampler(2, ImageType::FLOAT_3D, "velocityZ")
|
||||
@@ -26,11 +25,15 @@ GPU_SHADER_CREATE_INFO(overlay_volume_velocity)
|
||||
.push_constant(Type::VEC3, "domainOriginOffset")
|
||||
/* FluidDomainSettings.res_min */
|
||||
.push_constant(Type::IVEC3, "adaptiveCellOffset")
|
||||
.push_constant(Type::INT, "in_select_id")
|
||||
.vertex_out(overlay_volume_velocity_iface)
|
||||
.fragment_out(0, Type::VEC4, "fragColor")
|
||||
.vertex_source("overlay_volume_velocity_vert.glsl")
|
||||
.fragment_source("overlay_varying_color.glsl")
|
||||
.additional_info("draw_volume");
|
||||
.fragment_source("overlay_varying_color.glsl");
|
||||
|
||||
GPU_SHADER_CREATE_INFO(overlay_volume_velocity_streamline)
|
||||
.do_static_compilation(true)
|
||||
.additional_info("draw_volume", "overlay_volume_velocity");
|
||||
|
||||
GPU_SHADER_CREATE_INFO(overlay_volume_velocity_mac)
|
||||
.do_static_compilation(true)
|
||||
@@ -38,12 +41,12 @@ GPU_SHADER_CREATE_INFO(overlay_volume_velocity_mac)
|
||||
.push_constant(Type::BOOL, "drawMACX")
|
||||
.push_constant(Type::BOOL, "drawMACY")
|
||||
.push_constant(Type::BOOL, "drawMACZ")
|
||||
.additional_info("overlay_volume_velocity");
|
||||
.additional_info("draw_volume", "overlay_volume_velocity");
|
||||
|
||||
GPU_SHADER_CREATE_INFO(overlay_volume_velocity_needle)
|
||||
.do_static_compilation(true)
|
||||
.define("USE_NEEDLE")
|
||||
.additional_info("overlay_volume_velocity");
|
||||
.additional_info("draw_volume", "overlay_volume_velocity");
|
||||
|
||||
/** \} */
|
||||
|
||||
@@ -54,7 +57,6 @@ GPU_SHADER_CREATE_INFO(overlay_volume_velocity_needle)
|
||||
GPU_SHADER_INTERFACE_INFO(overlay_volume_gridlines_iface, "").flat(Type::VEC4, "finalColor");
|
||||
|
||||
GPU_SHADER_CREATE_INFO(overlay_volume_gridlines)
|
||||
.do_static_compilation(true)
|
||||
.push_constant(Type::FLOAT, "slicePosition")
|
||||
.push_constant(Type::INT, "sliceAxis")
|
||||
/* FluidDomainSettings.res */
|
||||
@@ -65,17 +67,21 @@ GPU_SHADER_CREATE_INFO(overlay_volume_gridlines)
|
||||
.push_constant(Type::VEC3, "domainOriginOffset")
|
||||
/* FluidDomainSettings.res_min */
|
||||
.push_constant(Type::IVEC3, "adaptiveCellOffset")
|
||||
.push_constant(Type::INT, "in_select_id")
|
||||
.vertex_out(overlay_volume_gridlines_iface)
|
||||
.fragment_out(0, Type::VEC4, "fragColor")
|
||||
.vertex_source("overlay_volume_gridlines_vert.glsl")
|
||||
.fragment_source("overlay_varying_color.glsl")
|
||||
.additional_info("draw_volume");
|
||||
.fragment_source("overlay_varying_color.glsl");
|
||||
|
||||
GPU_SHADER_CREATE_INFO(overlay_volume_gridlines_flat)
|
||||
.do_static_compilation(true)
|
||||
.additional_info("draw_volume", "overlay_volume_gridlines");
|
||||
|
||||
GPU_SHADER_CREATE_INFO(overlay_volume_gridlines_flags)
|
||||
.do_static_compilation(true)
|
||||
.define("SHOW_FLAGS")
|
||||
.sampler(0, ImageType::UINT_3D, "flagTexture")
|
||||
.additional_info("overlay_volume_gridlines");
|
||||
.additional_info("draw_volume", "overlay_volume_gridlines");
|
||||
|
||||
GPU_SHADER_CREATE_INFO(overlay_volume_gridlines_range)
|
||||
.do_static_compilation(true)
|
||||
@@ -86,6 +92,6 @@ GPU_SHADER_CREATE_INFO(overlay_volume_gridlines_range)
|
||||
.push_constant(Type::INT, "cellFilter")
|
||||
.sampler(0, ImageType::UINT_3D, "flagTexture")
|
||||
.sampler(1, ImageType::FLOAT_3D, "fieldTexture")
|
||||
.additional_info("overlay_volume_gridlines");
|
||||
.additional_info("draw_volume", "overlay_volume_gridlines");
|
||||
|
||||
/** \} */
|
||||
|
||||
@@ -2,7 +2,10 @@
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#pragma BLENDER_REQUIRE(select_lib.glsl)
|
||||
|
||||
void main()
|
||||
{
|
||||
fragColor = finalColor;
|
||||
select_id_output(select_id);
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#pragma BLENDER_REQUIRE(common_view_lib.glsl)
|
||||
#pragma BLENDER_REQUIRE(select_lib.glsl)
|
||||
|
||||
vec4 flag_to_color(uint flag)
|
||||
{
|
||||
@@ -32,6 +33,8 @@ vec4 flag_to_color(uint flag)
|
||||
|
||||
void main()
|
||||
{
|
||||
select_id_set(in_select_id);
|
||||
|
||||
int cell = gl_VertexID / 8;
|
||||
mat3 rot_mat = mat3(0.0);
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#pragma BLENDER_REQUIRE(common_view_lib.glsl)
|
||||
#pragma BLENDER_REQUIRE(select_lib.glsl)
|
||||
|
||||
/* Straight Port from BKE_defvert_weight_to_rgb()
|
||||
* TODO: port this to a color ramp. */
|
||||
@@ -89,6 +90,8 @@ vec3 get_vector_mac(ivec3 cell_co)
|
||||
|
||||
void main()
|
||||
{
|
||||
select_id_set(in_select_id);
|
||||
|
||||
#ifdef USE_NEEDLE
|
||||
int cell = gl_VertexID / 12;
|
||||
#elif defined(USE_MAC)
|
||||
|
||||
@@ -156,6 +156,7 @@ enum {
|
||||
* Fluid grid-line display color field types.
|
||||
*/
|
||||
enum {
|
||||
FLUID_GRIDLINE_COLOR_TYPE_NONE = 0,
|
||||
FLUID_GRIDLINE_COLOR_TYPE_FLAGS = 1,
|
||||
FLUID_GRIDLINE_COLOR_TYPE_RANGE = 2,
|
||||
};
|
||||
|
||||
@@ -1365,7 +1365,7 @@ static void rna_def_fluid_domain_settings(BlenderRNA *brna)
|
||||
};
|
||||
|
||||
static const EnumPropertyItem gridlines_color_field_items[] = {
|
||||
{0, "NONE", 0, "None", "None"},
|
||||
{FLUID_GRIDLINE_COLOR_TYPE_NONE, "NONE", 0, "None", "None"},
|
||||
{FLUID_GRIDLINE_COLOR_TYPE_FLAGS, "FLAGS", 0, "Flags", "Flag grid of the fluid domain"},
|
||||
{FLUID_GRIDLINE_COLOR_TYPE_RANGE,
|
||||
"RANGE",
|
||||
|
||||
Reference in New Issue
Block a user