Blender V2.61 - r43446
|
00001 /* 00002 * ***** BEGIN GPL LICENSE BLOCK ***** 00003 * 00004 * This program is free software; you can redistribute it and/or 00005 * modify it under the terms of the GNU General Public License 00006 * as published by the Free Software Foundation; either version 2 00007 * of the License, or (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software Foundation, 00016 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00017 * 00018 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. 00019 * All rights reserved. 00020 * 00021 * Full recode: 2004-2006 Blender Foundation 00022 * 00023 * Contributor(s): none yet. 00024 * 00025 * ***** END GPL/BL DUAL LICENSE BLOCK ***** 00026 */ 00027 00033 #ifndef ZBUF_H 00034 #define ZBUF_H 00035 00036 struct RenderPart; 00037 struct RenderLayer; 00038 struct LampRen; 00039 struct VlakRen; 00040 struct ListBase; 00041 struct ZSpan; 00042 struct APixstrand; 00043 struct APixstr; 00044 struct StrandShadeCache; 00045 00046 void fillrect(int *rect, int x, int y, int val); 00047 00052 void projectvert(const float v1[3], float winmat[][4], float adr[4]); 00053 void projectverto(const float v1[3], float winmat[][4], float adr[4]); 00054 int testclip(const float v[3]); 00055 00056 void zbuffer_shadow(struct Render *re, float winmat[][4], struct LampRen *lar, int *rectz, int size, float jitx, float jity); 00057 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]); 00058 void zbuffer_solid(struct RenderPart *pa, struct RenderLayer *rl, void (*fillfunc)(struct RenderPart*, struct ZSpan*, int, void*), void *data); 00059 00060 unsigned short *zbuffer_transp_shade(struct RenderPart *pa, struct RenderLayer *rl, float *pass, struct ListBase *psmlist); 00061 void zbuffer_sss(RenderPart *pa, unsigned int lay, void *handle, void (*func)(void*, int, int, int, int, int)); 00062 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); 00063 00064 typedef struct APixstr { 00065 unsigned short mask[4]; /* jitter mask */ 00066 int z[4]; /* distance */ 00067 int p[4]; /* index */ 00068 int obi[4]; /* object instance */ 00069 short shadfac[4]; /* optimize storage for irregular shadow */ 00070 struct APixstr *next; 00071 } APixstr; 00072 00073 typedef struct APixstrand { 00074 unsigned short mask[4]; /* jitter mask */ 00075 int z[4]; /* distance */ 00076 int p[4]; /* index */ 00077 int obi[4]; /* object instance */ 00078 int seg[4]; /* for strands, segment number */ 00079 float u[4], v[4]; /* for strands, u,v coordinate in segment */ 00080 struct APixstrand *next; 00081 } APixstrand; 00082 00083 typedef struct APixstrMain 00084 { 00085 struct APixstrMain *next, *prev; 00086 void *ps; 00087 } APixstrMain; 00088 00089 /* span fill in method, is also used to localize data for zbuffering */ 00090 typedef struct ZSpan { 00091 int rectx, recty; /* range for clipping */ 00092 00093 int miny1, maxy1, miny2, maxy2; /* actual filled in range */ 00094 float *minp1, *maxp1, *minp2, *maxp2; /* vertex pointers detect min/max range in */ 00095 float *span1, *span2; 00096 00097 float zmulx, zmuly, zofsx, zofsy; /* transform from hoco to zbuf co */ 00098 00099 int *rectz, *arectz; /* zbuffers, arectz is for transparant */ 00100 int *rectz1; /* seconday z buffer for shadowbuffer (2nd closest z) */ 00101 int *rectp; /* polygon index buffer */ 00102 int *recto; /* object buffer */ 00103 int *rectmask; /* negative zmask buffer */ 00104 APixstr *apixbuf, *curpstr; /* apixbuf for transparent */ 00105 APixstrand *curpstrand; /* same for strands */ 00106 struct ListBase *apsmbase; 00107 00108 int polygon_offset; /* offset in Z */ 00109 float shad_alpha; /* copy from material, used by irregular shadbuf */ 00110 int mask, apsmcounter; /* in use by apixbuf */ 00111 int apstrandmcounter; 00112 00113 float clipcrop; /* for shadow, was in R global before */ 00114 00115 void *sss_handle; /* used by sss */ 00116 void (*sss_func)(void *, int, int, int, int, int); 00117 00118 void (*zbuffunc)(struct ZSpan *, int, int, float *, float *, float *, float *); 00119 void (*zbuflinefunc)(struct ZSpan *, int, int, float *, float *); 00120 00121 } ZSpan; 00122 00123 /* exported to shadbuf.c */ 00124 void zbufclip4(struct ZSpan *zspan, int obi, int zvlnr, float *f1, float *f2, float *f3, float *f4, int c1, int c2, int c3, int c4); 00125 void zbuf_free_span(struct ZSpan *zspan); 00126 void freepsA(struct ListBase *lb); 00127 00128 /* to rendercore.c */ 00129 void zspan_scanconvert(struct ZSpan *zpan, void *handle, float *v1, float *v2, float *v3, void (*func)(void *, int, int, float, float) ); 00130 00131 /* exported to edge render... */ 00132 void zbufclip(struct ZSpan *zspan, int obi, int zvlnr, float *f1, float *f2, float *f3, int c1, int c2, int c3); 00133 void zbuf_alloc_span(struct ZSpan *zspan, int rectx, int recty, float clipcrop); 00134 void zbufclipwire(struct ZSpan *zspan, int obi, int zvlnr, int ec, float *ho1, float *ho2, float *ho3, float *ho4, int c1, int c2, int c3, int c4); 00135 00136 /* exported to shadeinput.c */ 00137 void zbuf_make_winmat(Render *re, float winmat[][4]); 00138 void zbuf_render_project(float winmat[][4], const float co[3], float ho[4]); 00139 00140 #endif 00141