61 if (default_world_ !=
nullptr) {
66::World *World::default_world_get()
68 if (default_world_ ==
nullptr) {
70 default_world_->horr = default_world_->horg = default_world_->horb = 0.0f;
71 default_world_->use_nodes = 0;
72 default_world_->nodetree =
nullptr;
75 return default_world_;
78::World *World::scene_world_get()
86 if (inst_.is_baking()) {
91 if (inst_.use_studio_light()) {
100 bool has_update =
false;
103 if (inst_.scene->world !=
nullptr) {
105 wo_handle = inst_.sync.sync_world(*inst_.scene->world);
106 has_update = wo_handle.
recalc != 0;
109 bool wait_ready =
true;
112 sync_volume(wo_handle, wait_ready);
115 if (inst_.use_studio_light()) {
117 bl_world = lookdev_world_.world_get();
119 else if ((inst_.view_layer->layflag &
SCE_LAY_SKY) == 0) {
120 bl_world = default_world_get();
122 else if (has_volume_absorption_) {
123 bl_world = default_world_get();
126 bl_world = scene_world_get();
131 default_tree.nodetree_get(bl_world);
134 if (has_volume_absorption_) {
136 bl_world = default_world_get();
146 inst_.light_probes.sync_world(bl_world, has_update);
148 if (inst_.is_viewport() && has_update) {
150 inst_.sampling.reset();
153 GPUMaterial *gpumat = inst_.shaders.world_shader_get(
157 bl_world = default_world_get();
158 ntree = default_tree.nodetree_get(bl_world);
159 gpumat = inst_.shaders.world_shader_get(bl_world, ntree,
MAT_PIPE_DEFERRED, !wait_ready);
167 inst_.manager->register_layer_attributes(gpumat);
169 float opacity = inst_.use_studio_light() ? lookdev_world_.background_opacity_get() :
170 inst_.film.background_opacity_get();
171 float background_blur = inst_.use_studio_light() ? lookdev_world_.background_blur_get() : 0.0;
173 inst_.pipelines.background.sync(gpumat, opacity, background_blur);
174 inst_.pipelines.world.sync(gpumat);
177void World::sync_volume(
const WorldHandle &world_handle,
bool wait_ready)
190 bool had_volume = has_volume_;
198 has_volume_ = has_volume_absorption_ = has_volume_scatter_ =
false;
204 if (has_volume_ || had_volume) {
void BKE_id_free(Main *bmain, void *idv)
void * BKE_id_new_nomain(short type, const char *name)
#define SH_NODE_OUTPUT_WORLD
#define SH_NODE_BACKGROUND
BLI_INLINE void BLI_listbase_clear(ListBase *lb)
MINLINE void copy_v3_fl3(float v[3], float x, float y, float z)
T * DEG_get_original(T *id)
bool GPU_material_flag_get(const GPUMaterial *mat, eGPUMaterialFlag flag)
eGPUMaterialStatus GPU_material_status(GPUMaterial *mat)
@ GPU_MATFLAG_VOLUME_SCATTER
@ GPU_MATFLAG_VOLUME_ABSORPTION
bool GPU_material_has_volume_output(GPUMaterial *mat)
struct blender::bke::bNodeTreeType * ntreeType_Shader
bNodeTree * nodetree_get(::World *world)
bool use_studio_light() const
WorldVolumePipeline world_volume
GPUMaterial * world_shader_get(::World *blender_world, bNodeTree *nodetree, eMaterialPipeline pipeline_type, bool deferred_compilation)
void world_sync(const WorldHandle &world_handle)
void sync(GPUMaterial *gpumat)
bNodeSocket * node_find_socket(bNode &node, eNodeSocketInOut in_out, StringRef identifier)
bNode * node_add_static_node(const bContext *C, bNodeTree &ntree, int type)
bNodeLink & node_add_link(bNodeTree &ntree, bNode &fromnode, bNodeSocket &fromsock, bNode &tonode, bNodeSocket &tosock)
bNodeTree * node_tree_add_tree(Main *bmain, StringRef name, StringRef idname)
void node_set_active(bNodeTree &ntree, bNode &node)
void node_tree_free_embedded_tree(bNodeTree *ntree)
@ MAT_PIPE_VOLUME_MATERIAL
bool assign_if_different(T &old_value, T new_value)
struct bNodeTree * nodetree