Blender V4.3
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
12#pragma once
13
14#include "DNA_world_types.h"
15
16namespace blender::eevee {
17
18class Instance;
19class LookdevView;
20
21/* -------------------------------------------------------------------- */
28 std::string hdri;
29 float rot_z = 0.0f;
30 float background_opacity = 0.0f;
31 float intensity = 1.0f;
32 float blur = 0.0f;
33 bool show_scene_world = true;
34
36 LookdevParameters(const ::View3D *v3d);
37 bool operator==(const LookdevParameters &other) const;
38 bool operator!=(const LookdevParameters &other) const;
39};
40
43/* -------------------------------------------------------------------- */
50 private:
51 bNode *environment_node_ = nullptr;
52 bNodeSocketValueFloat *intensity_socket_ = nullptr;
53 bNodeSocketValueFloat *angle_socket_ = nullptr;
54 ::Image image = {};
55 ::World world = {};
56
57 LookdevParameters parameters_;
58
59 public:
62
63 /* Returns true if an update was detected. */
64 bool sync(const LookdevParameters &new_parameters);
65
67 {
68 return &world;
69 }
70
72 {
73 return parameters_.background_opacity;
74 }
75
76 float background_blur_get() const
77 {
78 return parameters_.blur;
79 }
80
81 float intensity_get() const
82 {
83 return parameters_.intensity;
84 }
85};
86
89/* -------------------------------------------------------------------- */
95 private:
96 Instance &inst_;
97
98 bool enabled_;
99
100 static constexpr int num_spheres = 2;
101
102 /* Size and position of the look-dev spheres in world space. */
103 float sphere_radius_;
104 float3 sphere_position_;
105
106 rcti visible_rect_;
107
108 /* Dummy textures: required to reuse forward mesh shader and avoid another shader variation. */
109 Texture dummy_cryptomatte_tx_;
110 Texture dummy_aov_color_tx_;
111 Texture dummy_aov_value_tx_;
112
113 struct Sphere {
114 Framebuffer framebuffer = {"Lookdev.Framebuffer"};
115 Texture color_tx_ = {"Lookdev.Color"};
116 PassSimple pass = {"Lookdev.Sphere"};
117 };
118
119 Sphere spheres_[num_spheres];
120 PassSimple display_ps_ = {"Lookdev.Display"};
121
122 public:
123 LookdevModule(Instance &inst);
125
126 void init(const rcti *visible_rect);
127 void sync();
128
129 void draw(View &view);
130
131 void display();
132
133 private:
134 void sync_pass(PassSimple &pass, gpu::Batch *geom, ::Material *mat, ResourceHandle res_handle);
135 void sync_display();
136
137 float calc_viewport_scale();
138
139 friend class LookdevView;
140};
141
144} // namespace blender::eevee
void init()
A running instance of the engine.
bool sync(const LookdevParameters &new_parameters)
bool operator==(const LookdevParameters &other) const
bool operator!=(const LookdevParameters &other) const