87 const int64_t num_probes = inst_.light_probes.planar_map_.size();
90 int2 extent = main_view_extent;
91 int layer_count = num_probes;
95 if (num_probes == 0) {
101 inst_.render_buffers.acquire(extent, depth_format);
105 radiance_tx_.ensure_2d_array(gpu::TextureFormat::UFLOAT_11_11_10, extent, layer_count, usage);
106 depth_tx_.ensure_2d_array(depth_format, extent, layer_count, usage);
107 depth_tx_.ensure_layer_views();
109 do_display_draw_ = inst_.draw_overlays && num_probes > 0;
111 int resource_index = 0;
112 int display_index = 0;
113 for (
PlanarProbe &probe : inst_.light_probes.planar_map_.values()) {
114 if (resource_index == PLANAR_PROBE_MAX) {
118 PlanarResources &res = resources_[resource_index];
122 probe.set_view(main_view, resource_index);
123 probe_planar_buf_[resource_index] = probe;
125 res.view.
sync(probe.viewmat, probe.winmat);
127 world_clip_buf_.plane = probe.reflection_clip_plane_get();
128 world_clip_buf_.push_update();
134 const bool with_raycast = inst_.pipelines.has_raycast;
148 inst_.pipelines.deferred.header_layer_count(),
149 inst_.pipelines.deferred.closure_layer_count(),
150 inst_.pipelines.deferred.normal_layer_count());
162 inst_.pipelines.planar.render(res.view,
163 depth_tx_.layer_view(resource_index),
169 if (do_display_draw_ && probe.viewport_display) {
170 display_data_buf_.get_or_resize(display_index++) = {probe.plane_to_world, resource_index};
178 if (resource_index < PLANAR_PROBE_MAX) {
180 probe_planar_buf_[resource_index].layer_id = -1;
182 probe_planar_buf_.push_update();
184 do_display_draw_ = display_index > 0;
185 if (do_display_draw_) {
186 display_data_buf_.resize(display_index);
187 display_data_buf_.push_update();
193 if (!do_display_draw_) {
197 viewport_display_ps_.init();
201 viewport_display_ps_.framebuffer_set(&view_fb);
204 viewport_display_ps_.push_constant(
"world_coord_packed",
206 viewport_display_ps_.bind_resources(*
this);
207 viewport_display_ps_.bind_resources(inst_.sphere_probes);
208 viewport_display_ps_.bind_ssbo(
"display_data_buf", display_data_buf_);
209 viewport_display_ps_.draw_procedural(
GPU_PRIM_TRIS, 1, display_data_buf_.size() * 6);
211 inst_.manager->submit(viewport_display_ps_, view);
void ensure(GPUAttachment depth=GPU_ATTACHMENT_NONE, GPUAttachment color1=GPU_ATTACHMENT_NONE, GPUAttachment color2=GPU_ATTACHMENT_NONE, GPUAttachment color3=GPU_ATTACHMENT_NONE, GPUAttachment color4=GPU_ATTACHMENT_NONE, GPUAttachment color5=GPU_ATTACHMENT_NONE, GPUAttachment color6=GPU_ATTACHMENT_NONE, GPUAttachment color7=GPU_ATTACHMENT_NONE, GPUAttachment color8=GPU_ATTACHMENT_NONE)
void clear(float4 values)
bool ensure_2d_array(gpu::TextureFormat format, int2 extent, int layers, eGPUTextureUsage usage=GPU_TEXTURE_USAGE_GENERAL, const float *data=nullptr, int mip_len=1)
gpu::Texture * layer_view(int layer)