86 (viewport_uses_eevee && !use_resolution_scaling) ||
87 viewport_engine_provides_depth;
140 ensure_weight_ramp_texture();
152void Instance::ensure_weight_ramp_texture()
165 return a.
r ==
b.r && a.
g ==
b.g && a.
b ==
b.b && a.
a ==
b.a && a.
pos ==
b.pos &&
169 for (
int i = 0; i <
ARRAY_SIZE(a.data); i++) {
170 if (!is_equal_cbd(a.data[i],
b.data[i])) {
191 auto evaluate_weight_to_color = [&](
const float weight,
float result[4]) {
192 if (user_weight_ramp) {
199 const float gamma = 1.5f;
200 const float hsv[3] = {
201 (2.0f / 3.0f) * (1.0f - weight), 1.0f,
pow(0.5f + 0.5f * weight, gamma)};
205 for (
int i = 0; i < 3; i++) {
211 constexpr int res = 256;
213 float pixels[res][4];
214 for (
int i = 0; i < res; i++) {
215 evaluate_weight_to_color(i / 255.0f, pixels[i]);
220 for (
int i = 0; i < res; i++) {
231 if (!
state.is_space_v3d() ||
state.clipping_plane_count == 0) {
251 using namespace math;
255 return float4(r, g,
b, a) / 255.0f;
305 gb.colors.edit_mesh_middle =
interpolate(gb.colors.vert_select, gb.colors.wire_edit, 0.35f);
307 gb.colors.edit_mesh_middle =
float4(
309 gb.colors.edit_mesh_middle.w);
313 gb.colors.edge_freestyle[3] = 1.0f;
316 gb.colors.edge_freestyle =
float4(0.0f);
317 gb.colors.face_freestyle =
float4(0.0f);
338 gb.colors.bone_ik_line =
float4(0.8f, 0.8f, 0.0f, 1.0f);
339 gb.colors.bone_ik_line_no_target =
float4(0.8f, 0.5f, 0.2f, 1.0f);
340 gb.colors.bone_ik_line_spline =
float4(0.8f, 0.8f, 0.2f, 1.0f);
371 const bool is_bg_darker =
reduce_add(gb.colors.grid.xyz()) + 0.12f >
379 const int grid_axis_offset_i = int((grid_axis_brightness * 2.0f - 1.0f) * 255.0f);
401 }
while (++
color <= color_end);
404 gb.sizes.pixel = 1.0f;
407 gb.sizes.light_circle = 9.0f;
408 gb.sizes.light_circle_shadow = (gb.sizes.light_circle + 3.0f);
418 float *size =
reinterpret_cast<float *
>(&gb.sizes);
419 float *size_end = size + (
sizeof(gb.sizes) /
sizeof(
float));
421 *size *=
U.pixelsize;
422 }
while (++size <= size_end);
427 gb.pixel_fac =
state.rv3d->pixsize;
429 else if (
state.region) {
438 gb.size_viewport_inv = 1.0f / gb.size_viewport;
453 gb.backface_culling =
false;
511 begin_sync_layer(regular);
512 begin_sync_layer(infront);
523 const bool in_paint_mode = object_is_paint_mode(ob_ref.
object);
524 const bool in_sculpt_mode = object_is_sculpt_mode(ob_ref);
525 const bool in_particle_edit_mode = object_is_particle_edit_mode(ob_ref);
526 const bool in_edit_paint_mode = object_is_edit_paint_mode(
527 ob_ref, in_edit_mode, in_paint_mode, in_sculpt_mode);
528 const bool needs_prepass = object_needs_prepass(ob_ref, in_paint_mode);
538 if (in_particle_edit_mode) {
546 if (in_edit_paint_mode) {
550 else if (in_object_mode) {
572 if (in_sculpt_mode) {
629 layer.wireframe.object_sync_ex(
630 manager, ob_ref,
resources,
state, in_edit_paint_mode, in_edit_mode);
686 if (object_is_selected(ob_ref) && !in_edit_paint_mode) {
713 end_sync_layer(regular);
714 end_sync_layer(infront);
731 gpu::TextureFormat::SFLOAT_32_DEPTH_UINT_8,
738 {GPU_ATTACHMENT_TEXTURE(dtxl->depth_in_front), GPU_ATTACHMENT_TEXTURE(dtxl->color)});
779 layer.attribute_viewer.pre_draw(manager, view);
780 layer.cameras.pre_draw(manager, view);
781 layer.empties.pre_draw(manager, view);
782 layer.facing.pre_draw(manager, view);
783 layer.fade.pre_draw(manager, view);
784 layer.lattices.pre_draw(manager, view);
785 layer.gsplats.pre_draw(manager, view);
786 layer.light_probes.pre_draw(manager, view);
787 layer.particles.pre_draw(manager, view);
788 layer.pointclouds.pre_draw(manager, view);
789 layer.prepass.pre_draw(manager, view);
790 layer.wireframe.pre_draw(manager, view);
806 draw_node(manager, view);
809 draw_v2d(manager, view);
812 draw_v3d(manager, view);
835void Instance::draw_node(
Manager &manager,
View &view)
842void Instance::draw_v2d(
Manager &manager,
View &view)
859void Instance::draw_v3d(
Manager &manager,
View &view)
866 layer.fade.draw(framebuffer, manager, view);
867 layer.mode_transfer.draw(framebuffer, manager, view);
868 layer.text.draw(framebuffer, manager, view);
869 layer.paints.draw(framebuffer, manager, view);
870 layer.particles.draw(framebuffer, manager, view);
873 auto draw_line = [&](OverlayLayer &
layer, Framebuffer &framebuffer) {
874 layer.bounds.draw_line(framebuffer, manager, view);
875 layer.wireframe.draw_line(framebuffer, manager, view);
876 layer.cameras.draw_line(framebuffer, manager, view);
877 layer.empties.draw_line(framebuffer, manager, view);
878 layer.axes.draw_line(framebuffer, manager, view);
879 layer.force_fields.draw_line(framebuffer, manager, view);
880 layer.gsplats.draw_line(framebuffer, manager, view);
881 layer.lights.draw_line(framebuffer, manager, view);
882 layer.light_probes.draw_line(framebuffer, manager, view);
883 layer.speakers.draw_line(framebuffer, manager, view);
884 layer.lattices.draw_line(framebuffer, manager, view);
885 layer.metaballs.draw_line(framebuffer, manager, view);
886 layer.pointclouds.draw_line(framebuffer, manager, view);
887 layer.relations.draw_line(framebuffer, manager, view);
888 layer.fluids.draw_line(framebuffer, manager, view);
889 layer.particles.draw_line(framebuffer, manager, view);
890 layer.attribute_viewer.draw_line(framebuffer, manager, view);
891 layer.armatures.draw_line(framebuffer, manager, view);
892 layer.sculpts.draw_line(framebuffer, manager, view);
893 layer.grease_pencil.draw_line(framebuffer, manager, view);
896 layer.curves.draw_line(framebuffer, manager, view);
900 layer.meshes.draw_line_only(framebuffer, manager, view);
904 layer.light_probes.draw_color_only(framebuffer, manager, view);
905 layer.curves.draw_color_only(framebuffer, manager, view);
906 layer.grease_pencil.draw_color_only(framebuffer, manager, view);
1041bool Instance::object_is_selected(
const ObjectRef &ob_ref)
1046bool Instance::object_is_paint_mode(
const Object *
object)
1052bool Instance::object_is_sculpt_mode(
const ObjectRef &ob_ref)
1056 const bool is_active_object = ob_ref.object == active_object;
1058 bool is_active_geonode_preview = ob_ref.preview_base_geometry() !=
nullptr &&
1060 return is_active_object || is_active_geonode_preview;
1065 const bool is_active_object = ob_ref.object == active_object;
1066 return is_active_object;
1072bool Instance::object_is_particle_edit_mode(
const ObjectRef &ob_ref)
1077bool Instance::object_is_sculpt_mode(
const Object *
object)
1079 if (object->runtime->sculpt_session &&
1087bool Instance::object_is_edit_paint_mode(
const ObjectRef &ob_ref,
1090 bool in_sculpt_mode)
1092 bool in_edit_paint_mode = in_edit_mode || in_paint_mode || in_sculpt_mode;
1094 return in_edit_paint_mode || ob_ref.parent_is_in_edit_paint_mode(
1098bool Instance::object_is_edit_mode(
const Object *
object)
1102 switch (object->
type) {
1133bool Instance::object_is_in_front(
const Object *
object,
const State &
state)
1135 switch (object->
type) {
1144bool Instance::object_needs_prepass(
const ObjectRef &ob_ref,
bool in_paint_mode)
1161 if (in_paint_mode) {
1163 if (object_is_rendered_transparent(ob_ref.object,
state) ||
1164 object_is_in_front(ob_ref.object,
state))
1170 if (!
state.xray_enabled) {
1172 if (!
state.is_render_depth_available && (ob_ref.object->dt >=
OB_SOLID)) {
1180bool Instance::object_is_rendered_transparent(
const Object *
object,
const State &
state)
1182 if (
state.v3d ==
nullptr) {
1186 if (!
state.is_solid()) {
1194 const View3DShading &shading =
state.v3d->shading;
1196 if (shading.type ==
OB_WIRE) {
1205 return object->color[3] < 1.0f;
1211 for (
int i = 0; i < materials_num; i++) {
1213 if (mat && mat->a < 1.0f) {
#define OB_MODE_ALL_PAINT_MESH
#define OB_MODE_ALL_PAINT_GPENCIL
#define RV3D_LOCK_FLAGS(rv3d)
#define RV3D_CLIPPING_ENABLED(v3d, rv3d)
#define SHADING_XRAY_FLAG_ENABLED(shading)
#define GPU_framebuffer_ensure_config(_fb,...)
#define BLI_assert_unreachable()
constexpr IndexRange()=default
void display_to_view(View &view)
void ensure_visibility(View &view)
bool ensure_2d(gpu::TextureFormat format, int2 extent, eGPUTextureUsage usage=GPU_TEXTURE_USAGE_GENERAL, const float *data=nullptr, int mip_len=1)
bool ensure_1d(gpu::TextureFormat format, int extent, eGPUTextureUsage usage=GPU_TEXTURE_USAGE_GENERAL, const float *data=nullptr, int mip_len=1)
const float4x4 & winmat(int view_id=0) const
static View & default_get()
const float4x4 & viewinv(int view_id=0) const
void begin_sync(Resources &res, const State &state) final
void draw_output(Framebuffer &framebuffer, Manager &manager, View &) final
static bool is_pose_mode(const Object *armature_ob, const State &state)
void draw_vignette(Framebuffer &framebuffer, Manager &manager, View &view)
void draw_output(Framebuffer &framebuffer, Manager &manager, View &view) final
void begin_sync(Resources &res, const State &state) final
void begin_sync(Resources &res, const State &state) final
void draw_output(Framebuffer &framebuffer, Manager &manager, View &) final
static void compute_depth_planes(Manager &manager, View &view, Resources &res, const State &)
void draw_line(Framebuffer &framebuffer, Manager &manager, View &view) final
void begin_sync(Resources &res, const State &state) final
void begin_sync(Resources &res, const State &state) final
void draw_on_render(gpu::FrameBuffer *framebuffer, Manager &manager, View &view) final
void draw(Manager &manager) final
void object_sync(ObjectRef &ob_ref, Manager &manager) final
ImagePrepass image_prepass
AntiAliasing anti_aliasing
void object_sync(Manager &, const ObjectRef &ob_ref, Resources &, const State &state) final
void begin_sync(Resources &res, const State &state) final
void draw_color_only(Framebuffer &framebuffer, Manager &manager, View &view) final
void begin_sync(Resources &, const State &state) final
void draw_color_only(Framebuffer &framebuffer, Manager &manager, View &view) final
void object_sync(Manager &, const ObjectRef &ob_ref, Resources &res, const State &state) final
void end_sync(Resources &res, const State &state) final
void object_sync(Manager &manager, const ObjectRef &ob_ref, Resources &res, const State &state) final
void flat_objects_pass_sync(Manager &manager, View &view, Resources &res, const State &state)
void pre_draw(Manager &manager, View &view) final
void begin_sync(Resources &res, const State &state) final
void draw_line_only_ex(Framebuffer &framebuffer, Resources &res, Manager &manager, View &view)
void begin_sync(Resources &res, const State &state) final
void draw_color_only(Framebuffer &framebuffer, Manager &manager, View &) final
Simple API to draw debug shapes and log in the viewport.
float dot(VecOp< float, D >, VecOp< float, D >) RET
bool is_equal(float a, float b, const float epsilon)
Quaternion interpolate(Quaternion a, Quaternion b, float t)
float reduce_add(float2 a)
#define unit_float_to_uchar_clamp_v4(v1, v2)
void get_color_4fv(int colorid, float col[4])
void get_color_blend_shade_3fv(int colorid1, int colorid2, float fac, int offset, float col[3])
float get_value_f(int colorid)
void get_color_shade_4fv(int colorid, int offset, float col[4])
const bTheme * theme_get()
void get_color_blend_shade_4fv(int colorid1, int colorid2, float fac, int offset, float col[4])
void get_color_shade_alpha_4fv(int colorid, int coloffset, int alphaoffset, float col[4])
@ V3D_OVERLAY_HIDE_OBJECT_ORIGINS
@ V3D_OVERLAY_HIDE_MOTION_PATHS
@ V3D_OVERLAY_HIDE_OBJECT_XTRAS
void GPU_framebuffer_bind(gpu::FrameBuffer *fb)
int BKE_render_preview_pixel_size(const RenderData *r)
VecBase< uint8_t, 4 > uchar4
MINLINE void rgba_uchar_to_float(float r_col[4], const unsigned char col_ub[4])
int BKE_object_material_used_with_fallback_eval(const Object &ob)
Object * BKE_view_layer_active_object_get(const ViewLayer *view_layer)
void GPU_texture_update(gpu::Texture *texture, eGPUDataFormat data_format, const void *data)
void ED_space_image_get_aspect(SpaceImage *sima, float *r_aspx, float *r_aspy)
bool assign_if_different(T &old_value, T &&new_value)
void ED_space_image_get_size(SpaceImage *sima, int *r_width, int *r_height)
@ RE_WRITE_VIEWPORT_DEPTH
void GPU_framebuffer_clear_color(gpu::FrameBuffer *fb, const double4 clear_col)
void DRW_text_cache_destroy(DRWTextStore *dt)
MINLINE void srgb_to_linearrgb_v4(float linear[4], const float srgb[4])
RenderEngineType * ED_view3d_engine_type(const Scene *scene, int drawtype)
@ TH_TRANSPARENT_CHECKER_SIZE
@ TH_HANDLE_SEL_AUTOCLAMP
@ TH_TRANSPARENT_CHECKER_SECONDARY
@ TH_TRANSPARENT_CHECKER_PRIMARY
bool BKE_colorband_evaluate(const ColorBand *coba, float in, float out[4])
@ SI_OVERLAY_SHOW_OVERLAYS
@ V3D_SHADING_BACKFACE_CULLING
@ CTX_MODE_EDIT_POINTCLOUD
@ CTX_MODE_EDIT_GREASE_PENCIL
const char * RE_engine_id_BLENDER_EEVEE
void GPU_texture_update_sub(gpu::Texture *texture, eGPUDataFormat data_format, const void *pixels, int offset_x, int offset_y, int offset_z, int width, int height, int depth, uint unpack_row_length=0)
@ GPU_TEXTURE_USAGE_SHADER_READ
@ GPU_TEXTURE_USAGE_GENERAL
T & DRW_object_get_data_for_drawing(const Object &object)
Main * DEG_get_bmain(const Depsgraph *graph)
void hsv_to_rgb_v(const float hsv[3], float r_rgb[3])
BMesh const char void * data
@ USER_GPU_FLAG_FRESNEL_EDIT
constexpr size_t ARRAY_SIZE(const T(&arg)[N]) noexcept
bool BKE_view_layer_synced_ensure(const Main &bmain, const Scene *scene, ViewLayer *view_layer)
void DRW_submission_end()
void DRW_text_cache_draw(DRWTextStore *dt, const ARegion *region, const View3D *v3d)
const DRWContext * DRW_context_get()
@ V3D_SHADING_MATERIAL_COLOR
@ V3D_SHADING_OBJECT_COLOR
void GPU_framebuffer_clear_depth(gpu::FrameBuffer *fb, float clear_depth)
bool BKE_scene_uses_blender_workbench(const Scene *scene)
void _DNA_internal_memzero(void *dst, size_t size)
MINLINE float max_ff(float a, float b)
void ED_space_image_get_uv_aspect(SpaceImage *sima, float *r_aspx, float *r_aspy)
Material * BKE_object_material_get_eval(Object *ob, short act)
void DRW_submission_start()
DRWTextStore * DRW_text_cache_create()
bool DRW_object_is_in_edit_mode(const Object *ob)
void GPU_framebuffer_clear_color_depth(gpu::FrameBuffer *fb, const double4 clear_col, float clear_depth)
void GPU_depth_test(GPUDepthTest test)
float DEG_get_ctime(const Depsgraph *graph)
VecBase< double, 4 > double4
gpu::Texture * GPU_texture_create_2d(const char *name, int width, int height, int mip_len, gpu::TextureFormat format, eGPUTextureUsage usage, const float *data)
enum eContextObjectMode CTX_data_mode_enum_ex(const Object *obedit, const Object *ob, eObjectMode object_mode)
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
float grid_axis_brightness
eColorBand_ColorMode color_mode
eColorBand_Interp ipotype
eColorBand_HueInterp ipotype_hue
DefaultTextureList * viewport_texture_list_get() const
struct blender::DRWContext::@231153257105305272346150064304121064225151163351 options
bool is_image_render() const
float2 viewport_size_get() const
bool is_material_select() const
DefaultFramebufferList * viewport_framebuffer_list_get() const
bool is_viewport_image_render() const
enum blender::DRWContext::Mode mode
gpu::FrameBuffer * in_front_fb
gpu::Texture * depth_in_front
eSpaceImageOverlay_Flag flag
SpaceImageOverlay overlay
struct ColorBand coba_weight
float wireframe_threshold
eView3D_GridFlag gridflag
float xr_vignette_aperture
float polygon_offset_factor(const float4x4 &winmat)
Framebuffer overlay_line_in_front_fb
Framebuffer overlay_line_only_fb
TextureRef depth_target_tx
Framebuffer overlay_color_only_fb
Framebuffer overlay_output_color_only_fb
TextureRef depth_target_in_front_tx
Framebuffer overlay_output_fb
gpu::FrameBuffer * render_fb
ColorBand weight_ramp_copy
void begin_sync(int clipping_plane_count)
Framebuffer overlay_in_front_fb
void acquire(const DRWContext *draw_ctx, const State &state)
void update_theme_settings(const DRWContext *ctx, const State &state)
gpu::FrameBuffer * render_in_front_fb
draw::UniformArrayBuffer< float4, 6 > clip_planes_buf
void init(bool clipping_enabled)
bool is_selection() const
static float vertex_size_get()
draw::UniformBuffer< UniformData > globals_buf
void update_clip_planes(const State &state)
Framebuffer overlay_line_fb
const ViewLayer * view_layer
View::OffsetData offset_data_get() const
bool xray_enabled_and_not_wire
const SpaceLink * space_data
const Object * object_active
bool show_bone_selection() const
bool is_viewport_image_render
const bToolRef * active_tool
bool is_render_depth_available
eContextObjectMode ctx_mode
bool is_depth_only_drawing
const RegionView3D * rv3d
bool is_space_image() const