Blender V5.0
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
8
9#pragma once
10
11#include "BLI_math_color.h" /* IWYU pragma: keep. Used in macros. */
12
13#define BRICONT \
14 texres->tin = (texres->tin - 0.5f) * tex->contrast + tex->bright - 0.5f; \
15 if (!(tex->flag & TEX_NO_CLAMP)) { \
16 if (texres->tin < 0.0f) { \
17 texres->tin = 0.0f; \
18 } \
19 else if (texres->tin > 1.0f) { \
20 texres->tin = 1.0f; \
21 } \
22 } \
23 ((void)0)
24
25#define BRICONTRGB \
26 texres->trgba[0] = tex->rfac * \
27 ((texres->trgba[0] - 0.5f) * tex->contrast + tex->bright - 0.5f); \
28 texres->trgba[1] = tex->gfac * \
29 ((texres->trgba[1] - 0.5f) * tex->contrast + tex->bright - 0.5f); \
30 texres->trgba[2] = tex->bfac * \
31 ((texres->trgba[2] - 0.5f) * tex->contrast + tex->bright - 0.5f); \
32 if (!(tex->flag & TEX_NO_CLAMP)) { \
33 if (texres->trgba[0] < 0.0f) { \
34 texres->trgba[0] = 0.0f; \
35 } \
36 if (texres->trgba[1] < 0.0f) { \
37 texres->trgba[1] = 0.0f; \
38 } \
39 if (texres->trgba[2] < 0.0f) { \
40 texres->trgba[2] = 0.0f; \
41 } \
42 } \
43 if (tex->saturation != 1.0f) { \
44 float _hsv[3]; \
45 rgb_to_hsv(texres->trgba[0], texres->trgba[1], texres->trgba[2], _hsv, _hsv + 1, _hsv + 2); \
46 _hsv[1] *= tex->saturation; \
47 hsv_to_rgb( \
48 _hsv[0], _hsv[1], _hsv[2], &texres->trgba[0], &texres->trgba[1], &texres->trgba[2]); \
49 if ((tex->saturation > 1.0f) && !(tex->flag & TEX_NO_CLAMP)) { \
50 if (texres->trgba[0] < 0.0f) { \
51 texres->trgba[0] = 0.0f; \
52 } \
53 if (texres->trgba[1] < 0.0f) { \
54 texres->trgba[1] = 0.0f; \
55 } \
56 if (texres->trgba[2] < 0.0f) { \
57 texres->trgba[2] = 0.0f; \
58 } \
59 } \
60 } \
61 ((void)0)
62
63struct ImBuf;
64struct Image;
65struct ImagePool;
66struct Tex;
67struct TexResult;
68
69/* `texture_image.cc` */
70
71int imagewrap(struct Tex *tex,
72 struct Image *ima,
73 const float texvec[3],
74 struct TexResult *texres,
75 struct ImagePool *pool,
76 bool skip_load_image);
77void image_sample(struct Image *ima,
78 float fx,
79 float fy,
80 float dx,
81 float dy,
82 float result[4],
83 struct ImagePool *pool);
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)