OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
TextureDisplacement.hpp File Reference
#include <cmath>
#include <cstddef>
#include <Eigen/Core>
#include <cstdint>
#include <functional>
#include <memory>
#include <string>
#include <utility>
#include <vector>
#include <cereal/cereal.hpp>
#include <cereal/types/array.hpp>
#include <cereal/types/string.hpp>
#include <cereal/types/vector.hpp>
#include <array>
#include "Point.hpp"
#include "TriangleSelector.hpp"
Include dependency graph for TextureDisplacement.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  Slic3r::TextureIsland
struct  Slic3r::TextureAdjustments
struct  Slic3r::TextureDisplacementLayer
struct  Slic3r::TextureDisplacementOptions
struct  Slic3r::TextureDetail
struct  Slic3r::V2Resolution
struct  Slic3r::DecodedHeightTexture
struct  Slic3r::DecodedHeightTexture::TexelTap
struct  Slic3r::PrintableColor
struct  Slic3r::TextureColorSettings
struct  Slic3r::PatchUnwrap
struct  Slic3r::TextureColorRequest
struct  Slic3r::TextureBakeStats
struct  Slic3r::TextureDisplacementPrepareParams
struct  Slic3r::TextureDisplacementPrepareResult

Namespaces

namespace  Slic3r
 |/ Copyright (c) Prusa Research 2020 - 2023 Enrico Turri @enricoturri1966 |/ |/ PrusaSlicer is released under the terms of the AGPLv3 or higher |/

Typedefs

using Slic3r::DisplacementProgressFn = std::function<bool(int)>
using Slic3r::ColorQuantizeFn = std::function<int(const Vec3f &)>
using Slic3r::TextureDisplacementFacetsData = std::array<TriangleSelector::TriangleSplittingData, TEXTURE_DISPLACEMENT_MAX_LAYERS>
using Slic3r::HeightFieldSampler = std::function<float(const Vec3f &pos, const Vec3f &normal)>
using Slic3r::ColorFieldSampler = std::function<int(const Vec3f &pos, const Vec3f &normal)>

Enumerations

enum class  Slic3r::TextureTileMethod : int { Slic3r::Repeat = 0 , Slic3r::MirroredRepeat = 1 }
enum class  Slic3r::TextureProjectionMethod : int {
  Slic3r::Triplanar = 0 , Slic3r::Cylindrical = 1 , Slic3r::Spherical = 2 , Slic3r::LSCM = 3 ,
  Slic3r::ViewProjected = 4 , Slic3r::ModelUV = 5
}
enum class  Slic3r::TextureBlendMode : int {
  Slic3r::Add = 0 , Slic3r::Subtract = 1 , Slic3r::Multiply = 2 , Slic3r::Divide = 3 ,
  Slic3r::Override = 4
}

Functions

