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