Blender  V3.3
RE_bake.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2010 Blender Foundation. All rights reserved. */
3 
8 #pragma once
9 
10 #include "RE_pipeline.h"
11 
12 struct Depsgraph;
13 struct ImBuf;
14 struct MLoopUV;
15 struct Mesh;
16 struct Render;
17 
18 #ifdef __cplusplus
19 extern "C" {
20 #endif
21 
22 typedef struct BakeImage {
23  struct Image *image;
25  float uv_offset[2];
26  int width;
27  int height;
28  size_t offset;
29 
30  /* For associating render result layer with image. */
33 
34 typedef struct BakeTargets {
35  /* All images of the object. */
38 
39  /* Lookup table from Material number to BakeImage. */
42 
43  /* Pixel buffer to bake to. */
44  float *result;
47 
48  /* Baking to non-color data image. */
51 
52 typedef struct BakePixel {
54  int seed;
55  float uv[2];
56  float du_dx, du_dy;
57  float dv_dx, dv_dy;
59 
60 typedef struct BakeHighPolyData {
61  struct Object *ob;
62  struct Object *ob_eval;
63  struct Mesh *me;
65 
66  float obmat[4][4];
67  float imat[4][4];
69 
70 /* external_engine.c */
71 
72 bool RE_bake_has_engine(const struct Render *re);
73 
74 bool RE_bake_engine(struct Render *re,
75  struct Depsgraph *depsgraph,
76  struct Object *object,
77  int object_id,
78  const BakePixel pixel_array[],
79  const BakeTargets *targets,
80  eScenePassType pass_type,
81  int pass_filter,
82  float result[]);
83 
84 /* bake.c */
85 
86 int RE_pass_depth(eScenePassType pass_type);
87 
88 bool RE_bake_pixels_populate_from_objects(struct Mesh *me_low,
89  BakePixel pixel_array_from[],
90  BakePixel pixel_array_to[],
91  BakeHighPolyData highpoly[],
92  int tot_highpoly,
93  size_t pixels_num,
94  bool is_custom_cage,
95  float cage_extrusion,
96  float max_ray_distance,
97  float mat_low[4][4],
98  float mat_cage[4][4],
99  struct Mesh *me_cage);
100 
102  struct BakePixel *pixel_array,
103  size_t pixels_num,
104  const struct BakeTargets *targets,
105  const char *uv_layer);
106 
107 void RE_bake_mask_fill(const BakePixel pixel_array[], size_t pixels_num, char *mask);
108 
109 void RE_bake_margin(struct ImBuf *ibuf,
110  char *mask,
111  int margin,
112  char margin_type,
113  struct Mesh const *me,
114  char const *uv_layer,
115  const float uv_offset[2]);
116 
117 void RE_bake_normal_world_to_object(const BakePixel pixel_array[],
118  size_t pixels_num,
119  int depth,
120  float result[],
121  struct Object *ob,
122  const eBakeNormalSwizzle normal_swizzle[3]);
127 void RE_bake_normal_world_to_tangent(const BakePixel pixel_array[],
128  size_t pixels_num,
129  int depth,
130  float result[],
131  struct Mesh *me,
132  const eBakeNormalSwizzle normal_swizzle[3],
133  float mat[4][4]);
134 void RE_bake_normal_world_to_world(const BakePixel pixel_array[],
135  size_t pixels_num,
136  int depth,
137  float result[],
138  const eBakeNormalSwizzle normal_swizzle[3]);
139 
140 void RE_bake_ibuf_clear(struct Image *image, bool is_tangent);
141 
142 #ifdef __cplusplus
143 }
144 #endif
struct Depsgraph Depsgraph
Definition: DEG_depsgraph.h:35
eBakeNormalSwizzle
eScenePassType
void RE_bake_normal_world_to_tangent(const BakePixel pixel_array[], size_t pixels_num, int depth, float result[], struct Mesh *me, const eBakeNormalSwizzle normal_swizzle[3], float mat[4][4])
Definition: bake.c:831
struct BakeHighPolyData BakeHighPolyData
void RE_bake_margin(struct ImBuf *ibuf, char *mask, int margin, char margin_type, struct Mesh const *me, char const *uv_layer, const float uv_offset[2])
void RE_bake_normal_world_to_object(const BakePixel pixel_array[], size_t pixels_num, int depth, float result[], struct Object *ob, const eBakeNormalSwizzle normal_swizzle[3])
Definition: bake.c:956
bool RE_bake_has_engine(const struct Render *re)
struct BakePixel BakePixel
struct BakeTargets BakeTargets
bool RE_bake_engine(struct Render *re, struct Depsgraph *depsgraph, struct Object *object, int object_id, const BakePixel pixel_array[], const BakeTargets *targets, eScenePassType pass_type, int pass_filter, float result[])
Definition: engine.c:819
void RE_bake_mask_fill(const BakePixel pixel_array[], size_t pixels_num, char *mask)
Definition: bake.c:129
struct BakeImage BakeImage
int RE_pass_depth(eScenePassType pass_type)
Definition: bake.c:1037
bool RE_bake_pixels_populate_from_objects(struct Mesh *me_low, BakePixel pixel_array_from[], BakePixel pixel_array_to[], BakeHighPolyData highpoly[], int tot_highpoly, size_t pixels_num, bool is_custom_cage, float cage_extrusion, float max_ray_distance, float mat_low[4][4], float mat_cage[4][4], struct Mesh *me_cage)
Definition: bake.c:535
void RE_bake_pixels_populate(struct Mesh *me, struct BakePixel *pixel_array, size_t pixels_num, const struct BakeTargets *targets, const char *uv_layer)
void RE_bake_ibuf_clear(struct Image *image, bool is_tangent)
Definition: bake.c:1012
void RE_bake_normal_world_to_world(const BakePixel pixel_array[], size_t pixels_num, int depth, float result[], const eBakeNormalSwizzle normal_swizzle[3])
Definition: bake.c:988
#define RE_MAXNAME
Definition: RE_pipeline.h:36
const Depsgraph * depsgraph
depth_tx normal_tx diffuse_light_tx specular_light_tx volume_light_tx environment_tx ambient_occlusion_tx aov_value_tx in_weight_img image(1, GPU_R32F, Qualifier::WRITE, ImageType::FLOAT_2D_ARRAY, "out_weight_img") .image(3
ccl_device_inline float4 mask(const int4 &mask, const float4 &a)
Definition: math_float4.h:513
struct Mesh * me
Definition: RE_bake.h:63
struct Object * ob
Definition: RE_bake.h:61
float imat[4][4]
Definition: RE_bake.h:67
struct Object * ob_eval
Definition: RE_bake.h:62
float obmat[4][4]
Definition: RE_bake.h:66
bool is_flip_object
Definition: RE_bake.h:64
int height
Definition: RE_bake.h:27
char render_layer_name[RE_MAXNAME]
Definition: RE_bake.h:31
int tile_number
Definition: RE_bake.h:24
size_t offset
Definition: RE_bake.h:28
struct Image * image
Definition: RE_bake.h:23
float uv_offset[2]
Definition: RE_bake.h:25
int width
Definition: RE_bake.h:26
float dv_dx
Definition: RE_bake.h:57
float du_dx
Definition: RE_bake.h:56
int seed
Definition: RE_bake.h:54
float du_dy
Definition: RE_bake.h:56
float uv[2]
Definition: RE_bake.h:55
float dv_dy
Definition: RE_bake.h:57
int object_id
Definition: RE_bake.h:53
int primitive_id
Definition: RE_bake.h:53
struct Image ** material_to_image
Definition: RE_bake.h:40
float * result
Definition: RE_bake.h:44
bool is_noncolor
Definition: RE_bake.h:49
int pixels_num
Definition: RE_bake.h:45
int materials_num
Definition: RE_bake.h:41
int channels_num
Definition: RE_bake.h:46
int images_num
Definition: RE_bake.h:37
BakeImage * images
Definition: RE_bake.h:36
struct Material ** mat