float Slic3r::blend_displacement (float accumulated, float value, TextureBlendMode mode)
void Slic3r::average_island_scales (std::vector< TextureIsland > &islands)
std::string Slic3r::texture_displacement_layers_to_json (const std::vector< TextureDisplacementLayer > &layers, const TextureDisplacementOptions &options)
bool Slic3r::texture_displacement_layers_from_json (const std::string &text, std::vector< TextureDisplacementLayer > &layers, TextureDisplacementOptions &options)
TextureDetail Slic3r::analyze_texture_detail (const TextureDisplacementLayer &layer)
V2Resolution Slic3r::recommend_v2_resolution (const indexed_triangle_set &mesh, const std::vector< TextureDisplacementLayer > &layers, const Transform3d &volume_to_world)
DecodedHeightTexture Slic3r::apply_texture_adjustments (const DecodedHeightTexture &src, const TextureAdjustments &adj)
float Slic3r::adjustment_blur_radius (float blur, int width, int height)
DecodedHeightTexture Slic3r::downscale_height_texture (const DecodedHeightTexture &src, int max_px)
DecodedHeightTexture Slic3r::decode_height_texture (const TextureDisplacementLayer &layer, bool keep_decoded)
bool Slic3r::height_texture_has_color (const TextureDisplacementLayer &layer)
void Slic3r::box_projection_axes (const Vec3f &normal, Vec3f &u_axis, Vec3f &v_axis)
Vec2f Slic3r::project_planar (const Vec3f &position, const Vec3f &normal)
Vec2f Slic3r::apply_uv_transform (const Vec2f &planar, const TextureDisplacementLayer &layer, float aspect, bool normalized_uv)
bool Slic3r::project_uv_projective (const std::array< float, 12 > &m, const Vec3f &position, Vec2f &uv)
float Slic3r::sample_layer_height (const DecodedHeightTexture &texture, const TextureDisplacementLayer &layer, const Vec3f &position, const Vec3f &normal, const Vec3f &patch_center, const Vec3f &patch_axis, const Vec2f *lscm_uv)
bool Slic3r::sample_layer_color (const DecodedHeightTexture &texture, const TextureDisplacementLayer &layer, const Vec3f &position, const Vec3f &normal, Vec3f &out, const Vec3f &patch_center, const Vec3f &patch_axis, const Vec2f *lscm_uv)
std::vector< uint8_t > Slic3r::transfer_facet_paint (const indexed_triangle_set &src_mesh, const TriangleSelector::TriangleSplittingData &src_paint, const indexed_triangle_set &dst_mesh)
bool Slic3r::compute_layer_paint_anchor (const indexed_triangle_set &base_mesh, const TriangleSelector::TriangleSplittingData &facet_data, Vec3f &anchor_pos, Vec3f &anchor_normal)
indexed_triangle_set Slic3r::extract_painted_patch (const indexed_triangle_set &base_mesh, const TriangleSelector::TriangleSplittingData &facet_data)
Vec2f Slic3r::apply_island_transform (const Vec2f &uv, int chart, const PatchUnwrap &unwrap, const std::vector< TextureIsland > &islands)
Eigen::Matrix< float, 2, 3 > Slic3r::island_transform_matrix (int chart, const PatchUnwrap &unwrap, const std::vector< TextureIsland > &islands)
std::vector< TextureIsland > Slic3r::compute_connected_net (const PatchUnwrap &unwrap)
bool Slic3r::join_chart_placement (const PatchUnwrap &unwrap, const std::vector< TextureIsland > &islands, int child, int parent, TextureIsland &out_child)
PatchUnwrap Slic3r::compute_patch_unwrap (const indexed_triangle_set &patch, float seam_angle_deg, float padding_mm, const std::vector< std::pair< int, int > > &seam_edges)
std::vector< Vec2f > Slic3r::compute_lscm_uvs (const indexed_triangle_set &patch, const TextureDisplacementLayer &layer)
std::vector< Vec2f > Slic3r::compute_lscm_corner_uvs (const indexed_triangle_set &patch, const TextureDisplacementLayer &layer)
std::vector< Vec2f > Slic3r::compute_model_corner_uvs (const indexed_triangle_set &base_mesh, const std::vector< Vec2f > &model_uv, const indexed_triangle_set &patch, const std::vector< int > &patch_source)
std::vector< Vec2f > Slic3r::collapse_corner_uvs (const indexed_triangle_set &patch, const std::vector< Vec2f > &corner)
std::vector< Vec2f > Slic3r::transfer_uv_channel (const indexed_triangle_set &src_mesh, const std::vector< Vec2f > &src_uv, const indexed_triangle_set &dst_mesh, float max_distance)
int Slic3r::lscm_uv_override_key (int unwrapped_vertex)
std::vector< bool > Slic3r::apply_lscm_uv_overrides (PatchUnwrap &unwrap, const std::vector< std::pair< int, Vec2f > > &overrides)
void Slic3r::merge_small_color_regions (const indexed_triangle_set &mesh, std::vector< int > &color, float min_area_mm2)
indexed_triangle_set Slic3r::build_texture_displacement (const indexed_triangle_set &base_mesh, const std::vector< TextureDisplacementLayer > &layers, const TextureDisplacementFacetsData &facets_data, const TextureDisplacementOptions &options, const DisplacementProgressFn &progress, const TextureColorRequest *color, const Transform3d &volume_to_world, BakeStageRecorder *debug, TextureBakeStats *stats, const std::vector< Vec2f > *model_uv, const Vec3d *texture_anchor, float resting_drop)
Transform3d Slic3r::texture_displacement_volume_to_world (const ModelVolume &volume)
Transform3d Slic3r::texture_displacement_bake_frame (const Transform3d &volume_to_world, const Vec3d &anchor)
Transform3d Slic3r::texture_displacement_bake_frame (const Transform3d &volume_to_world)
std::vector< Vec3f > Slic3r::texture_displacement_vertex_normals (const indexed_triangle_set &its)
void Slic3r::texture_displacement_patch_frame (const indexed_triangle_set &patch, const std::vector< Vec3f > &vertex_normals, Vec3f &center, Vec3f &axis, Vec3f &average_normal)
indexed_triangle_set Slic3r::build_texture_displacement (const ModelVolume &volume)
void Slic3r::smooth_mesh_vertices (indexed_triangle_set &mesh, const std::vector< uint8_t > &movable, float strength, int iterations, const DisplacementProgressFn &on_pass)
ColorFieldSampler Slic3r::make_combined_color_sampler (const indexed_triangle_set &base_mesh, const std::vector< TextureDisplacementLayer > &layers, const TextureDisplacementFacetsData &facets_data, ColorQuantizeFn quantize, ColorQuantizeFn quantize_pure, const std::vector< Vec2f > *model_uv)
HeightFieldSampler Slic3r::make_combined_displacement_sampler (const indexed_triangle_set &base_mesh, const std::vector< TextureDisplacementLayer > &layers, const TextureDisplacementFacetsData &facets_data, const std::vector< Vec2f > *model_uv)
indexed_triangle_set Slic3r::subdivide_mesh_uniform (const indexed_triangle_set &mesh, float max_edge_length_mm, int max_iterations)
indexed_triangle_set Slic3r::subdivide_mesh_adaptive (const indexed_triangle_set &mesh, const std::vector< uint8_t > &refine_region, float target_edge_length_mm, int max_triangles, std::vector< int > *out_source, const HeightFieldSampler &sampler, float chord_tolerance_mm, float min_edge_length_mm, float border_edge_length_mm, const DisplacementProgressFn &progress, const ColorFieldSampler &color, float color_edge_length_mm, bool split_multi_crossings)
indexed_triangle_set Slic3r::cut_mesh_at_steps (const indexed_triangle_set &mesh, const std::vector< uint8_t > &region, const HeightFieldSampler &sampler, float step_width_mm, float seam_gap_mm, float min_feature_mm, std::vector< int > *out_source, size_t *out_cut_count)
bool Slic3r::texture_has_steps_to_cut (const indexed_triangle_set &mesh, const std::vector< uint8_t > &region, const HeightFieldSampler &sampler, float step_width_mm, float seam_gap_mm, float min_feature_mm)

