Blender V4.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
9#include <cstdio>
10#include <cstdlib>
11#include <cstring>
12
13#include "BLI_utildefines.h"
14
15#include "RNA_define.hh"
16
17#include "rna_internal.hh" /* own include */
18
19#ifdef RNA_RUNTIME
20
21# include "BKE_context.hh"
22# include "BKE_global.hh"
23# include "BLI_math_vector.h"
24# include "DNA_scene_types.h"
25# include "IMB_imbuf.hh"
26# include "IMB_imbuf_types.hh"
27# include "RE_pipeline.h"
28# include "RE_texture.h"
29
30static void texture_evaluate(Tex *tex, const float value[3], float r_color[4])
31{
32 TexResult texres = {0.0f};
33
34 /* TODO(sergey): always use color management now. */
35 multitex_ext(tex, value, nullptr, nullptr, 1, &texres, 0, nullptr, true, false);
36
37 copy_v3_v3(r_color, texres.trgba);
38 r_color[3] = texres.tin;
39}
40
41#else
42
44{
45 FunctionRNA *func;
46 PropertyRNA *parm;
47
48 func = RNA_def_function(srna, "evaluate", "texture_evaluate");
50 func, "Evaluate the texture at the a given coordinate and returns the result");
51
53 func,
54 "value",
55 3,
56 nullptr,
57 -FLT_MAX,
58 FLT_MAX,
59 "The coordinates (x,y,z) of the texture, in case of a 3D texture, the z value is the slice "
60 "of the texture that is evaluated. For 2D textures such as images, the z value is ignored.",
61 "",
62 -1e4,
63 1e4);
65
66 /* return location and normal */
68 func,
69 "result",
70 4,
71 nullptr,
72 -FLT_MAX,
73 FLT_MAX,
74 "The result of the texture where (x,y,z,w) are (red, green, blue, intensity). "
75 "For grayscale textures, often intensity only will be used.",
76 nullptr,
77 -1e4,
78 1e4);
80 RNA_def_function_output(func, parm);
81}
82
83#endif
MINLINE void copy_v3_v3(float r[3], const float a[3])
Contains defines and structs used throughout the imbuf module.
ParameterFlag
Definition RNA_types.hh:396
@ PARM_REQUIRED
Definition RNA_types.hh:397
PropertyFlag
Definition RNA_types.hh:201
@ PROP_THICK_WRAP
Definition RNA_types.hh:312
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:87
float trgba[4]
Definition RE_texture.h:88
int multitex_ext(Tex *tex, const float texvec[3], float dxt[3], float dyt[3], int osatex, TexResult *texres, const short thread, ImagePool *pool, bool scene_color_manage, const bool skip_load_image)