Blender V5.3
RE_bake.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2010 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#pragma once
10
11#include "BLI_string_ref.hh"
12
13#include "DNA_scene_types.h"
14
15#include "RE_pipeline.h"
16
17namespace blender {
18
19struct Depsgraph;
20struct ImBuf;
21struct Mesh;
22struct Render;
23
24struct BakeImage {
25 struct Image *image;
27 float uv_offset[2];
28 int width;
29 int height;
30 size_t offset;
31
32 /* For associating render result layer with image. */
34};
35
37 /* All images of the object. */
40
41 /* Lookup table from Material number to BakeImage. */
44
45 /* Pixel buffer to bake to. */
46 float *result;
49
50 /* Baking to non-color data image. */
52};
53
54struct BakePixel {
56 int seed;
57 float uv[2];
58 float du_dx, du_dy;
59 float dv_dx, dv_dy;
60 /* Is a margin pixel used to improve denoise quality and is not copied into final image. */
62};
63
65 struct Object *ob;
66 struct Object *ob_eval;
67 struct Mesh *mesh;
69
70 float obmat[4][4];
71 float imat[4][4];
72};
73
74/* `external_engine.cc` */
75
76bool RE_bake_has_engine(const struct Render *re);
77
78bool RE_bake_engine(struct Render *re,
79 struct Depsgraph *depsgraph,
80 struct Object *object,
81 int object_id,
82 const BakePixel pixel_array[],
83 const BakeTargets *targets,
84 eScenePassType pass_type,
85 int pass_filter,
86 float result[]);
87
88/* `bake.cc` */
89
90int RE_pass_depth(eScenePassType pass_type);
91
93 BakePixel pixel_array_from[],
94 BakePixel pixel_array_to[],
95 BakeHighPolyData highpoly[],
96 int highpoly_num,
97 size_t pixels_num,
98 bool is_custom_cage,
99 float cage_extrusion,
100 float max_ray_distance,
101 const float mat_low[4][4],
102 const float mat_cage[4][4],
103 struct Mesh *me_cage);
104
106 struct BakePixel *pixel_array,
107 size_t pixels_num,
108 const struct BakeTargets *targets,
109 StringRef uv_layer,
110 int margin);
111
112void RE_bake_mask_fill(const BakePixel pixel_array[], size_t pixels_num, char *mask);
113
114void RE_bake_margin(struct ImBuf *ibuf,
115 char *mask,
116 int margin,
117 char margin_type,
118 const Mesh *mesh,
119 StringRef uv_layer,
120 const float uv_offset[2]);
121
122void RE_bake_normal_world_to_object(const BakePixel pixel_array[],
123 size_t pixels_num,
124 int depth,
125 float result[],
126 struct Object *ob,
127 const eBakeNormalSwizzle normal_swizzle[3]);
132void RE_bake_normal_world_to_tangent(const BakePixel pixel_array[],
133 size_t pixels_num,
134 int depth,
135 float result[],
136 struct Mesh *mesh,
137 const eBakeNormalSwizzle normal_swizzle[3],
138 const float mat[4][4]);
139void RE_bake_normal_world_to_world(const BakePixel pixel_array[],
140 size_t pixels_num,
141 int depth,
142 float result[],
143 const eBakeNormalSwizzle normal_swizzle[3]);
144
145void RE_bake_ibuf_clear(struct Image *image, bool is_tangent);
146
147} // namespace blender
#define RE_MAXNAME
Definition RE_pipeline.h:42
BMesh Iterators.
void RE_bake_ibuf_clear(Image *image, const bool is_tangent)
Definition bake.cc:1102
constexpr float max_ray_distance
int RE_pass_depth(const eScenePassType pass_type)
Definition bake.cc:1127
bool RE_bake_has_engine(const Render *re)
bool RE_bake_pixels_populate_from_objects(Mesh *me_low, BakePixel pixel_array_from[], BakePixel pixel_array_to[], BakeHighPolyData highpoly[], const int highpoly_num, const size_t pixels_num, const bool is_custom_cage, const float cage_extrusion, const float max_ray_distance, const float mat_low[4][4], const float mat_cage[4][4], Mesh *me_cage)
Definition bake.cc:542
void RE_bake_pixels_populate(Mesh *mesh, BakePixel pixel_array[], const size_t pixels_num, const BakeTargets *targets, const StringRef uv_layer, int margin)
Definition bake.cc:766
void RE_bake_normal_world_to_tangent(const BakePixel pixel_array[], const size_t pixels_num, const int depth, float result[], Mesh *mesh, const eBakeNormalSwizzle normal_swizzle[3], const float mat[4][4])
Definition bake.cc:921
void RE_bake_normal_world_to_object(const BakePixel pixel_array[], const size_t pixels_num, const int depth, float result[], Object *ob, const eBakeNormalSwizzle normal_swizzle[3])
Definition bake.cc:1046
void RE_bake_mask_fill(const BakePixel pixel_array[], const size_t pixels_num, char *mask)
Definition bake.cc:128
bool RE_bake_engine(Render *re, Depsgraph *depsgraph, Object *object, const int object_id, const BakePixel pixel_array[], const BakeTargets *targets, const eScenePassType pass_type, const int pass_filter, float result[])
void RE_bake_normal_world_to_world(const BakePixel pixel_array[], const size_t pixels_num, const int depth, float result[], const eBakeNormalSwizzle normal_swizzle[3])
Definition bake.cc:1078
void RE_bake_margin(ImBuf *ibuf, char *mask, const int margin, const char margin_type, const Mesh *mesh, const StringRef uv_layer, const float uv_offset[2])
Definition bake.cc:145
struct Object * ob
Definition RE_bake.h:65
struct Object * ob_eval
Definition RE_bake.h:66
struct Mesh * mesh
Definition RE_bake.h:67
char render_layer_name[RE_MAXNAME]
Definition RE_bake.h:33
float uv_offset[2]
Definition RE_bake.h:27
struct Image * image
Definition RE_bake.h:25
struct Image ** material_to_image
Definition RE_bake.h:42
BakeImage * images
Definition RE_bake.h:38