diff options
Diffstat (limited to 'source/blender/render/intern/include')
-rw-r--r-- | source/blender/render/intern/include/occlusion.h | 49 | ||||
-rw-r--r-- | source/blender/render/intern/include/pixelblending.h | 2 | ||||
-rw-r--r-- | source/blender/render/intern/include/pixelshading.h | 5 | ||||
-rw-r--r-- | source/blender/render/intern/include/render_types.h | 89 | ||||
-rw-r--r-- | source/blender/render/intern/include/rendercore.h | 14 | ||||
-rw-r--r-- | source/blender/render/intern/include/renderdatabase.h | 12 | ||||
-rw-r--r-- | source/blender/render/intern/include/shadbuf.h | 2 | ||||
-rw-r--r-- | source/blender/render/intern/include/shading.h | 10 | ||||
-rw-r--r-- | source/blender/render/intern/include/sss.h | 2 | ||||
-rw-r--r-- | source/blender/render/intern/include/strand.h | 19 | ||||
-rw-r--r-- | source/blender/render/intern/include/sunsky.h | 144 | ||||
-rw-r--r-- | source/blender/render/intern/include/texture.h | 2 | ||||
-rw-r--r-- | source/blender/render/intern/include/zbuf.h | 24 |
13 files changed, 330 insertions, 44 deletions
diff --git a/source/blender/render/intern/include/occlusion.h b/source/blender/render/intern/include/occlusion.h new file mode 100644 index 00000000000..646ad30b318 --- /dev/null +++ b/source/blender/render/intern/include/occlusion.h @@ -0,0 +1,49 @@ +/* + * $Id$ + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2008 Blender Foundation. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): Brecht Van Lommel. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#ifndef OCCLUSION_H +#define OCCLUSION_H + +struct Render; +struct ShadeInput; +struct ShadeResult; +struct RenderPart; +struct ShadeSample; +struct DerivedMesh; +struct ObjectRen; + +void make_occ_tree(struct Render *re); +void free_occ(struct Render *re); +void sample_occ(struct Render *re, struct ShadeInput *shi); + +void cache_occ_samples(struct Render *re, struct RenderPart *pa, struct ShadeSample *ssamp); +void free_occ_samples(struct Render *re, struct RenderPart *pa); + +#endif + diff --git a/source/blender/render/intern/include/pixelblending.h b/source/blender/render/intern/include/pixelblending.h index 04c5a3977a3..f7f4bc76eae 100644 --- a/source/blender/render/intern/include/pixelblending.h +++ b/source/blender/render/intern/include/pixelblending.h @@ -35,6 +35,8 @@ */ void add_filt_fmask(unsigned int mask, float *col, float *rowbuf, int row_w); void add_filt_fmask_pixsize(unsigned int mask, float *in, float *rowbuf, int row_w, int pixsize); +void add_filt_fmask_coord(float filt[][3], float *col, float *rowbuf, int row_w, int col_h, int x, int y); +void mask_array(unsigned int mask, float filt[][3]); /** * Alpha-over blending for floats. diff --git a/source/blender/render/intern/include/pixelshading.h b/source/blender/render/intern/include/pixelshading.h index d2235784a59..c6b11b4af9a 100644 --- a/source/blender/render/intern/include/pixelshading.h +++ b/source/blender/render/intern/include/pixelshading.h @@ -45,7 +45,7 @@ * mask is pixel coverage in bits * @return pointer to the object */ -void shadeHaloFloat(HaloRen *har, +int shadeHaloFloat(HaloRen *har, float *col, int zz, float dist, float xn, float yn, short flarec); @@ -55,7 +55,8 @@ void shadeHaloFloat(HaloRen *har, */ void shadeSkyPixel(float *collector, float fx, float fy); void shadeSkyView(float *colf, float *rco, float *view, float *dxyview); - +void shadeAtmPixel(struct SunSky *sunsky, float *collector, float fx, float fy, float distance); +void shadeSunView(float *colf, float *view); /* ------------------------------------------------------------------------- */ #endif diff --git a/source/blender/render/intern/include/render_types.h b/source/blender/render/intern/include/render_types.h index 7fbbd0f5abc..1768b052b54 100644 --- a/source/blender/render/intern/include/render_types.h +++ b/source/blender/render/intern/include/render_types.h @@ -42,6 +42,9 @@ #include "RE_pipeline.h" #include "RE_shader_ext.h" /* TexResult, ShadeResult, ShadeInput */ +#include "sunsky.h" + +#include "BLO_sys_types.h" // for intptr_t support struct Object; struct MemArena; @@ -64,8 +67,10 @@ typedef struct SampleTables typedef struct QMCSampler { + struct QMCSampler *next, *prev; int type; int tot; + int used; double *samp2d; double offs[BLENDER_MAX_THREADS][2]; } QMCSampler; @@ -79,17 +84,18 @@ typedef struct RenderPart { struct RenderPart *next, *prev; - /* result of part rendering */ - RenderResult *result; + RenderResult *result; /* result of part rendering */ + ListBase fullresult; /* optional full sample buffers */ int *recto; /* object table for objects */ int *rectp; /* polygon index table */ int *rectz; /* zbuffer */ - long *rectdaps; /* delta acum buffer for pixel structs */ + int *rectmask; /* negative zmask */ + intptr_t *rectdaps; /* delta acum buffer for pixel structs */ int *rectbacko; /* object table for backside sss */ int *rectbackp; /* polygon index table for backside sss */ int *rectbackz; /* zbuffer for backside sss */ - long *rectall; /* buffer for all faces for sss */ + intptr_t *rectall; /* buffer for all faces for sss */ rcti disprect; /* part coordinates within total picture */ int rectx, recty; /* the size */ @@ -113,6 +119,8 @@ struct Render RenderResult *result; /* if render with single-layer option, other rendered layers are stored here */ RenderResult *pushedresult; + /* a list of RenderResults, for fullsample */ + ListBase fullresult; /* window size, display rect, viewplane */ int winx, winy; @@ -147,7 +155,10 @@ struct Render /* samples */ SampleTables *samples; float jit[32][2]; - QMCSampler *qsa; + ListBase *qmcsamplers; + + /* shadow counter, detect shadow-reuse for shaders */ + int shadowsamplenr[BLENDER_MAX_THREADS]; /* scene, and its full copy of renderdata and world */ Scene *scene; @@ -158,6 +169,10 @@ struct Render /* octree tables and variables for raytrace */ void *raytree; + + /* occlusion tree */ + void *occlusiontree; + ListBase strandsurface; /* use this instead of R.r.cfra */ float cfra; @@ -170,11 +185,9 @@ struct Render ListBase lampren; /* storage, for free */ ListBase objecttable; - struct RenderBuckets *strandbuckets; struct ObjectInstanceRen *objectinstance; ListBase instancetable; - struct GHash *objecthash; int totinstance; struct Image *backbuf, *bakebuf; @@ -215,7 +228,7 @@ struct ISBData; typedef struct ShadSampleBuf { struct ShadSampleBuf *next, *prev; - long *zbuf; + intptr_t *zbuf; char *cbuf; } ShadSampleBuf; @@ -241,7 +254,9 @@ typedef struct ObjectRen { struct ObjectRen *next, *prev; struct Object *ob, *par; struct Scene *sce; - int index, psysindex; + int index, psysindex, flag, lay; + + float boundbox[2][3]; int totvert, totvlak, totstrand, tothalo; int vertnodeslen, vlaknodeslen, strandnodeslen, blohalen; @@ -249,11 +264,13 @@ typedef struct ObjectRen { struct VlakTableNode *vlaknodes; struct StrandTableNode *strandnodes; struct HaloRen **bloha; - ListBase strandbufs; + struct StrandBuffer *strandbuf; char (*mtface)[32]; char (*mcol)[32]; - int actmtface, actmcol; + int actmtface, actmcol, bakemtface; + + float obmat[4][4]; /* only used in convertblender.c, for instancing */ } ObjectRen; typedef struct ObjectInstanceRen { @@ -261,11 +278,14 @@ typedef struct ObjectInstanceRen { ObjectRen *obr; Object *ob, *par; - int index, psysindex; + int index, psysindex, lay; - float mat[4][4], imat[3][3]; + float mat[4][4], nmat[3][3]; /* nmat is inverse mat tranposed */ short flag; + float dupliorco[3], dupliuv[2]; + float (*duplitexmat)[4]; + float *vectors; int totvector; } ObjectInstanceRen; @@ -302,13 +322,10 @@ typedef struct RadFace { typedef struct VlakRen { struct VertRen *v1, *v2, *v3, *v4; /* keep in order for ** addressing */ - unsigned int lay; float n[3]; struct Material *mat; char puno; char flag, ec; - RadFace *radface; - ObjectRen *obr; int index; } VlakRen; @@ -328,22 +345,43 @@ typedef struct HaloRen struct Material *mat; } HaloRen; +/* ------------------------------------------------------------------------- */ + typedef struct StrandVert { float co[3]; float strandco; } StrandVert; +typedef struct StrandSurface { + struct StrandSurface *next, *prev; + ObjectRen obr; + int (*face)[4]; + float (*co)[3]; + /* for occlusion caching */ + float (*col)[3]; + /* for speedvectors */ + float (*prevco)[3], (*nextco)[3]; + int totvert, totface; +} StrandSurface; + +typedef struct StrandBound { + int start, end; + float boundbox[2][3]; +} StrandBound; + typedef struct StrandBuffer { struct StrandBuffer *next, *prev; struct StrandVert *vert; - int totvert; + struct StrandBound *bound; + int totvert, totbound; struct ObjectRen *obr; struct Material *ma; + struct StrandSurface *surface; unsigned int lay; int overrideuv; int flag, maxdepth; - float adaptcos, minwidth; + float adaptcos, minwidth, widthfade; float winmat[4][4]; int winx, winy; @@ -380,8 +418,10 @@ typedef struct LampRen { float xs, ys, dist; float co[3]; - short type, mode; + short type; + int mode; float r, g, b, k; + float shdwr, shdwg, shdwb; float energy, haint; int lay; float spotsi,spotbl; @@ -420,9 +460,11 @@ typedef struct LampRen { float area_size, area_sizey, area_sizez; float adapt_thresh; + /* sun/sky */ + struct SunSky *sunsky; + struct ShadBuf *shb; float *jitter; - QMCSampler *qsa; float imat[3][3]; float spottexfac; @@ -463,6 +505,9 @@ typedef struct LampRen { #define R_LAMPHALO 8 #define R_GLOB_NOPUNOFLIP 16 #define R_NEED_TANGENT 32 +#define R_SKIP_MULTIRES 64 +#define R_BAKE_TRACE 128 +#define R_BAKING 256 /* vlakren->flag (vlak = face in dutch) char!!! */ #define R_SMOOTH 1 @@ -481,10 +526,14 @@ typedef struct LampRen { #define R_STRAND_BSPLINE 1 #define R_STRAND_B_UNITS 2 +/* objectren->flag */ +#define R_INSTANCEABLE 1 + /* objectinstance->flag */ #define R_DUPLI_TRANSFORMED 1 #define R_ENV_TRANSFORMED 2 #define R_TRANSFORMED (1|2) +#define R_NEED_VECTORS 4 #endif /* RENDER_TYPES_H */ diff --git a/source/blender/render/intern/include/rendercore.h b/source/blender/render/intern/include/rendercore.h index ab009a980a5..4b28529a147 100644 --- a/source/blender/render/intern/include/rendercore.h +++ b/source/blender/render/intern/include/rendercore.h @@ -37,8 +37,8 @@ /* vector defines */ -#define CROSS(dest, a, b) dest[0]= a[1] * b[2] - a[2] * b[1]; dest[1]= a[2] * b[0] - a[0] * b[2]; dest[2]= a[0] * b[1] - a[1] * b[0] -#define VECMUL(dest, f) dest[0]*= f; dest[1]*= f; dest[2]*= f +#define CROSS(dest, a, b) { dest[0]= a[1] * b[2] - a[2] * b[1]; dest[1]= a[2] * b[0] - a[0] * b[2]; dest[2]= a[0] * b[1] - a[1] * b[0]; } +#define VECMUL(dest, f) { dest[0]*= f; dest[1]*= f; dest[2]*= f; } struct HaloRen; struct ShadeInput; @@ -47,13 +47,14 @@ struct World; struct RenderPart; struct RenderLayer; struct ObjectRen; +struct ListBase; /* ------------------------------------------------------------------------- */ typedef struct PixStr { struct PixStr *next; - int obi, facenr, z; + int obi, facenr, z, maskz; unsigned short mask; short shadfac; } PixStr; @@ -87,6 +88,9 @@ void zbufshadeDA_tile(struct RenderPart *pa); void zbufshade_sss_tile(struct RenderPart *pa); +int get_sample_layers(struct RenderPart *pa, struct RenderLayer *rl, struct RenderLayer **rlpp); + + /* -------- ray.c ------- */ extern void freeraytree(Render *re); @@ -97,9 +101,7 @@ extern void ray_trace(ShadeInput *, ShadeResult *); extern void ray_ao(ShadeInput *, float *); extern void init_jitter_plane(LampRen *lar); extern void init_ao_sphere(struct World *wrld); -extern void init_lamp_hammersley(LampRen *lar); -extern void free_lamp_qmcsampler(LampRen *lar); -extern void init_render_hammersley(Render *re); +extern void init_render_qmcsampler(Render *re); extern void free_render_qmcsampler(Render *re); #endif /* RENDER_EXT_H */ diff --git a/source/blender/render/intern/include/renderdatabase.h b/source/blender/render/intern/include/renderdatabase.h index c919a54008e..dc28eae1cc2 100644 --- a/source/blender/render/intern/include/renderdatabase.h +++ b/source/blender/render/intern/include/renderdatabase.h @@ -42,6 +42,7 @@ struct CustomData; struct StrandBuffer; struct StrandRen; struct ObjectInstanceRen; +struct RadFace; #define RE_QUAD_MASK 0x7FFFFFF #define RE_QUAD_OFFS 0x8000000 @@ -63,6 +64,8 @@ typedef struct VlakTableNode { struct MCol *mcol; int totmtface, totmcol; float *surfnor; + float *tangent; + struct RadFace **radface; } VlakTableNode; typedef struct StrandTableNode { @@ -70,6 +73,7 @@ typedef struct StrandTableNode { float *winspeed; float *surfnor; float *simplify; + int *face; struct MCol *mcol; float *uv; int totuv, totmcol; @@ -82,6 +86,7 @@ void free_renderdata_vlaknodes(struct VlakTableNode *vlaknodes); void set_normalflags(struct Render *re, struct ObjectRen *obr); void project_renderdata(struct Render *re, void (*projectfunc)(float *, float mat[][4], float *), int do_pano, float xoffs, int do_buckets); +int clip_render_object(float boundbox[][3], float *bounds, float mat[][4]); /* functions are not exported... so wrong names */ @@ -93,8 +98,8 @@ struct HaloRen *RE_inithalo(struct Render *re, struct ObjectRen *obr, struct Mat struct HaloRen *RE_inithalo_particle(struct Render *re, struct ObjectRen *obr, struct DerivedMesh *dm, struct Material *ma, float *vec, float *vec1, float *orco, float *uvco, float hasize, float vectsize, int seed); struct StrandBuffer *RE_addStrandBuffer(struct ObjectRen *obr, int totvert); -struct ObjectRen *RE_addRenderObject(struct Render *re, struct Object *ob, struct Object *par, int index, int psysindex); -void RE_addRenderInstance(struct Render *re, struct ObjectRen *obr, struct Object *ob, struct Object *par, int index, int psysindex, float mat[][4]); +struct ObjectRen *RE_addRenderObject(struct Render *re, struct Object *ob, struct Object *par, int index, int psysindex, int lay); +struct ObjectInstanceRen *RE_addRenderInstance(struct Render *re, struct ObjectRen *obr, struct Object *ob, struct Object *par, int index, int psysindex, float mat[][4], int lay); void RE_makeRenderInstances(struct Render *re); void RE_instanceTransformNormal(struct ObjectInstanceRen *obi, float *nor, float *tnor); @@ -108,12 +113,15 @@ float *RE_vertren_get_winspeed(struct ObjectInstanceRen *obi, struct VertRen *ve struct MTFace *RE_vlakren_get_tface(struct ObjectRen *obr, VlakRen *ren, int n, char **name, int verify); struct MCol *RE_vlakren_get_mcol(struct ObjectRen *obr, VlakRen *ren, int n, char **name, int verify); float *RE_vlakren_get_surfnor(struct ObjectRen *obr, VlakRen *ren, int verify); +float *RE_vlakren_get_nmap_tangent(struct ObjectRen *obr, VlakRen *ren, int verify); +RadFace **RE_vlakren_get_radface(struct ObjectRen *obr, VlakRen *ren, int verify); int RE_vlakren_get_normal(struct Render *re, struct ObjectInstanceRen *obi, struct VlakRen *vlr, float *nor); float *RE_strandren_get_surfnor(struct ObjectRen *obr, struct StrandRen *strand, int verify); float *RE_strandren_get_uv(struct ObjectRen *obr, struct StrandRen *strand, int n, char **name, int verify); struct MCol *RE_strandren_get_mcol(struct ObjectRen *obr, struct StrandRen *strand, int n, char **name, int verify); float *RE_strandren_get_simplify(struct ObjectRen *obr, struct StrandRen *strand, int verify); +int *RE_strandren_get_face(struct ObjectRen *obr, struct StrandRen *strand, int verify); float *RE_strandren_get_winspeed(struct ObjectInstanceRen *obi, struct StrandRen *strand, int verify); struct VertRen *RE_vertren_copy(struct ObjectRen *obr, struct VertRen *ver); diff --git a/source/blender/render/intern/include/shadbuf.h b/source/blender/render/intern/include/shadbuf.h index a96baab8294..7015b4bc1bf 100644 --- a/source/blender/render/intern/include/shadbuf.h +++ b/source/blender/render/intern/include/shadbuf.h @@ -54,7 +54,7 @@ void threaded_makeshadowbufs(struct Render *re); * @param inp The inproduct between viewvector and ? * */ -float testshadowbuf(struct ShadBuf *shb, float *rco, float *dxco, float *dyco, float inp); +float testshadowbuf(struct Render *re, struct ShadBuf *shb, float *rco, float *dxco, float *dyco, float inp, float mat_bias); /** * Determines the shadow factor for lamp <lar>, between <p1> diff --git a/source/blender/render/intern/include/shading.h b/source/blender/render/intern/include/shading.h index 6ca63a2976d..54311d2515a 100644 --- a/source/blender/render/intern/include/shading.h +++ b/source/blender/render/intern/include/shading.h @@ -40,13 +40,13 @@ struct ObjectInstanceRen obi; /* needed to calculate shadow and AO for an entire pixel */ typedef struct ShadeSample { - int tot; /* amount of shi in use, can be 1 for not FULL_OSA */ + int tot; /* amount of shi in use, can be 1 for not FULL_OSA */ + + RenderLayer *rlpp[RE_MAX_OSA]; /* fast lookup from sample to renderlayer (fullsample buf) */ /* could be malloced once */ ShadeInput shi[RE_MAX_OSA]; ShadeResult shr[RE_MAX_OSA]; - - int samplenr; /* counter, detect shadow-reuse for shaders */ } ShadeSample; @@ -56,7 +56,8 @@ void shade_material_loop(struct ShadeInput *shi, struct ShadeResult *shr); void shade_input_set_triangle_i(struct ShadeInput *shi, struct ObjectInstanceRen *obi, struct VlakRen *vlr, short i1, short i2, short i3); void shade_input_set_triangle(struct ShadeInput *shi, volatile int obi, volatile int facenr, int normal_flip); void shade_input_copy_triangle(struct ShadeInput *shi, struct ShadeInput *from); -void shade_input_set_viewco(struct ShadeInput *shi, float x, float y, float z); +void shade_input_calc_viewco(struct ShadeInput *shi, float x, float y, float z, float *view, float *dxyview, float *co, float *dxco, float *dyco); +void shade_input_set_viewco(struct ShadeInput *shi, float x, float y, float sx, float sy, float z); void shade_input_set_uv(struct ShadeInput *shi); void shade_input_set_normals(struct ShadeInput *shi); void shade_input_flip_normals(struct ShadeInput *shi); @@ -69,6 +70,7 @@ void shade_input_initialize(struct ShadeInput *shi, struct RenderPart *pa, struc void shade_sample_initialize(struct ShadeSample *ssamp, struct RenderPart *pa, struct RenderLayer *rl); void shade_samples_do_AO(struct ShadeSample *ssamp); +void shade_samples_fill_with_ps(struct ShadeSample *ssamp, struct PixStr *ps, int x, int y); int shade_samples(struct ShadeSample *ssamp, struct PixStr *ps, int x, int y); void vlr_set_uv_indices(struct VlakRen *vlr, int *i1, int *i2, int *i3); diff --git a/source/blender/render/intern/include/sss.h b/source/blender/render/intern/include/sss.h index 660fb544227..9ffdcaf206a 100644 --- a/source/blender/render/intern/include/sss.h +++ b/source/blender/render/intern/include/sss.h @@ -59,7 +59,7 @@ void sss_add_points(Render *re, float (*co)[3], float (*color)[3], float *area, void free_sss(struct Render *re); int sample_sss(struct Render *re, struct Material *mat, float *co, float *col); -int has_sss_tree(struct Render *re, struct Material *mat); +int sss_pass_done(struct Render *re, struct Material *mat); #endif /*SSS_H*/ diff --git a/source/blender/render/intern/include/strand.h b/source/blender/render/intern/include/strand.h index c6ec72125ad..09988125830 100644 --- a/source/blender/render/intern/include/strand.h +++ b/source/blender/render/intern/include/strand.h @@ -41,6 +41,9 @@ struct RenderBuckets; struct RenderPrimitiveIterator; struct ZSpan; struct ObjectInstanceRen; +struct StrandSurface; +struct DerivedMesh; +struct ObjectRen; typedef struct StrandPoint { /* position within segment */ @@ -61,6 +64,7 @@ typedef struct StrandPoint { float co1[3], co2[3]; float hoco1[4], hoco2[4]; float zco1[3], zco2[3]; + int clip1, clip2; /* screen space */ float hoco[4]; @@ -81,9 +85,20 @@ typedef struct StrandSegment { int shaded; } StrandSegment; +struct StrandShadeCache; +typedef struct StrandShadeCache StrandShadeCache; + void strand_eval_point(StrandSegment *sseg, StrandPoint *spoint); -void render_strand_segment(struct Render *re, float winmat[][4], struct StrandPart *spart, struct ZSpan *zspan, StrandSegment *sseg); -void project_strands(Render *re, void (*projectfunc)(float *, float mat[][4], float *), int do_pano, int do_buckets); +void render_strand_segment(struct Render *re, float winmat[][4], struct StrandPart *spart, struct ZSpan *zspan, int totzspan, StrandSegment *sseg); +void strand_minmax(struct StrandRen *strand, float *min, float *max); + +struct StrandSurface *cache_strand_surface(struct Render *re, struct ObjectRen *obr, struct DerivedMesh *dm, float mat[][4], int timeoffset); +void free_strand_surface(struct Render *re); + +struct StrandShadeCache *strand_shade_cache_create(void); +void strand_shade_cache_free(struct StrandShadeCache *cache); +void strand_shade_segment(struct Render *re, struct StrandShadeCache *cache, struct StrandSegment *sseg, struct ShadeSample *ssamp, float t, float s, int addpassflag); +void strand_shade_unref(struct StrandShadeCache *cache, struct StrandVert *svert); struct RenderBuckets *init_buckets(struct Render *re); void add_buckets_primitive(struct RenderBuckets *buckets, float *min, float *max, void *prim); diff --git a/source/blender/render/intern/include/sunsky.h b/source/blender/render/intern/include/sunsky.h new file mode 100644 index 00000000000..f61338bcf27 --- /dev/null +++ b/source/blender/render/intern/include/sunsky.h @@ -0,0 +1,144 @@ + /** + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * Contributor(s): zaghaghi + * + * ***** END GPL LICENSE BLOCK ***** + */ +/** + * This feature comes from Preetham paper on "A Practical Analytic Model for Daylight" + * and example code from Brian Smits, another author of that paper in + * http://www.cs.utah.edu/vissim/papers/sunsky/code/ + * */ +#ifndef SUNSKY_H_ +#define SUNSKY_H_ + +#define SPECTRUM_MAX_COMPONENTS 100 +#define SPECTRUM_START 350.0 +#define SPECTRUM_END 800.0 + +typedef struct SunSky +{ + short effect_type, skyblendtype, sky_colorspace; + float turbidity; + float theta, phi; + + float toSun[3]; + + /*float sunSpectralRaddata[SPECTRUM_MAX_COMPONENTS];*/ + float sunSolidAngle; + + float zenith_Y, zenith_x, zenith_y; + + float perez_Y[5], perez_x[5], perez_y[5]; + + /* suggested by glome in + * http://projects.blender.org/tracker/?func=detail&atid=127&aid=8063&group_id=9*/ + float horizon_brightness; + float spread; + float sun_brightness; + float sun_size; + float backscattered_light; + float skyblendfac; + float sky_exposure; + + float atm_HGg; + + float atm_SunIntensity; + float atm_InscatteringMultiplier; + float atm_ExtinctionMultiplier; + float atm_BetaRayMultiplier; + float atm_BetaMieMultiplier; + float atm_DistanceMultiplier; + + float atm_BetaRay[3]; + float atm_BetaDashRay[3]; + float atm_BetaMie[3]; + float atm_BetaDashMie[3]; + float atm_BetaRM[3]; +}SunSky; + +/** + * InitSunSky: + * this function compute some sun,sky parameters according to input parameters and also initiate some other sun, sky parameters + * parameters: + * sunSky, is a structure that contains informtion about sun, sky and atmosphere, in this function, most of its values initiated + * turb, is atmosphere turbidity + * toSun, contains sun direction + * horizon_brighness, controls the brightness of the horizon colors + * spread, controls colors spreed at horizon + * sun_brightness, controls sun's brightness + * sun_size, controls sun's size + * back_scatter, controls back scatter light + * */ +void InitSunSky(struct SunSky *sunsky, float turb, float *toSun, float horizon_brightness, + float spread,float sun_brightness, float sun_size, float back_scatter, + float skyblendfac, short skyblendtype, float sky_exposure, float sky_colorspace); + +/** + * GetSkyXYZRadiance: + * this function compute sky radiance according to a view parameters `theta' and `phi'and sunSky values + * parameters: + * sunSky, sontains sun and sky parameters + * theta, is sun's theta + * phi, is sun's phi + * color_out, is computed color that shows sky radiance in XYZ color format + * */ +void GetSkyXYZRadiance(struct SunSky* sunsky, float theta, float phi, float color_out[3]); + +/** + * GetSkyXYZRadiancef: + * this function compute sky radiance according to a view direction `varg' and sunSky values + * parameters: + * sunSky, sontains sun and sky parameters + * varg, shows direction + * color_out, is computed color that shows sky radiance in XYZ color format + * */ +void GetSkyXYZRadiancef(struct SunSky* sunsky, const float varg[3], float color_out[3]); + +/** + * InitAtmosphere: + * this function intiate sunSky structure with user input parameters. + * parameters: + * sunSky, contains information about sun, and in this function some atmosphere parameters will initiated + * sun_intens, shows sun intensity value + * mief, Mie scattering factor this factor currently call with 1.0 + * rayf, Rayleigh scattering factor, this factor currently call with 1.0 + * inscattf, inscatter light factor that range from 0.0 to 1.0, 0.0 means no inscatter light and 1.0 means full inscatter light + * extincf, extinction light factor that range from 0.0 to 1.0, 0.0 means no extinction and 1.0 means full extinction + * disf, is distance factor, multiplyed to pixle's z value to compute each pixle's distance to camera, + * */ +void InitAtmosphere(struct SunSky *sunSky, float sun_intens, float mief, float rayf, float inscattf, float extincf, float disf); + +/** + * AtmospherePixleShader: + * this function apply atmosphere effect on a pixle color `rgb' at distance `s' + * parameters: + * sunSky, contains information about sun parameters and user values + * view, is camera view vector + * s, is distance + * rgb, contains rendered color value for a pixle + * */ +void AtmospherePixleShader( struct SunSky* sunSky, float view[3], float s, float rgb[3]); + +/** + * ClipColor: + * clip a color to range [0,1]; + * */ +void ClipColor(float c[3]); + +#endif /*SUNSKY_H_*/ diff --git a/source/blender/render/intern/include/texture.h b/source/blender/render/intern/include/texture.h index 8e56c4a852f..be5471e07c4 100644 --- a/source/blender/render/intern/include/texture.h +++ b/source/blender/render/intern/include/texture.h @@ -55,7 +55,7 @@ struct ImBuf; void do_halo_tex(struct HaloRen *har, float xn, float yn, float *colf); void do_sky_tex(float *rco, float *lo, float *dxyview, float *hor, float *zen, float *blend, int skyflag); void do_material_tex(struct ShadeInput *shi); -void do_lamp_tex(LampRen *la, float *lavec, struct ShadeInput *shi, float *colf); +void do_lamp_tex(LampRen *la, float *lavec, struct ShadeInput *shi, float *colf, int effect); void init_render_textures(Render *re); diff --git a/source/blender/render/intern/include/zbuf.h b/source/blender/render/intern/include/zbuf.h index 4d30c1e0dfb..b6d0c656f63 100644 --- a/source/blender/render/intern/include/zbuf.h +++ b/source/blender/render/intern/include/zbuf.h @@ -36,6 +36,8 @@ struct LampRen; struct VlakRen; struct ListBase; struct ZSpan; +struct APixstrand; +struct StrandShadeCache; void fillrect(int *rect, int x, int y, int val); @@ -48,12 +50,11 @@ void projectverto(float *v1, float winmat[][4], float *adr); int testclip(float *v); void zbuffer_shadow(struct Render *re, float winmat[][4], struct LampRen *lar, int *rectz, int size, float jitx, float jity); -void zbuffer_solid(struct RenderPart *pa, unsigned int layer, short layflag, void (*fillfunc)(struct RenderPart*, struct ZSpan*, int, void*), void *data); +void zbuffer_solid(struct RenderPart *pa, struct RenderLayer *rl, void (*fillfunc)(struct RenderPart*, struct ZSpan*, int, void*), void *data); -unsigned short *zbuffer_transp_shade(struct RenderPart *pa, struct RenderLayer *rl, float *pass); -unsigned short *zbuffer_strands_shade(struct Render *re, struct RenderPart *pa, struct RenderLayer *rl, float *pass); -void convert_zbuf_to_distbuf(struct RenderPart *pa, struct RenderLayer *rl); +unsigned short *zbuffer_transp_shade(struct RenderPart *pa, struct RenderLayer *rl, float *pass, struct ListBase *psmlist); void zbuffer_sss(RenderPart *pa, unsigned int lay, void *handle, void (*func)(void*, int, int, int, int, int)); +int zbuffer_strands_abuf(struct Render *re, struct RenderPart *pa, struct RenderLayer *rl, struct APixstrand *apixbuf, struct ListBase *apsmbase, struct StrandShadeCache *cache); typedef struct APixstr { unsigned short mask[4]; /* jitter mask */ @@ -64,10 +65,20 @@ typedef struct APixstr { struct APixstr *next; } APixstr; +typedef struct APixstrand { + unsigned short mask[4]; /* jitter mask */ + int z[4]; /* distance */ + int p[4]; /* index */ + int obi[4]; /* object instance */ + int seg[4]; /* for strands, segment number */ + float u[4], v[4]; /* for strands, u,v coordinate in segment */ + struct APixstrand *next; +} APixstrand; + typedef struct APixstrMain { struct APixstrMain *next, *prev; - struct APixstr *ps; + void *ps; } APixstrMain; /* span fill in method, is also used to localize data for zbuffering */ @@ -84,12 +95,15 @@ typedef struct ZSpan { int *rectz1; /* seconday z buffer for shadowbuffer (2nd closest z) */ int *rectp; /* polygon index buffer */ int *recto; /* object buffer */ + int *rectmask; /* negative zmask buffer */ APixstr *apixbuf, *curpstr; /* apixbuf for transparent */ + APixstrand *curpstrand; /* same for strands */ struct ListBase *apsmbase; int polygon_offset; /* offset in Z */ float shad_alpha; /* copy from material, used by irregular shadbuf */ int mask, apsmcounter; /* in use by apixbuf */ + int apstrandmcounter; float clipcrop; /* for shadow, was in R global before */ |