Merge with trunk r41625
[blender.git] / source / blender / render / intern / include / texture.h
1 /*
2  * texture_ext.h
3  *
4  *
5  * ***** BEGIN GPL LICENSE BLOCK *****
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software Foundation,
19  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  *
21  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
22  * All rights reserved.
23  *
24  * The Original Code is: all of this file.
25  *
26  * Contributor(s): none yet.
27  *
28  * ***** END GPL LICENSE BLOCK *****
29  */
30
31 /** \file blender/render/intern/include/texture.h
32  *  \ingroup render
33  */
34
35
36 #ifndef TEXTURE_EXT_H
37 #define TEXTURE_EXT_H
38
39 #define BRICONT                                                               \
40         texres->tin= (texres->tin-0.5f) * tex->contrast+tex->bright-0.5f;         \
41         if(texres->tin < 0.0f)      texres->tin= 0.0f;                            \
42         else if(texres->tin > 1.0f) texres->tin= 1.0f;                            \
43
44 #define BRICONTRGB                                                            \
45         texres->tr= tex->rfac*((texres->tr-0.5f)*tex->contrast+tex->bright-0.5f); \
46         if(texres->tr<0.0f) texres->tr= 0.0f;                                     \
47         texres->tg= tex->gfac*((texres->tg-0.5f)*tex->contrast+tex->bright-0.5f); \
48         if(texres->tg<0.0f) texres->tg= 0.0f;                                     \
49         texres->tb= tex->bfac*((texres->tb-0.5f)*tex->contrast+tex->bright-0.5f); \
50         if(texres->tb<0.0f) texres->tb= 0.0f;                                     \
51         if(tex->saturation != 1.0f) {                                             \
52                 float _hsv[3];                                                        \
53                 rgb_to_hsv(texres->tr, texres->tg, texres->tb,                        \
54                            _hsv, _hsv+1, _hsv+2);                                     \
55                 _hsv[1] *= tex->saturation;                                           \
56                 hsv_to_rgb(_hsv[0], _hsv[1], _hsv[2],                                 \
57                            &texres->tr, &texres->tg, &texres->tb);                    \
58         }                                                                         \
59
60 #define RGBTOBW(r,g,b)  ( r*0.35f + g*0.45f + b*0.2f )          /* keep this in sync with gpu_shader_material.glsl:rgbtobw */
61
62 struct HaloRen;
63 struct ShadeInput;
64 struct TexResult;
65 struct Tex;
66 struct Image;
67 struct ImBuf;
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[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[3], const float dyt[3], struct TexResult *texres);
85 int imagewrap(struct Tex *tex, struct Image *ima, struct ImBuf *ibuf, const float texvec[3], struct TexResult *texres);
86 void image_sample(struct Image *ima, float fx, float fy, float dx, float dy, float *result);
87
88 #endif /* TEXTURE_EXT_H */
89