Blender V4.5
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_manager.hh"
25#include "draw_pass.hh"
26
27struct bNode;
29struct View3D;
30
31namespace blender::eevee {
32
33class Instance;
34class LookdevView;
35
36using blender::draw::Framebuffer;
38using blender::draw::ResourceHandle;
39using blender::draw::Texture;
40using blender::draw::View;
41
42/* -------------------------------------------------------------------- */
49 std::string hdri;
50 float rot_z = 0.0f;
51 float background_opacity = 0.0f;
52 float intensity = 1.0f;
53 float blur = 0.0f;
54 bool show_scene_world = true;
55
57 LookdevParameters(const ::View3D *v3d);
58 bool operator==(const LookdevParameters &other) const;
59 bool operator!=(const LookdevParameters &other) const;
60};
61
63
64/* -------------------------------------------------------------------- */
69
71 private:
72 bNode *environment_node_ = nullptr;
73 bNodeSocketValueFloat *intensity_socket_ = nullptr;
74 bNodeSocketValueFloat *angle_socket_ = nullptr;
75 ::Image *image = nullptr;
76 ::World *world = nullptr;
77
78 LookdevParameters parameters_;
79
80 public:
83
84 /* Returns true if an update was detected. */
85 bool sync(const LookdevParameters &new_parameters);
86
88 {
89 return world;
90 }
91
93 {
94 return parameters_.background_opacity;
95 }
96
97 float background_blur_get() const
98 {
99 return parameters_.blur;
100 }
101
102 float intensity_get() const
103 {
104 return parameters_.intensity;
105 }
106};
107
109
110/* -------------------------------------------------------------------- */
114
116 private:
117 Instance &inst_;
118
119 bool enabled_;
120
121 static constexpr int num_spheres = 2;
122
126 enum SphereLOD {
127 LOW = 0,
128 MEDIUM = 1,
129 HIGH = 2,
130
131 MAX, /* Max number of level of detail */
132 };
133
134 std::array<gpu::Batch *, MAX> sphere_lod_ = {};
135
136 /* Size and position of the look-dev spheres in world space. */
137 float sphere_radius_;
138 float3 sphere_position_;
139
140 rcti visible_rect_;
141
142 /* Dummy textures: required to reuse forward mesh shader and avoid another shader variation. */
143 Texture dummy_cryptomatte_tx_;
144 Texture dummy_aov_color_tx_;
145 Texture dummy_aov_value_tx_;
146
147 struct Sphere {
148 Framebuffer framebuffer = {"Lookdev.Framebuffer"};
149 Texture color_tx_ = {"Lookdev.Color"};
150 PassSimple pass = {"Lookdev.Sphere"};
151 };
152
153 Sphere spheres_[num_spheres];
154 PassSimple display_ps_ = {"Lookdev.Display"};
155
156 public:
157 LookdevModule(Instance &inst);
159
160 void init(const rcti *visible_rect);
161 void sync();
162
163 void draw(View &view);
164
165 void display();
166
167 private:
168 void sync_pass(PassSimple &pass, gpu::Batch *geom, ::Material *mat, ResourceHandle res_handle);
169 void sync_display();
170
171 float calc_viewport_scale();
172 SphereLOD calc_level_of_detail(const float viewport_scale);
173 blender::gpu::Batch *sphere_get(const SphereLOD level_of_detail);
174
175 friend class LookdevView;
176};
177
179
180} // 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