2 * ***** BEGIN GPL LICENSE BLOCK *****
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.
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.
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.
18 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
19 * All rights reserved.
21 * Full recode: 2004-2006 Blender Foundation
23 * Contributor(s): none yet.
25 * ***** END GPL/BL DUAL LICENSE BLOCK *****
28 /** \file blender/render/intern/include/zbuf.h
44 struct StrandShadeCache;
46 void fillrect(int *rect, int x, int y, int val);
49 * Converts a world coordinate into a homogenous coordinate in view
52 void projectvert(const float v1[3], float winmat[][4], float adr[4]);
53 void projectverto(const float v1[3], float winmat[][4], float adr[4]);
54 int testclip(const float v[3]);
56 void zbuffer_shadow(struct Render *re, float winmat[][4], struct LampRen *lar, int *rectz, int size, float jitx, float jity);
57 void zbuffer_abuf_shadow(struct Render *re, struct LampRen *lar, float winmat[][4], struct APixstr *APixbuf, struct APixstrand *apixbuf, struct ListBase *apsmbase, int size, int samples, float (*jit)[2]);
58 void zbuffer_solid(struct RenderPart *pa, struct RenderLayer *rl, void (*fillfunc)(struct RenderPart*, struct ZSpan*, int, void*), void *data);
60 unsigned short *zbuffer_transp_shade(struct RenderPart *pa, struct RenderLayer *rl, float *pass, struct ListBase *psmlist);
61 void zbuffer_sss(RenderPart *pa, unsigned int lay, void *handle, void (*func)(void*, int, int, int, int, int));
62 int zbuffer_strands_abuf(struct Render *re, struct RenderPart *pa, struct APixstrand *apixbuf, struct ListBase *apsmbase, unsigned int lay, int negzmask, float winmat[][4], int winx, int winy, int sample, float (*jit)[2], float clipcrop, int shadow, struct StrandShadeCache *cache);
64 typedef struct APixstr {
65 unsigned short mask[4]; /* jitter mask */
66 int z[4]; /* distance */
68 int obi[4]; /* object instance */
69 short shadfac[4]; /* optimize storage for irregular shadow */
73 typedef struct APixstrand {
74 unsigned short mask[4]; /* jitter mask */
75 int z[4]; /* distance */
77 int obi[4]; /* object instance */
78 int seg[4]; /* for strands, segment number */
79 float u[4], v[4]; /* for strands, u,v coordinate in segment */
80 struct APixstrand *next;
83 typedef struct APixstrMain
85 struct APixstrMain *next, *prev;
89 /* span fill in method, is also used to localize data for zbuffering */
90 typedef struct ZSpan {
91 int rectx, recty; /* range for clipping */
93 int miny1, maxy1, miny2, maxy2; /* actual filled in range */
94 const float *minp1, *maxp1, *minp2, *maxp2; /* vertex pointers detect min/max range in */
97 float zmulx, zmuly, zofsx, zofsy; /* transform from hoco to zbuf co */
99 int *rectz, *arectz; /* zbuffers, arectz is for transparant */
100 int *rectz1; /* seconday z buffer for shadowbuffer (2nd closest z) */
101 int *rectp; /* polygon index buffer */
102 int *recto; /* object buffer */
103 int *rectmask; /* negative zmask buffer */
104 APixstr *apixbuf, *curpstr; /* apixbuf for transparent */
105 APixstrand *curpstrand; /* same for strands */
106 struct ListBase *apsmbase;
108 int polygon_offset; /* offset in Z */
109 float shad_alpha; /* copy from material, used by irregular shadbuf */
110 int mask, apsmcounter; /* in use by apixbuf */
111 int apstrandmcounter;
113 float clipcrop; /* for shadow, was in R global before */
115 void *sss_handle; /* used by sss */
116 void (*sss_func)(void *, int, int, int, int, int);
118 void (*zbuffunc)(struct ZSpan *, int, int, const float *, const float *, const float *, const float *);
119 void (*zbuflinefunc)(struct ZSpan *, int, int, const float *, const float *);
123 /* exported to shadbuf.c */
124 void zbufclip4(struct ZSpan *zspan, int obi, int zvlnr, float *f1, float *f2, float *f3, float *f4,
125 int c1, int c2, int c3, int c4);
126 void zbuf_free_span(struct ZSpan *zspan);
127 void freepsA(struct ListBase *lb);
129 /* to rendercore.c */
130 void zspan_scanconvert(struct ZSpan *zpan, void *handle, float *v1, float *v2, float *v3,
131 void (*func)(void *, int, int, float, float) );
133 /* exported to edge render... */
134 void zbufclip(struct ZSpan *zspan, int obi, int zvlnr, float *f1, float *f2, float *f3, int c1, int c2, int c3);
135 void zbuf_alloc_span(struct ZSpan *zspan, int rectx, int recty, float clipcrop);
136 void zbufclipwire(struct ZSpan *zspan, int obi, int zvlnr, int ec,
137 float *ho1, float *ho2, float *ho3, float *ho4, int c1, int c2, int c3, int c4);
139 /* exported to shadeinput.c */
140 void zbuf_make_winmat(Render *re, float winmat[][4]);
141 void zbuf_render_project(float winmat[][4], const float co[3], float ho[4]);