Blender  V2.93
texture_common.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
17  * All rights reserved.
18  */
19 
24 #pragma once
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
30 #define BRICONT \
31  texres->tin = (texres->tin - 0.5f) * tex->contrast + tex->bright - 0.5f; \
32  if (!(tex->flag & TEX_NO_CLAMP)) { \
33  if (texres->tin < 0.0f) { \
34  texres->tin = 0.0f; \
35  } \
36  else if (texres->tin > 1.0f) { \
37  texres->tin = 1.0f; \
38  } \
39  } \
40  ((void)0)
41 
42 #define BRICONTRGB \
43  texres->tr = tex->rfac * ((texres->tr - 0.5f) * tex->contrast + tex->bright - 0.5f); \
44  texres->tg = tex->gfac * ((texres->tg - 0.5f) * tex->contrast + tex->bright - 0.5f); \
45  texres->tb = tex->bfac * ((texres->tb - 0.5f) * tex->contrast + tex->bright - 0.5f); \
46  if (!(tex->flag & TEX_NO_CLAMP)) { \
47  if (texres->tr < 0.0f) { \
48  texres->tr = 0.0f; \
49  } \
50  if (texres->tg < 0.0f) { \
51  texres->tg = 0.0f; \
52  } \
53  if (texres->tb < 0.0f) { \
54  texres->tb = 0.0f; \
55  } \
56  } \
57  if (tex->saturation != 1.0f) { \
58  float _hsv[3]; \
59  rgb_to_hsv(texres->tr, texres->tg, texres->tb, _hsv, _hsv + 1, _hsv + 2); \
60  _hsv[1] *= tex->saturation; \
61  hsv_to_rgb(_hsv[0], _hsv[1], _hsv[2], &texres->tr, &texres->tg, &texres->tb); \
62  if ((tex->saturation > 1.0f) && !(tex->flag & TEX_NO_CLAMP)) { \
63  if (texres->tr < 0.0f) { \
64  texres->tr = 0.0f; \
65  } \
66  if (texres->tg < 0.0f) { \
67  texres->tg = 0.0f; \
68  } \
69  if (texres->tb < 0.0f) { \
70  texres->tb = 0.0f; \
71  } \
72  } \
73  } \
74  ((void)0)
75 
76 struct ImBuf;
77 struct Image;
78 struct ImagePool;
79 struct Tex;
80 struct TexResult;
81 
82 /* texture_image.c */
83 
84 int imagewraposa(struct Tex *tex,
85  struct Image *ima,
86  struct ImBuf *ibuf,
87  const float texvec[3],
88  const float dxt[2],
89  const float dyt[2],
90  struct TexResult *texres,
91  struct ImagePool *pool,
92  const bool skip_load_image);
93 int imagewrap(struct Tex *tex,
94  struct Image *ima,
95  const float texvec[3],
96  struct TexResult *texres,
97  struct ImagePool *pool,
98  const bool skip_load_image);
99 void image_sample(struct Image *ima,
100  float fx,
101  float fy,
102  float dx,
103  float dy,
104  float result[4],
105  struct ImagePool *pool);
106 
107 #ifdef __cplusplus
108 }
109 #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, const 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, const bool skip_load_image)