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