Module: Gsplat::Backend::RubyAccumulate
- Defined in:
- lib/gsplat/backend/ruby/accumulate.rb
Overview
Brute-force Numo alpha compositor used as a rasterization reference.
Constant Summary collapse
- ALPHA_CLAMP =
0.999- ALPHA_SKIP =
1.0 / 255.0
- TRANSMITTANCE_STOP =
1e-4
Class Method Summary collapse
-
.forward(means2d, conics, opacities, colors, backgrounds, width, height) ⇒ Object
rubocop:disable Metrics/AbcSize, Metrics/ParameterLists.
Class Method Details
.forward(means2d, conics, opacities, colors, backgrounds, width, height) ⇒ Object
rubocop:disable Metrics/AbcSize, Metrics/ParameterLists
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/gsplat/backend/ruby/accumulate.rb', line 14 def forward(means2d, conics, opacities, colors, backgrounds, width, height) # rubocop:enable Metrics/ParameterLists inputs = validate_inputs(means2d, conics, opacities, colors, backgrounds, width, height) means2d, conics, opacities, colors, backgrounds = inputs camera_count, gaussian_count = means2d.shape[0...2] channel_count = colors.shape[-1] pixel_count = width * height pixels_x, pixels_y = pixel_coordinates(means2d.class, width, height) render_colors = means2d.class.zeros(camera_count, pixel_count, channel_count) render_alphas = means2d.class.zeros(camera_count, pixel_count) last_ids = Numo::Int32.zeros(camera_count, pixel_count) camera_count.times do |camera_index| composited, transmittance, camera_last_ids = composite_camera( means2d[camera_index, true, true], conics[camera_index, true, true], opacities[camera_index, true], colors[camera_index, true, true], pixels_x, pixels_y, gaussian_count ) if backgrounds composited += transmittance.reshape(pixel_count, 1) * backgrounds[camera_index, true].reshape(1, channel_count) end render_colors[camera_index, true, true] = composited render_alphas[camera_index, true] = 1 - transmittance last_ids[camera_index, true] = camera_last_ids + (camera_index * gaussian_count) end [ render_colors.reshape(camera_count, height, width, channel_count), render_alphas.reshape(camera_count, height, width, 1), last_ids.reshape(camera_count, height, width) ] end |