Module: Gsplat::RasterizationValidation
- Defined in:
- lib/gsplat/rasterization_validation.rb
Overview
Input and option validation for the high-level renderer.
Constant Summary collapse
- RENDER_MODES =
%w[RGB d Ed D ED RGB-d RGB-Ed RGB+D RGB+ED].freeze
- RASTERIZE_MODES =
%w[classic antialiased].freeze
Class Method Summary collapse
- .validate_eval3d!(with_eval3d, return_normals, covars, rasterize_mode) ⇒ Object
-
.validate_options!(render_mode, rasterize_mode, sh_degree, tile_size, channel_chunk, width, height) ⇒ Object
rubocop:disable Metrics/ParameterLists.
-
.validate_scene!(means, quats, scales, covars, opacities, colors, viewmats, intrinsics, sh_degree) ⇒ Object
rubocop:disable Metrics/ParameterLists.
- .warn_unsupported_options(packed, _global_z_order) ⇒ Object
Class Method Details
.validate_eval3d!(with_eval3d, return_normals, covars, rasterize_mode) ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/gsplat/rasterization_validation.rb', line 32 def validate_eval3d!(with_eval3d, return_normals, covars, rasterize_mode) raise ArgumentError, "return_normals requires with_eval3d: true" if return_normals && !with_eval3d raise ArgumentError, "with_eval3d requires quats and scales instead of covars" if with_eval3d && covars return unless with_eval3d && rasterize_mode != "classic" raise ArgumentError, "with_eval3d requires rasterize_mode: \"classic\"" end |
.validate_options!(render_mode, rasterize_mode, sh_degree, tile_size, channel_chunk, width, height) ⇒ Object
rubocop:disable Metrics/ParameterLists
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/gsplat/rasterization_validation.rb', line 12 def (render_mode, rasterize_mode, sh_degree, tile_size, channel_chunk, width, height) # rubocop:enable Metrics/ParameterLists raise ArgumentError, "unsupported render_mode #{render_mode.inspect}" unless RENDER_MODES.include?(render_mode) unless RASTERIZE_MODES.include?(rasterize_mode) raise ArgumentError, "unsupported rasterize_mode #{rasterize_mode.inspect}" end unless sh_degree.nil? || (0..4).cover?(sh_degree) raise ArgumentError, "sh_degree must be nil or an integer from 0 through 4" end values = { width: width, height: height, tile_size: tile_size, channel_chunk: channel_chunk } invalid = values.find { |_name, value| !value.is_a?(Integer) || !value.positive? } raise ArgumentError, "#{invalid[0]} must be a positive integer" if invalid end |
.validate_scene!(means, quats, scales, covars, opacities, colors, viewmats, intrinsics, sh_degree) ⇒ Object
rubocop:disable Metrics/ParameterLists
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/gsplat/rasterization_validation.rb', line 41 def validate_scene!(means, quats, scales, covars, opacities, colors, viewmats, intrinsics, sh_degree) # rubocop:enable Metrics/ParameterLists means_shape = data(means).shape unless means_shape.length == 2 && means_shape[-1] == 3 raise ShapeError, "expected means [N,3], got #{means_shape.inspect}" end gaussian_count = means_shape[0] opacity_shape = data(opacities).shape unless [[gaussian_count], [data(viewmats).shape[0], gaussian_count]].include?(opacity_shape) raise ShapeError, "expected opacities [N] or [C,N], got #{opacity_shape.inspect}" end validate_geometry!(quats, scales, covars, gaussian_count) camera_count = data(viewmats).shape[0] unless data(viewmats).shape == [camera_count, 4, 4] && data(intrinsics).shape == [camera_count, 3, 3] raise ShapeError, "expected viewmats [C,4,4] and ks [C,3,3], " \ "got #{data(viewmats).shape.inspect} and #{data(intrinsics).shape.inspect}" end validate_color_shape!(data(colors).shape, gaussian_count, camera_count, sh_degree) end |