Blender V4.5
eevee_world.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2021 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
11
12#pragma once
13
14#include "DNA_world_types.h"
15
16#include "eevee_lookdev.hh"
17#include "eevee_sync.hh"
18
19struct bNodeTree;
21struct UniformBuffer;
22
23namespace blender::eevee {
24
25class Instance;
26
27/* -------------------------------------------------------------------- */
34
36 private:
37 bNodeTree *ntree_;
38 bNodeSocketValueRGBA *color_socket_;
39
40 public:
43
46};
47
49
50/* -------------------------------------------------------------------- */
54
55class World {
56 public:
61
62 private:
63 Instance &inst_;
64
65 DefaultWorldNodeTree default_tree;
66
67 /* Used to detect if world change. */
68 ::World *prev_original_world = nullptr;
69
70 /* Used when the scene doesn't have a world. */
71 ::World *default_world_ = nullptr;
72
73 /* Is true if world as a valid volume shader compiled. */
74 bool has_volume_ = false;
75 /* Is true if the volume shader has absorption. Disables distant lights. */
76 bool has_volume_absorption_ = false;
77 /* Is true if the volume shader has scattering. */
78 bool has_volume_scatter_ = false;
79 /* Is true if the surface shader is compiled and ready. */
80 bool is_ready_ = false;
81
82 LookdevWorld lookdev_world_;
83
84 public:
85 World(Instance &inst) : inst_(inst){};
86 ~World();
87
88 /* Setup and request the background shader. */
89 void sync();
90
91 bool has_volume() const
92 {
93 return has_volume_;
94 }
95
97 {
98 return has_volume_absorption_;
99 }
100
102 {
103 return has_volume_scatter_;
104 }
105
106 bool is_ready() const
107 {
108 return is_ready_;
109 }
110
111 float sun_threshold();
112
113 float sun_angle()
114 {
115 return scene_world_get()->sun_angle;
116 }
117
119 {
120 return scene_world_get()->sun_shadow_maximum_resolution;
121 }
122
124 {
125 return scene_world_get()->sun_shadow_filter_radius;
126 }
127
129 {
130 return scene_world_get()->sun_shadow_jitter_overblur;
131 }
132
134 {
135 return scene_world_get()->flag & WO_USE_SUN_SHADOW;
136 }
137
139 {
140 return scene_world_get()->flag & WO_USE_SUN_SHADOW_JITTER;
141 }
142
143 private:
144 void sync_volume(const WorldHandle &world_handle, bool wait_ready);
145
146 /* Returns a dummy black world for when a valid world isn't present or when we want to suppress
147 * any light coming from the world. */
148 ::World *default_world_get();
149
150 /* Returns either the scene world or the default world if scene has no world. */
151 ::World *scene_world_get();
152};
153
155
156} // namespace blender::eevee
@ WO_USE_SUN_SHADOW
@ WO_USE_SUN_SHADOW_JITTER
bNodeTree * nodetree_get(::World *world)
A running instance of the engine.
UniformBuffer< LightData > sunlight
bool has_volume() const
World(Instance &inst)
bool has_volume_absorption() const
float sun_shadow_jitter_overblur()
float sun_shadow_max_resolution()
bool has_volume_scatter() const