Fix T43427: Particle system children sometimes not generated on reload
[blender.git] / source / blender / render / intern / include / texture.h
1 /*
2  * ***** BEGIN GPL LICENSE BLOCK *****
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software Foundation,
16  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  *
18  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
19  * All rights reserved.
20  *
21  * The Original Code is: all of this file.
22  *
23  * Contributor(s): none yet.
24  *
25  * ***** END GPL LICENSE BLOCK *****
26  */
27
28 /** \file blender/render/intern/include/texture.h
29  *  \ingroup render
30  */
31
32
33 #ifndef __TEXTURE_H__
34 #define __TEXTURE_H__
35
36 #define BRICONT                                                           \
37         texres->tin= (texres->tin-0.5f) * tex->contrast+tex->bright-0.5f;     \
38         if (!(tex->flag & TEX_NO_CLAMP)) {                                    \
39                 if (texres->tin < 0.0f)      texres->tin= 0.0f;                   \
40                 else if (texres->tin > 1.0f) texres->tin= 1.0f;                   \
41         }                                                                     \
42
43 #define BRICONTRGB                                                            \
44         texres->tr= tex->rfac*((texres->tr-0.5f)*tex->contrast+tex->bright-0.5f); \
45         texres->tg= tex->gfac*((texres->tg-0.5f)*tex->contrast+tex->bright-0.5f); \
46         texres->tb= tex->bfac*((texres->tb-0.5f)*tex->contrast+tex->bright-0.5f); \
47         if (!(tex->flag & TEX_NO_CLAMP)) {                                        \
48                 if (texres->tr < 0.0f) texres->tr= 0.0f;                              \
49                 if (texres->tg < 0.0f) texres->tg= 0.0f;                              \
50                 if (texres->tb < 0.0f) texres->tb= 0.0f;                              \
51         }                                                                         \
52         if (tex->saturation != 1.0f) {                                            \
53                 float _hsv[3];                                                        \
54                 rgb_to_hsv(texres->tr, texres->tg, texres->tb,                        \
55                            _hsv, _hsv+1, _hsv+2);                                     \
56                 _hsv[1] *= tex->saturation;                                           \
57                 hsv_to_rgb(_hsv[0], _hsv[1], _hsv[2],                                 \
58                            &texres->tr, &texres->tg, &texres->tb);                    \
59         }                                                                         \
60
61 struct HaloRen;
62 struct ShadeInput;
63 struct TexResult;
64 struct Tex;
65 struct Image;
66 struct ImBuf;
67 struct ImagePool;
68
69 /* texture.h */
70
71 void do_halo_tex(struct HaloRen *har, float xn, float yn, float col_r[4]);
72 void do_sky_tex(const float rco[3], float lo[3], const float dxyview[2], float hor[3], float zen[3], float *blend, int skyflag, short thread);
73 void do_material_tex(struct ShadeInput *shi, struct Render *re);
74 void do_lamp_tex(LampRen *la, const float lavec[3], struct ShadeInput *shi, float col_r[3], int effect);
75 void do_volume_tex(struct ShadeInput *shi, const float xyz[3], int mapto_flag, float col_r[3], float *val, struct Render *re);
76
77 void init_render_textures(Render *re);
78 void end_render_textures(Render *re);
79
80 void render_realtime_texture(struct ShadeInput *shi, struct Image *ima);
81
82 /* imagetexture.h */
83
84 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);
85 int imagewrap(struct Tex *tex, struct Image *ima, struct ImBuf *ibuf, const float texvec[3], struct TexResult *texres, struct ImagePool *pool, const bool skip_load_image);
86 void image_sample(struct Image *ima, float fx, float fy, float dx, float dy, float result[4], struct ImagePool *pool);
87
88 #endif /* __TEXTURE_H__ */
89