Blender V4.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
12#pragma once
13
14#include "DNA_world_types.h"
15
16#include "eevee_lookdev.hh"
17
18namespace blender::eevee {
19
20class Instance;
21
22/* -------------------------------------------------------------------- */
31 private:
32 bNodeTree *ntree_;
33 bNodeSocketValueRGBA *color_socket_;
34
35 public:
38
41};
42
45/* -------------------------------------------------------------------- */
50class World {
51 public:
56
57 private:
58 Instance &inst_;
59
60 DefaultWorldNodeTree default_tree;
61
62 /* Used to detect if world change. */
63 ::World *prev_original_world = nullptr;
64
65 /* Used when the scene doesn't have a world. */
66 ::World *default_world_ = nullptr;
67
68 /* Is true if world as a valid volume shader compiled. */
69 bool has_volume_ = false;
70 /* Is true if the volume shader has absorption. Disables distant lights. */
71 bool has_volume_absorption_ = false;
72 /* Is true if the volume shader has scattering. */
73 bool has_volume_scatter_ = false;
74
75 LookdevWorld lookdev_world_;
76
77 public:
78 World(Instance &inst) : inst_(inst){};
79 ~World();
80
81 void sync();
82
83 bool has_volume() const
84 {
85 return has_volume_;
86 }
87
89 {
90 return has_volume_absorption_;
91 }
92
93 bool has_volume_scatter() const
94 {
95 return has_volume_scatter_;
96 }
97
98 float sun_threshold();
99
100 float sun_angle()
101 {
102 return scene_world_get()->sun_angle;
103 }
104
106 {
107 return scene_world_get()->sun_shadow_maximum_resolution;
108 }
109
111 {
112 return scene_world_get()->sun_shadow_filter_radius;
113 }
114
116 {
117 return scene_world_get()->sun_shadow_jitter_overblur;
118 }
119
121 {
122 return scene_world_get()->flag & WO_USE_SUN_SHADOW;
123 }
124
126 {
127 return scene_world_get()->flag & WO_USE_SUN_SHADOW_JITTER;
128 }
129
130 private:
131 void sync_volume(const WorldHandle &world_handle);
132
133 /* Returns a dummy black world for when a valid world isn't present or when we want to suppress
134 * any light coming from the world. */
135 ::World *default_world_get();
136
137 /* Returns either the scene world or the default world if scene has no world. */
138 ::World *scene_world_get();
139};
140
143} // 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