Variables

static constexpr uint8_t Slic3r::REFINE_PAINTED = 1
static constexpr uint8_t Slic3r::REFINE_BORDER = 2
static constexpr size_t Slic3r::TEXTURE_DISPLACEMENT_MAX_LAYERS = 8
static constexpr float Slic3r::LSCM_DEFAULT_SEAM_ANGLE_DEG = 30.f
static constexpr float Slic3r::TRIPLANAR_BLEND_SHARPNESS = 4.f

Class Documentation

◆ Slic3r::TextureDetail

struct Slic3r::TextureDetail
Class Members
bool flat_colors = false
float flat_share = 0.f
float mean_gradient = 0.f
float pixels_per_edge = 4.f
float sharp_fraction = 0.f

◆ Slic3r::V2Resolution

struct Slic3r::V2Resolution
Class Members
bool budget_bound = false
int budget_k = 0
float edge_mm = 0.f
float pixels_per_edge = 0.f
float texel_mm = 0.f

◆ Slic3r::DecodedHeightTexture::TexelTap

struct Slic3r::DecodedHeightTexture::TexelTap
Class Members
float tx = 0.f
float ty = 0.f
int x0 = 0
int x1 = 0
int y0 = 0
int y1 = 0

◆ Slic3r::TextureColorRequest

struct Slic3r::TextureColorRequest
Collaboration diagram for Slic3r::TextureColorRequest:
Class Members
int despeckle_passes = 0
float min_color_region_mm2 = 0.5f
vector< uint8_t > * out_triangle = nullptr
ColorQuantizeFn quantize
ColorQuantizeFn quantize_pure

◆ Slic3r::TextureBakeStats

struct Slic3r::TextureBakeStats
Class Members
bool budget_limited = false
size_t triangles_budget = 0
size_t triangles_refined = 0

◆ Slic3r::TextureDisplacementPrepareParams

struct Slic3r::TextureDisplacementPrepareParams
Class Members
bool cut_steps = false
float remesh_edge_mm = 0.f
float remesh_sharp_deg = 0.f
int subdiv_added_triangles = 0
float subdiv_border_mm = 0.f
float subdiv_color_edge_mm = 0.f
float subdiv_detail_mm = 0.f
bool subdiv_feature = false
float subdiv_min_edge_mm = 0.f
float subdiv_target_mm = 0.f

◆ Slic3r::TextureDisplacementPrepareResult

struct Slic3r::TextureDisplacementPrepareResult
Collaboration diagram for Slic3r::TextureDisplacementPrepareResult:
Class Members
TextureDisplacementFacetsData masks
indexed_triangle_set mesh
bool paint_lost = false
vector< Vec2f > uv