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