Blender V5.0
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.h"
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
27static void texture_evaluate(Tex *tex, const float value[3], float r_color[4])
28{
29 TexResult texres = {0.0f};
30
31 /* TODO(sergey): always use color management now. */
32 multitex_ext(tex, value, &texres, 0, nullptr, true, false);
33
34 copy_v3_v3(r_color, texres.trgba);
35 r_color[3] = texres.tin;
36}
37
38#else
39
41{
42 FunctionRNA *func;
43 PropertyRNA *parm;
44
45 func = RNA_def_function(srna, "evaluate", "texture_evaluate");
47 func, "Evaluate the texture at the given coordinate and returns the result");
48
50 func,
51 "value",
52 3,
53 nullptr,
54 -FLT_MAX,
55 FLT_MAX,
56 "The coordinates (x,y,z) of the texture, in case of a 3D texture, the z value is the slice "
57 "of the texture that is evaluated. For 2D textures such as images, the z value is ignored.",
58 "",
59 -1e4,
60 1e4);
62
63 /* return location and normal */
65 func,
66 "result",
67 4,
68 nullptr,
69 -FLT_MAX,
70 FLT_MAX,
71 "The result of the texture where (x,y,z,w) are (red, green, blue, intensity). "
72 "For grayscale textures, often intensity only will be used.",
73 nullptr,
74 -1e4,
75 1e4);
77 RNA_def_function_output(func, parm);
78}
79
80#endif
MINLINE void copy_v3_v3(float r[3], const float a[3])
ParameterFlag
Definition RNA_types.hh:544
@ PARM_REQUIRED
Definition RNA_types.hh:545
PropertyFlag
Definition RNA_types.hh:300
@ PROP_THICK_WRAP
Definition RNA_types.hh:423
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)
FunctionRNA * RNA_def_function(StructRNA *srna, const char *identifier, const char *call)
void RNA_def_function_ui_description(FunctionRNA *func, const char *description)
void RNA_def_function_output(FunctionRNA *, PropertyRNA *ret)
void RNA_def_parameter_flags(PropertyRNA *prop, PropertyFlag flag_property, ParameterFlag flag_parameter)
void RNA_api_texture(StructRNA *srna)
#define FLT_MAX
Definition stdcycles.h:14
float tin
Definition RE_texture.h:59
float trgba[4]
Definition RE_texture.h:60
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)