Blender  V2.93
RE_bake.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2010 Blender Foundation.
17  * All rights reserved.
18  */
19 
24 #pragma once
25 
26 struct Depsgraph;
27 struct ImBuf;
28 struct Mesh;
29 struct Render;
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
35 typedef struct BakeImage {
36  struct Image *image;
37  int width;
38  int height;
39  size_t offset;
41 
42 typedef struct BakeTargets {
43  /* All images of the object. */
46 
47  /* Lookup table from Material number to BakeImage. */
50 
51  /* Pixel buffer to bake to. */
52  float *result;
55 
56  /* Baking to non-color data image. */
59 
60 typedef struct BakePixel {
62  int seed;
63  float uv[2];
64  float du_dx, du_dy;
65  float dv_dx, dv_dy;
67 
68 typedef struct BakeHighPolyData {
69  struct Object *ob;
70  struct Object *ob_eval;
71  struct Mesh *me;
73 
74  float obmat[4][4];
75  float imat[4][4];
77 
78 /* external_engine.c */
79 bool RE_bake_has_engine(struct Render *re);
80 
81 bool RE_bake_engine(struct Render *re,
82  struct Depsgraph *depsgraph,
83  struct Object *object,
84  const int object_id,
85  const BakePixel pixel_array[],
86  const BakeTargets *targets,
87  const eScenePassType pass_type,
88  const int pass_filter,
89  float result[]);
90 
91 /* bake.c */
92 int RE_pass_depth(const eScenePassType pass_type);
93 
94 bool RE_bake_pixels_populate_from_objects(struct Mesh *me_low,
95  BakePixel pixel_array_from[],
96  BakePixel pixel_array_to[],
97  BakeHighPolyData highpoly[],
98  const int tot_highpoly,
99  const size_t num_pixels,
100  const bool is_custom_cage,
101  const float cage_extrusion,
102  const float max_ray_distance,
103  float mat_low[4][4],
104  float mat_cage[4][4],
105  struct Mesh *me_cage);
106 
108  struct BakePixel *pixel_array,
109  const size_t num_pixels,
110  const struct BakeTargets *targets,
111  const char *uv_layer);
112 
113 void RE_bake_mask_fill(const BakePixel pixel_array[], const size_t num_pixels, char *mask);
114 
115 void RE_bake_margin(struct ImBuf *ibuf, char *mask, const int margin);
116 
117 void RE_bake_normal_world_to_object(const BakePixel pixel_array[],
118  const size_t num_pixels,
119  const int depth,
120  float result[],
121  struct Object *ob,
122  const eBakeNormalSwizzle normal_swizzle[3]);
123 void RE_bake_normal_world_to_tangent(const BakePixel pixel_array[],
124  const size_t num_pixels,
125  const int depth,
126  float result[],
127  struct Mesh *me,
128  const eBakeNormalSwizzle normal_swizzle[3],
129  float mat[4][4]);
130 void RE_bake_normal_world_to_world(const BakePixel pixel_array[],
131  const size_t num_pixels,
132  const int depth,
133  float result[],
134  const eBakeNormalSwizzle normal_swizzle[3]);
135 
136 void RE_bake_ibuf_clear(struct Image *image, const bool is_tangent);
137 
138 #ifdef __cplusplus
139 }
140 #endif
struct Depsgraph Depsgraph
Definition: DEG_depsgraph.h:51
eBakeNormalSwizzle
eScenePassType
bool RE_bake_engine(struct Render *re, struct Depsgraph *depsgraph, struct Object *object, const int object_id, const BakePixel pixel_array[], const BakeTargets *targets, const eScenePassType pass_type, const int pass_filter, float result[])
Definition: engine.c:744
bool RE_bake_pixels_populate_from_objects(struct Mesh *me_low, BakePixel pixel_array_from[], BakePixel pixel_array_to[], BakeHighPolyData highpoly[], const int tot_highpoly, const size_t num_pixels, const bool is_custom_cage, const float cage_extrusion, const float max_ray_distance, float mat_low[4][4], float mat_cage[4][4], struct Mesh *me_cage)
Definition: bake.c:523
void RE_bake_normal_world_to_world(const BakePixel pixel_array[], const size_t num_pixels, const int depth, float result[], const eBakeNormalSwizzle normal_swizzle[3])
Definition: bake.c:984
struct BakeHighPolyData BakeHighPolyData
void RE_bake_normal_world_to_object(const BakePixel pixel_array[], const size_t num_pixels, const int depth, float result[], struct Object *ob, const eBakeNormalSwizzle normal_swizzle[3])
Definition: bake.c:952
bool RE_bake_has_engine(struct Render *re)
Definition: engine.c:738
struct BakePixel BakePixel
void RE_bake_normal_world_to_tangent(const BakePixel pixel_array[], const size_t num_pixels, const int depth, float result[], struct Mesh *me, const eBakeNormalSwizzle normal_swizzle[3], float mat[4][4])
Definition: bake.c:827
int RE_pass_depth(const eScenePassType pass_type)
Definition: bake.c:1033
void RE_bake_ibuf_clear(struct Image *image, const bool is_tangent)
Definition: bake.c:1008
struct BakeTargets BakeTargets
void RE_bake_pixels_populate(struct Mesh *me, struct BakePixel *pixel_array, const size_t num_pixels, const struct BakeTargets *targets, const char *uv_layer)
struct BakeImage BakeImage
void RE_bake_margin(struct ImBuf *ibuf, char *mask, const int margin)
Definition: bake.c:156
void RE_bake_mask_fill(const BakePixel pixel_array[], const size_t num_pixels, char *mask)
Definition: bake.c:141
const Depsgraph * depsgraph
struct Mesh * me
Definition: RE_bake.h:71
struct Object * ob
Definition: RE_bake.h:69
float imat[4][4]
Definition: RE_bake.h:75
struct Object * ob_eval
Definition: RE_bake.h:70
float obmat[4][4]
Definition: RE_bake.h:74
bool is_flip_object
Definition: RE_bake.h:72
int height
Definition: RE_bake.h:38
size_t offset
Definition: RE_bake.h:39
struct Image * image
Definition: RE_bake.h:36
int width
Definition: RE_bake.h:37
float dv_dx
Definition: RE_bake.h:65
float du_dx
Definition: RE_bake.h:64
int seed
Definition: RE_bake.h:62
float du_dy
Definition: RE_bake.h:64
float uv[2]
Definition: RE_bake.h:63
float dv_dy
Definition: RE_bake.h:65
int object_id
Definition: RE_bake.h:61
int primitive_id
Definition: RE_bake.h:61
int * material_to_image
Definition: RE_bake.h:48
float * result
Definition: RE_bake.h:52
bool is_noncolor
Definition: RE_bake.h:57
int num_images
Definition: RE_bake.h:45
int num_materials
Definition: RE_bake.h:49
int num_channels
Definition: RE_bake.h:54
int num_pixels
Definition: RE_bake.h:53
BakeImage * images
Definition: RE_bake.h:44
struct Material ** mat
ccl_device_inline float4 mask(const int4 &mask, const float4 &a)