44 environment_node_ = environment;
60 bke::node_add_link(ntree, environment, environment_out, background, background_color_in);
65 STRNCPY(image.id.name,
"IMLookdev");
80 STRNCPY(world.id.name,
"WOLookdev");
82 world.use_nodes =
true;
83 world.nodetree = ntree;
96 if (parameters_changed) {
97 intensity_socket_->value = parameters_.intensity;
98 angle_socket_->value = parameters_.rot_z;
101 environment_node_->id =
nullptr;
111 environment_node_->id = &image.id;
117 return parameters_changed;
133 visible_rect_ = *visible_rect;
134 enabled_ = inst_.is_viewport() && inst_.overlays_enabled() && inst_.use_lookdev_overlay();
137 const int2 extent_dummy(1);
140 dummy_cryptomatte_tx_.ensure_2d(
GPU_RGBA32F, extent_dummy, usage);
141 dummy_aov_color_tx_.ensure_2d_array(
GPU_RGBA16F, extent_dummy, 1, usage);
142 dummy_aov_value_tx_.ensure_2d_array(
GPU_R16F, extent_dummy, 1, usage);
146float LookdevModule::calc_viewport_scale()
148 const float viewport_scale =
clamp_f(
150 return viewport_scale;
156 (
U.lookdev_sphere_size / 400.0f) * viewport_scale *
UI_SCALE_FAC, 0.1f, 1.0f);
158 if (res_scale > 0.7f) {
161 else if (res_scale > 0.25f) {
169 const int sphere_radius =
U.lookdev_sphere_size *
UI_SCALE_FAC * viewport_scale;
170 return sphere_radius * 2;
178 const float viewport_scale = calc_viewport_scale();
184 if (spheres_[index].color_tx_.ensure_2d(color_format, extent)) {
186 if (inst_.sampling.finished_viewport()) {
187 inst_.sampling.reset();
195 const Camera &cam = inst_.camera;
197 int2 display_extent = inst_.film.display_extent_get();
198 float pixel_radius = inst_.shadows.screen_pixel_radius(
202 pixel_radius *= sphere_distance;
205 this->sphere_radius_ = (extent.x / 2) * pixel_radius;
206 this->sphere_position_ = cam.
position() -
207 cam.
forward() * (sphere_distance + this->sphere_radius_);
210 model_m4.
location() = this->sphere_position_;
216 sync_pass(spheres_[0].pass, geom, inst_.materials.metallic_mat, handle);
217 sync_pass(spheres_[1].pass, geom, inst_.materials.diffuse_mat, handle);
221void LookdevModule::sync_pass(
PassSimple &pass,
245 pass.
draw(geom, res_handle, 0);
248void LookdevModule::sync_display()
255 pass.state_set(
state);
259 pass.push_constant(
"anchor",
int2(visible_rect_.
xmax, visible_rect_.
ymin));
260 pass.bind_texture(
"metallic_tx", &spheres_[0].color_tx_);
261 pass.bind_texture(
"diffuse_tx", &spheres_[1].color_tx_);
271 for (Sphere &sphere : spheres_) {
272 sphere.framebuffer.bind();
273 inst_.manager->submit(sphere.pass,
view);
289 inst_.manager->submit(display_ps_);
302 if (v3d ==
nullptr) {
306 const ::View3DShading &shading = v3d->shading;
310 rot_z = shading.studiolight_rot_z;
312 blur = shading.studiolight_blur;
313 intensity = shading.studiolight_intensity;
327 return !(*
this == other);
GPUTexture * BKE_image_get_gpu_texture(Image *image, ImageUser *iuser)
void BKE_libblock_free_datablock(ID *id, int flag) ATTR_NONNULL()
void BKE_libblock_init_empty(ID *id) ATTR_NONNULL(1)
#define SH_NODE_OUTPUT_WORLD
#define SH_NODE_VECTOR_ROTATE
#define SH_NODE_TEX_COORD
#define SH_NODE_TEX_ENVIRONMENT
#define SH_NODE_BACKGROUND
@ STUDIOLIGHT_EQUIRECT_RADIANCE_GPUTEXTURE
struct StudioLight * BKE_studiolight_find(const char *name, int flag)
void BKE_studiolight_ensure_flag(StudioLight *sl, int flag)
#define STUDIOLIGHT_ORIENTATIONS_MATERIAL_MODE
MINLINE float clamp_f(float value, float min, float max)
MINLINE void copy_v4_fl(float r[4], float f)
BLI_INLINE int BLI_rcti_size_x(const struct rcti *rct)
#define STRNCPY(dst, src)
@ NODE_VECTOR_ROTATE_TYPE_AXIS_Z
@ V3D_SHADING_SCENE_WORLD_RENDER
@ V3D_SHADING_SCENE_WORLD
#define GPU_ATTACHMENT_TEXTURE(_texture)
#define GPU_ATTACHMENT_NONE
void GPU_framebuffer_viewport_reset(GPUFrameBuffer *framebuffer)
void GPU_framebuffer_bind(GPUFrameBuffer *framebuffer)
void GPU_material_free(ListBase *gpumaterial)
void GPU_texture_ref(GPUTexture *texture)
@ GPU_TEXTURE_USAGE_SHADER_READ
@ GPU_TEXTURE_USAGE_SHADER_WRITE
#define GPU_TEXTURE_FREE_SAFE(texture)
struct blender::bke::bNodeTreeType * ntreeType_Shader
void bind_texture(const char *name, GPUTexture *texture, GPUSamplerState state=sampler_auto)
void bind_resources(U &resources)
void clear_depth(float depth)
void draw(gpu::Batch *batch, uint instance_len=-1, uint vertex_len=-1, uint vertex_first=-1, ResourceHandle handle={0}, uint custom_id=0)
void clear_color(float4 color)
void state_set(DRWState state, int clip_plane_count=0)
void material_set(Manager &manager, GPUMaterial *material)
const float3 & forward() const
const float3 & position() const
const CameraData & data_get() const
bool is_perspective() const
struct blender::eevee::HiZBuffer::@333276274241261234242230221004020010346271237200 front
A running instance of the engine.
VolumeProbeModule volume_probes
SphereProbeModule sphere_probes
UniformDataModule uniform_data
void init(const rcti *visible_rect)
LookdevModule(Instance &inst)
bool sync(const LookdevParameters &new_parameters)
UtilityTexture utility_tx
GPUMaterial * material_shader_get(::Material *blender_mat, bNodeTree *nodetree, eMaterialPipeline pipeline_type, eMaterialGeometry geometry_type, bool deferred_compilation)
GPUShader * static_shader_get(eShaderType shader_type)
struct blender::eevee::VolumeModule::@330301236050151106271146123161047263065032217016 result
additional_info("compositor_sum_float_shared") .push_constant(Type additional_info("compositor_sum_float_shared") .push_constant(Type GPU_RGBA32F
local_group_size(16, 16) .push_constant(Type texture
blender::gpu::Batch * DRW_cache_sphere_get(const eDRWLevelOfDetail level_of_detail)
Simple API to draw debug shapes and log in the viewport.
const float * DRW_viewport_invert_size_get()
DefaultFramebufferList * DRW_viewport_framebuffer_list_get()
const float * DRW_viewport_size_get()
#define RBUFS_UTILITY_TEX_SLOT
void node_set_active(bNodeTree *ntree, bNode *node)
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, const char *name, const char *idname)
bNodeSocket * node_find_socket(bNode *node, eNodeSocketInOut in_out, StringRef identifier)
detail::Pass< command::DrawCommandBuf > PassSimple
static int calc_sphere_extent(const float viewport_scale)
static eDRWLevelOfDetail calc_level_of_detail(const float viewport_scale)
MatBase< T, NumCol, NumRow > scale(const MatBase< T, NumCol, NumRow > &mat, const VectorT &scale)
MatBase< T, NumCol, NumRow > rotate(const MatBase< T, NumCol, NumRow > &mat, const RotationT &rotation)
bool assign_if_different(T &old_value, T new_value)
MatBase< float, 4, 4 > float4x4
VecBase< float, 4 > float4
VecBase< int32_t, 2 > int2
VecBase< float, 2 > float2
MatBase< float, 3, 3 > float3x3
VecBase< float, 3 > float3
GPUFrameBuffer * default_fb
struct bNodeTree * nodetree
struct GPUTexture * equirect_radiance_gputexture
bool operator==(const LookdevParameters &other) const
bool operator!=(const LookdevParameters &other) const
void * BKE_image_get_tile