Blender V5.0
eevee_lookdev.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
11
12#pragma once
13
14#include <string>
15
16#include "DNA_image_types.h"
17#include "DNA_vec_types.h"
18#include "DNA_world_types.h"
19
21
22#include "DRW_gpu_wrapper.hh"
23
24#include "draw_pass.hh"
25
26struct bNode;
28struct View3D;
29
30namespace blender::eevee {
31
32class Instance;
33class LookdevView;
34
35using blender::draw::Framebuffer;
37using blender::draw::ResourceHandleRange;
38using blender::draw::Texture;
39using blender::draw::View;
40
41/* -------------------------------------------------------------------- */
48 std::string hdri;
49 float rot_z = 0.0f;
50 float background_opacity = 0.0f;
51 float intensity = 1.0f;
52 float blur = 0.0f;
53 bool show_scene_world = true;
54
56 LookdevParameters(const ::View3D *v3d);
57 bool operator==(const LookdevParameters &other) const;
58 bool operator!=(const LookdevParameters &other) const;
59};
60
62
63/* -------------------------------------------------------------------- */
68
70 private:
71 bNode *environment_node_ = nullptr;
72 bNodeSocketValueFloat *intensity_socket_ = nullptr;
73 bNodeSocketValueFloat *angle_socket_ = nullptr;
74 ::Image *image = nullptr;
75 ::World *world = nullptr;
76
77 LookdevParameters parameters_;
78
79 public:
82
83 /* Returns true if an update was detected. */
84 bool sync(const LookdevParameters &new_parameters);
85
87 {
88 return world;
89 }
90
92 {
93 return parameters_.background_opacity;
94 }
95
96 float background_blur_get() const
97 {
98 return parameters_.blur;
99 }
100
101 float intensity_get() const
102 {
103 return parameters_.intensity;
104 }
105};
106
108
109/* -------------------------------------------------------------------- */
113
115 private:
116 Instance &inst_;
117
118 bool enabled_;
119
120 static constexpr int num_spheres = 2;
121
125 enum SphereLOD {
126 LOW = 0,
127 MEDIUM = 1,
128 HIGH = 2,
129
130 MAX, /* Max number of level of detail */
131 };
132
133 std::array<gpu::Batch *, MAX> sphere_lod_ = {};
134
135 /* Size and position of the look-dev spheres in world space. */
136 float sphere_radius_;
137 float3 sphere_position_;
138
139 rcti visible_rect_;
140
141 /* Dummy textures: required to reuse forward mesh shader and avoid another shader variation. */
142 Texture dummy_cryptomatte_tx_;
143 Texture dummy_aov_color_tx_;
144 Texture dummy_aov_value_tx_;
145
146 struct Sphere {
147 Framebuffer framebuffer = {"Lookdev.Framebuffer"};
148 Texture color_tx_ = {"Lookdev.Color"};
149 PassSimple pass = {"Lookdev.Sphere"};
150 };
151
152 Sphere spheres_[num_spheres];
153 PassSimple display_ps_ = {"Lookdev.Display"};
154
155 public:
156 LookdevModule(Instance &inst);
158
159 void init(const rcti *visible_rect);
160 void sync();
161
162 void draw(View &view);
163
164 void display();
165
166 private:
167 void sync_pass(PassSimple &pass,
168 gpu::Batch *geom,
169 ::Material *mat,
170 ResourceHandleRange res_handle);
171 void sync_display();
172
173 float calc_viewport_scale();
174 SphereLOD calc_level_of_detail(const float viewport_scale);
175 blender::gpu::Batch *sphere_get(const SphereLOD level_of_detail);
176
177 friend class LookdevView;
178};
179
181
182} // namespace blender::eevee
static AppView * view
void init()
A running instance of the engine.
bool sync(const LookdevParameters &new_parameters)
detail::Pass< command::DrawCommandBuf > PassSimple
VecBase< float, 3 > float3
bool operator==(const LookdevParameters &other) const
bool operator!=(const LookdevParameters &other) const