22 PassMain ps_ = {
"attribute_viewer_ps_"};
30 bool enabled_ =
false;
42 state.clipping_plane_count);
44 auto create_sub = [&](
const char *name,
GPUShader *shader) {
45 auto &sub = ps_.sub(name);
46 sub.shader_set(shader);
60 const bool is_preview = dupli_object !=
nullptr &&
62 if (!enabled_ || !is_preview) {
67 const auto &instances =
69 if (
const std::optional<blender::bke::AttributeMetaData> meta_data =
70 instances.attributes()->lookup_meta_data(
".viewer"))
72 if (attribute_type_supports_viewer_overlay(meta_data->data_type)) {
73 populate_for_instance(ob_ref, *dupli_object,
state, manager);
78 populate_for_geometry(ob_ref,
state, manager);
92 void populate_for_instance(
const ObjectRef &ob_ref,
107 color.a *=
state.overlay.viewer_attribute_opacity;
108 switch (
object.type) {
114 auto &sub = *instance_sub_;
116 sub.draw(
batch, res_handle);
119 auto &sub = *instance_sub_;
121 sub.draw(
batch, res_handle);
127 auto &sub = *pointcloud_sub_;
129 sub.push_constant(
"ucolor", color);
135 auto &sub = *instance_sub_;
136 sub.push_constant(
"ucolor", color);
138 sub.draw(
batch, res_handle);
149 static bool attribute_type_supports_viewer_overlay(
const eCustomDataType data_type)
155 void populate_for_geometry(
const ObjectRef &ob_ref,
const State &
state, Manager &manager)
157 const float opacity =
state.overlay.viewer_attribute_opacity;
158 Object &
object = *ob_ref.object;
159 switch (
object.type) {
161 Mesh *mesh =
static_cast<Mesh *
>(
object.data);
162 if (
const std::optional<bke::AttributeMetaData> meta_data =
163 mesh->
attributes().lookup_meta_data(
".viewer"))
165 if (attribute_type_supports_viewer_overlay(meta_data->data_type)) {
167 auto &sub = *mesh_sub_;
168 sub.push_constant(
"opacity", opacity);
169 sub.draw(
batch, manager.unique_handle(ob_ref));
176 if (
const std::optional<bke::AttributeMetaData> meta_data =
177 pointcloud->
attributes().lookup_meta_data(
".viewer"))
179 if (attribute_type_supports_viewer_overlay(meta_data->data_type)) {
181 auto &sub = *pointcloud_sub_;
183 sub.push_constant(
"opacity", opacity);
184 sub.bind_texture(
"attribute_tx", vertbuf);
185 sub.draw(
batch, manager.unique_handle(ob_ref));
191 Curve *curve =
static_cast<Curve *
>(
object.data);
194 if (
const std::optional<bke::AttributeMetaData> meta_data =
195 curves.attributes().lookup_meta_data(
".viewer"))
197 if (attribute_type_supports_viewer_overlay(meta_data->data_type)) {
199 auto &sub = *curve_sub_;
200 sub.push_constant(
"opacity", opacity);
201 ResourceHandle res_handle = manager.resource_handle(
object.object_to_world());
202 sub.draw(
batch, res_handle);
210 const bke::CurvesGeometry &curves = curves_id->
geometry.wrap();
211 if (
const std::optional<bke::AttributeMetaData> meta_data =
212 curves.attributes().lookup_meta_data(
".viewer"))
214 if (attribute_type_supports_viewer_overlay(meta_data->data_type)) {
215 bool is_point_domain;
217 curves_id,
".viewer", &is_point_domain);
218 auto &sub = *curves_sub_;
220 sub.push_constant(
"opacity", opacity);
221 sub.push_constant(
"is_point_domain", is_point_domain);
222 sub.bind_texture(
"color_tx", *
texture);
223 sub.draw(
batch, manager.unique_handle(ob_ref));
Low-level operations for curves.
#define CD_TYPE_AS_MASK(_type)
#define CD_MASK_PROP_QUATERNION
#define CD_MASK_PROP_FLOAT4X4
struct PointCloud PointCloud
@ V3D_OVERLAY_VIEWER_ATTRIBUTE
void GPU_framebuffer_bind(GPUFrameBuffer *framebuffer)
in reality light always falls off quadratically Particle Retrieve the data of the particle that spawned the object for example to give variation to multiple instances of an object Point Retrieve information about points in a point cloud Retrieve the edges of an object as it appears to Cycles topology will always appear triangulated Convert a blackbody temperature to an RGB value Normal Generate a perturbed normal from an RGB normal map image Typically used for faking highly detailed surfaces Generate an OSL shader from a file or text data block Image Sample an image file as a texture Gabor Generate Gabor noise Gradient Generate interpolated color and intensity values based on the input vector Magic Generate a psychedelic color texture Voronoi Generate Worley noise based on the distance to random points Typically used to generate textures such as or biological cells Brick Generate a procedural texture producing bricks Texture Retrieve multiple types of texture coordinates nTypically used as inputs for texture nodes Vector Convert a or normal between and object coordinate space Combine Create a color from its and value channels Color Retrieve a color attribute
struct GPUShader GPUShader
std::optional< AttributeAccessor > attributes() const final
ResourceHandle unique_handle(const ObjectRef &ref)
void submit(PassSimple &pass, View &view)
ResourceHandle resource_handle(const ObjectRef &ref, float inflate_bounds=0.0f)
void push_constant(const char *name, const float &data)
detail::PassBase< command::DrawMultiBuf > Sub
void begin_sync(Resources &res, const State &state)
void object_sync(const ObjectRef &ob_ref, const State &state, Manager &manager)
void draw(Framebuffer &framebuffer, Manager &manager, View &view)
ShaderPtr attribute_viewer_pointcloud
ShaderPtr attribute_viewer_mesh
ShaderPtr attribute_viewer_curves
ShaderPtr attribute_viewer_curve
local_group_size(16, 16) .push_constant(Type texture
blender::gpu::Batch * DRW_cache_curve_edge_wire_viewer_attribute_get(Object *ob)
blender::gpu::Batch * DRW_cache_curve_edge_wire_get(Object *ob)
blender::gpu::Batch * DRW_cache_mesh_surface_get(Object *ob)
blender::gpu::Batch * DRW_cache_mesh_loose_edges_get(Object *ob)
blender::gpu::Batch * DRW_cache_mesh_surface_viewer_attribute_get(Object *ob)
DupliObject * DRW_object_get_dupli(const Object *)
@ DRW_STATE_DEPTH_LESS_EQUAL
struct @157336070235062372277311340362362342103123126032::@262166344314164341202215145112231240022370055142 batch
gpu::Batch * point_cloud_sub_pass_setup(PassMain::Sub &sub_ps, Object *object, GPUMaterial *gpu_material=nullptr)
gpu::Batch * curves_sub_pass_setup(PassMain::Sub &ps, const Scene *scene, Object *ob, GPUMaterial *gpu_material=nullptr)
detail::Pass< command::DrawMultiBuf > PassMain
gpu::VertBuf ** DRW_curves_texture_for_evaluated_attribute(Curves *curves, const char *name, bool *r_is_point_domain)
gpu::VertBuf ** DRW_pointcloud_evaluated_attribute(PointCloud *pointcloud, const char *name)
ColorSceneLinear4f< eAlpha::Premultiplied > ColorGeometry4f
const struct Curves * curve_eval
const blender::bke::GeometrySet * preview_base_geometry
int preview_instance_index
const GeometryComponent * get_component(GeometryComponent::Type component_type) const
const SelectionType selection_type