Blender  V3.3
rna_texture_api.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
7 #include <stdio.h>
8 #include <stdlib.h>
9 #include <string.h>
10 
11 #include "BLI_utildefines.h"
12 
13 #include "RNA_define.h"
14 
15 #include "rna_internal.h" /* own include */
16 
17 #ifdef RNA_RUNTIME
18 
19 # include "BKE_context.h"
20 # include "BKE_global.h"
21 # include "BLI_math.h"
22 # include "DNA_scene_types.h"
23 # include "IMB_imbuf.h"
24 # include "IMB_imbuf_types.h"
25 # include "RE_pipeline.h"
26 # include "RE_texture.h"
27 
28 static void texture_evaluate(struct Tex *tex, float value[3], float r_color[4])
29 {
30  TexResult texres = {0.0f};
31 
32  /* TODO(sergey): always use color management now. */
33  multitex_ext(tex, value, NULL, NULL, 1, &texres, 0, NULL, true, false);
34 
35  copy_v3_v3(r_color, texres.trgba);
36  r_color[3] = texres.tin;
37 }
38 
39 #else
40 
42 {
43  FunctionRNA *func;
44  PropertyRNA *parm;
45 
46  func = RNA_def_function(srna, "evaluate", "texture_evaluate");
48  func, "Evaluate the texture at the a given coordinate and returns the result");
49 
50  parm = RNA_def_float_vector(
51  func,
52  "value",
53  3,
54  NULL,
55  -FLT_MAX,
56  FLT_MAX,
57  "The coordinates (x,y,z) of the texture, in case of a 3D texture, the z value is the slice "
58  "of the texture that is evaluated. For 2D textures such as images, the z value is ignored",
59  "",
60  -1e4,
61  1e4);
63 
64  /* return location and normal */
65  parm = RNA_def_float_vector(
66  func,
67  "result",
68  4,
69  NULL,
70  -FLT_MAX,
71  FLT_MAX,
72  "The result of the texture where (x,y,z,w) are (red, green, blue, intensity). "
73  "For grayscale textures, often intensity only will be used",
74  NULL,
75  -1e4,
76  1e4);
78  RNA_def_function_output(func, parm);
79 }
80 
81 #endif
MINLINE void copy_v3_v3(float r[3], const float a[3])
Contains defines and structs used throughout the imbuf module.
@ PARM_REQUIRED
Definition: RNA_types.h:352
@ PROP_THICK_WRAP
Definition: RNA_types.h:285
FunctionRNA * RNA_def_function(StructRNA *srna, const char *identifier, const char *call)
Definition: rna_define.c:4273
void RNA_def_function_output(FunctionRNA *UNUSED(func), PropertyRNA *ret)
Definition: rna_define.c:4337
PropertyRNA * RNA_def_float_vector(StructOrFunctionRNA *cont_, const char *identifier, int len, const float *default_value, float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax)
Definition: rna_define.c:3862
void RNA_def_function_ui_description(FunctionRNA *func, const char *description)
Definition: rna_define.c:4347
void RNA_def_parameter_flags(PropertyRNA *prop, PropertyFlag flag_property, ParameterFlag flag_parameter)
Definition: rna_define.c:1518
void RNA_api_texture(StructRNA *srna)
float tin
Definition: RE_texture.h:86
float trgba[4]
Definition: RE_texture.h:87
int multitex_ext(Tex *tex, float texvec[3], float dxt[3], float dyt[3], int osatex, TexResult *texres, const short thread, struct ImagePool *pool, bool scene_color_manage, const bool skip_load_image)