Lagrange
Loading...
Searching...
No Matches
TextureRasterizer.h
1/*
2 * Copyright 2025 Adobe. All rights reserved.
3 * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License. You may obtain a copy
5 * of the License at http://www.apache.org/licenses/LICENSE-2.0
6 *
7 * Unless required by applicable law or agreed to in writing, software distributed under
8 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9 * OF ANY KIND, either express or implied. See the License for the specific language
10 * governing permissions and limitations under the License.
11 */
12#pragma once
13
14#include <lagrange/SurfaceMesh.h>
15#include <lagrange/image/Array3D.h>
16#include <lagrange/image/View3D.h>
17
18#include <Eigen/Geometry>
19
20namespace lagrange::texproc {
21
24
29{
31 Eigen::Affine3f view_transform = Eigen::Affine3f::Identity();
32
37 Eigen::Projective3f projection_transform = Eigen::Projective3f::Identity();
38};
39
44{
47
50
55 double depth_precision = 1e-3;
56
58 size_t width = 1024;
59
61 size_t height = 1024;
62};
63
70template <typename Scalar, typename Index>
72{
73public:
74 using Array3Df = image::experimental::Array3D<float>;
75
76public:
85 const TextureRasterizerOptions& options);
86
91
100 std::pair<Array3Df, Array3Df> weighted_texture_from_render(
101 image::experimental::View3D<const float> image,
102 const CameraOptions& options) const;
103
104private:
106
107 struct Impl;
108 value_ptr<Impl> m_impl;
109
111};
112
120 span<std::pair<image::experimental::Array3D<float>, image::experimental::Array3D<float>>>
121 textures_and_weights,
122 float low_ratio_threshold);
123
125
126} // namespace lagrange::texproc
A general purpose polygonal mesh class.
Definition SurfaceMesh.h:66
TextureRasterizer(const SurfaceMesh< Scalar, Index > &mesh, const TextureRasterizerOptions &options)
Construct a new instance of the rasterizer.
std::pair< Array3Df, Array3Df > weighted_texture_from_render(image::experimental::View3D< const float > image, const CameraOptions &options) const
Unproject a rendered image into a UV texture and confidence map.
Smart pointer with value semantics.
Definition value_ptr.h:134
::nonstd::span< T, Extent > span
A bounds-safe view for sequences of objects.
Definition span.h:27
void filter_low_confidences(span< std::pair< image::experimental::Array3D< float >, image::experimental::Array3D< float > > > textures_and_weights, float low_ratio_threshold)
Discard low-confidence values.
Basic image data structure.
Parameters for computing the rendering of a mesh.
Definition TextureRasterizer.h:29
Eigen::Projective3f projection_transform
Camera projection transform (view space -> NDC space).
Definition TextureRasterizer.h:37
Eigen::Affine3f view_transform
Camera view transform (world space -> view space).
Definition TextureRasterizer.h:31
Options for computing the texture map and confidence from a rendering.
Definition TextureRasterizer.h:44
size_t height
Texture height.
Definition TextureRasterizer.h:61
size_t width
Texture width.
Definition TextureRasterizer.h:58
double depth_precision
Depth precision (for determining visibility).
Definition TextureRasterizer.h:55
double depth_discontinuity_threshold
Depth discontinuity threshold (in view space).
Definition TextureRasterizer.h:49
unsigned int depth_discontinuity_erosion_radius
Erosion radius (in texels).
Definition TextureRasterizer.h:46