Blender V4.3
overlay_next_xray_fade.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2019 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
14
15#pragma once
16
18
19namespace blender::draw::overlay {
20
21class XrayFade {
22 private:
23 PassSimple xray_fade_ps_ = {"XrayFade"};
24
25 bool enabled_ = false;
26
27 public:
29 {
30 enabled_ = state.xray_enabled && (state.xray_opacity > 0.0f) &&
31 (res.selection_type == SelectionType::DISABLED);
32
33 if (!enabled_) {
34 return;
35 }
36
37 {
38 PassSimple &pass = xray_fade_ps_;
39 pass.init();
42 pass.shader_set(res.shaders.xray_fade.get());
43 /* TODO(fclem): Confusing. The meaning of xray depth texture changed between legacy engine
44 * and overlay next. To be renamed after shaders are not shared anymore. */
45 pass.bind_texture("depthTex", &res.xray_depth_tx);
46 pass.bind_texture("xrayDepthTex", &res.depth_tx);
47 pass.bind_texture("xrayDepthTexInfront", &res.depth_in_front_tx);
48 pass.push_constant("opacity", 1.0f - state.xray_opacity);
50 }
51 }
52
53 void draw(Framebuffer &framebuffer, Manager &manager, View & /*view*/)
54 {
55 if (!enabled_) {
56 return;
57 }
58
59 GPU_framebuffer_bind(framebuffer);
60 manager.submit(xray_fade_ps_);
61 }
62};
63
64} // namespace blender::draw::overlay
void GPU_framebuffer_bind(GPUFrameBuffer *framebuffer)
@ GPU_PRIM_TRIS
void submit(PassSimple &pass, View &view)
void bind_texture(const char *name, GPUTexture *texture, GPUSamplerState state=sampler_auto)
void draw_procedural(GPUPrimType primitive, uint instance_len, uint vertex_len, uint vertex_first=-1, ResourceHandle handle={0}, uint custom_id=0)
Definition draw_pass.hh:833
void state_set(DRWState state, int clip_plane_count=0)
Definition draw_pass.hh:954
void framebuffer_set(GPUFrameBuffer **framebuffer)
Definition draw_pass.hh:977
void push_constant(const char *name, const float &data)
void shader_set(GPUShader *shader)
Definition draw_pass.hh:971
void begin_sync(Resources &res, State &state)
void draw(Framebuffer &framebuffer, Manager &manager, View &)
@ DRW_STATE_WRITE_COLOR
Definition draw_state.hh:30
@ DRW_STATE_BLEND_MUL
Definition draw_state.hh:60
static ulong state[N]
detail::Pass< command::DrawCommandBuf > PassSimple