Blender V5.0
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
28
29/* -------------------------------------------------------------------- */
33
34class World {
35 public:
41
42 private:
43 Instance &inst_;
44
45 /* Used to detect if world change. */
46 ::World *prev_original_world = nullptr;
47
48 /* Used when the scene doesn't have a world. */
49 ::World *default_world_ = nullptr;
50
51 /* Is true if world as a valid volume shader compiled. */
52 bool has_volume_ = false;
53 /* Is true if the volume shader has absorption. Disables distant lights. */
54 bool has_volume_absorption_ = false;
55 /* Is true if the volume shader has scattering. */
56 bool has_volume_scatter_ = false;
57 /* Is true if the surface shader is compiled and ready. */
58 bool is_ready_ = false;
59
60 LookdevWorld lookdev_world_;
61
62 public:
63 World(Instance &inst) : inst_(inst) {};
64 ~World();
65
66 /* Setup and request the background shader. */
67 void sync();
68
69 bool has_volume() const
70 {
71 return has_volume_;
72 }
73
75 {
76 return has_volume_absorption_;
77 }
78
79 bool has_volume_scatter() const
80 {
81 return has_volume_scatter_;
82 }
83
84 bool is_ready() const
85 {
86 return is_ready_;
87 }
88
89 float sun_threshold();
90
91 float sun_angle()
92 {
93 return scene_world_get()->sun_angle;
94 }
95
97 {
98 return scene_world_get()->sun_shadow_maximum_resolution;
99 }
100
102 {
103 return scene_world_get()->sun_shadow_filter_radius;
104 }
105
107 {
108 return scene_world_get()->sun_shadow_jitter_overblur;
109 }
110
112 {
113 return scene_world_get()->flag & WO_USE_SUN_SHADOW;
114 }
115
117 {
118 return scene_world_get()->flag & WO_USE_SUN_SHADOW_JITTER;
119 }
120
121 private:
122 void sync_volume(const WorldHandle &world_handle, bool wait_ready);
123
124 /* Returns a dummy black world for when a valid world isn't present or when we want to suppress
125 * any light coming from the world. */
126 ::World *default_world_get();
127
128 /* Returns either the scene world or the default world if scene has no world. */
129 ::World *scene_world_get();
130};
131
133
134} // namespace blender::eevee
@ WO_USE_SUN_SHADOW
@ WO_USE_SUN_SHADOW_JITTER
A running instance of the engine.
UniformBuffer< LightData > sunlight
bool has_volume() const
bool is_ready() const
World(Instance &inst)
bool has_volume_absorption() const
float sun_shadow_jitter_overblur()
float sun_shadow_max_resolution()
bool has_volume_scatter() const