Blender V5.0
overlay_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
8
9#pragma once
10
11#include "overlay_base.hh"
12
13namespace blender::draw::overlay {
14
21 private:
22 PassSimple xray_fade_ps_ = {"XrayFade"};
23
24 public:
25 void begin_sync(Resources &res, const State &state) final
26 {
27 enabled_ = state.xray_enabled && (state.xray_opacity > 0.0f) && !res.is_selection();
28
29 if (!enabled_) {
30 return;
31 }
32
33 {
34 PassSimple &pass = xray_fade_ps_;
35 pass.init();
37 pass.framebuffer_set(&res.overlay_color_only_fb);
38 pass.shader_set(res.shaders->xray_fade.get());
39 /* TODO(fclem): Confusing. The meaning of xray depth texture changed between legacy engine
40 * and overlay next. To be renamed after shaders are not shared anymore. */
41 pass.bind_texture("depth_tx", &res.xray_depth_tx);
42 pass.bind_texture("depth_txInfront", &res.xray_depth_in_front_tx);
43 pass.bind_texture("xray_depth_tx", &res.depth_tx);
44 pass.bind_texture("xray_depth_txInfront", &res.depth_in_front_tx);
45 pass.push_constant("opacity", 1.0f - state.xray_opacity);
47 }
48 }
49
50 void draw_color_only(Framebuffer &framebuffer, Manager &manager, View & /*view*/) final
51 {
52 if (!enabled_) {
53 return;
54 }
55
56 GPU_framebuffer_bind(framebuffer);
57 manager.submit(xray_fade_ps_);
58 }
59};
60
61} // namespace blender::draw::overlay
void GPU_framebuffer_bind(blender::gpu::FrameBuffer *fb)
@ GPU_PRIM_TRIS
void framebuffer_set(gpu::FrameBuffer **framebuffer)
void shader_set(gpu::Shader *shader)
void bind_texture(const char *name, gpu::Texture *texture, GPUSamplerState state=sampler_auto)
void draw_procedural(GPUPrimType primitive, uint instance_len, uint vertex_len, uint vertex_first=-1, ResourceIndexRange res_index={}, uint custom_id=0)
Definition draw_pass.hh:964
void state_set(DRWState state, int clip_plane_count=0)
void push_constant(const char *name, const float &data)
void begin_sync(Resources &res, const State &state) final
void draw_color_only(Framebuffer &framebuffer, Manager &manager, View &) final
@ 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