Blender V4.3
texture_common.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2001-2002 NaN Holding BV. All rights reserved.
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
9#pragma once
10
11#ifdef __cplusplus
12extern "C" {
13#endif
14
15#define BRICONT \
16 texres->tin = (texres->tin - 0.5f) * tex->contrast + tex->bright - 0.5f; \
17 if (!(tex->flag & TEX_NO_CLAMP)) { \
18 if (texres->tin < 0.0f) { \
19 texres->tin = 0.0f; \
20 } \
21 else if (texres->tin > 1.0f) { \
22 texres->tin = 1.0f; \
23 } \
24 } \
25 ((void)0)
26
27#define BRICONTRGB \
28 texres->trgba[0] = tex->rfac * \
29 ((texres->trgba[0] - 0.5f) * tex->contrast + tex->bright - 0.5f); \
30 texres->trgba[1] = tex->gfac * \
31 ((texres->trgba[1] - 0.5f) * tex->contrast + tex->bright - 0.5f); \
32 texres->trgba[2] = tex->bfac * \
33 ((texres->trgba[2] - 0.5f) * tex->contrast + tex->bright - 0.5f); \
34 if (!(tex->flag & TEX_NO_CLAMP)) { \
35 if (texres->trgba[0] < 0.0f) { \
36 texres->trgba[0] = 0.0f; \
37 } \
38 if (texres->trgba[1] < 0.0f) { \
39 texres->trgba[1] = 0.0f; \
40 } \
41 if (texres->trgba[2] < 0.0f) { \
42 texres->trgba[2] = 0.0f; \
43 } \
44 } \
45 if (tex->saturation != 1.0f) { \
46 float _hsv[3]; \
47 rgb_to_hsv(texres->trgba[0], texres->trgba[1], texres->trgba[2], _hsv, _hsv + 1, _hsv + 2); \
48 _hsv[1] *= tex->saturation; \
49 hsv_to_rgb( \
50 _hsv[0], _hsv[1], _hsv[2], &texres->trgba[0], &texres->trgba[1], &texres->trgba[2]); \
51 if ((tex->saturation > 1.0f) && !(tex->flag & TEX_NO_CLAMP)) { \
52 if (texres->trgba[0] < 0.0f) { \
53 texres->trgba[0] = 0.0f; \
54 } \
55 if (texres->trgba[1] < 0.0f) { \
56 texres->trgba[1] = 0.0f; \
57 } \
58 if (texres->trgba[2] < 0.0f) { \
59 texres->trgba[2] = 0.0f; \
60 } \
61 } \
62 } \
63 ((void)0)
64
65struct ImBuf;
66struct Image;
67struct ImagePool;
68struct Tex;
69struct TexResult;
70
71/* `texture_image.cc` */
72
73int imagewraposa(struct Tex *tex,
74 struct Image *ima,
75 struct ImBuf *ibuf,
76 const float texvec[3],
77 const float DXT[2],
78 const float DYT[2],
79 struct TexResult *texres,
80 struct ImagePool *pool,
81 bool skip_load_image);
82int imagewrap(struct Tex *tex,
83 struct Image *ima,
84 const float texvec[3],
85 struct TexResult *texres,
86 struct ImagePool *pool,
87 bool skip_load_image);
88void image_sample(struct Image *ima,
89 float fx,
90 float fy,
91 float dx,
92 float dy,
93 float result[4],
94 struct ImagePool *pool);
95
96#ifdef __cplusplus
97}
98#endif
void image_sample(struct Image *ima, float fx, float fy, float dx, float dy, float result[4], struct ImagePool *pool)
int imagewrap(struct Tex *tex, struct Image *ima, const float texvec[3], struct TexResult *texres, struct ImagePool *pool, bool skip_load_image)
int imagewraposa(struct Tex *tex, struct Image *ima, struct ImBuf *ibuf, const float texvec[3], const float DXT[2], const float DYT[2], struct TexResult *texres, struct ImagePool *pool, bool skip_load_image)