Blender V2.61 - r43446
Classes | Defines | Typedefs | Functions | Variables

shadbuf.c File Reference

#include <math.h>
#include <string.h>
#include "MEM_guardedalloc.h"
#include "DNA_group_types.h"
#include "DNA_lamp_types.h"
#include "DNA_material_types.h"
#include "BKE_global.h"
#include "BKE_scene.h"
#include "BLI_math.h"
#include "BLI_blenlib.h"
#include "BLI_jitter.h"
#include "BLI_memarena.h"
#include "BLI_rand.h"
#include "BLI_utildefines.h"
#include "PIL_time.h"
#include "renderpipeline.h"
#include "render_types.h"
#include "renderdatabase.h"
#include "rendercore.h"
#include "shadbuf.h"
#include "shading.h"
#include "zbuf.h"

Go to the source code of this file.

Classes

struct  Boxf
struct  ISBBranch
struct  BSPFace

Defines

#define RCOMP   0
#define GCOMP   1
#define BCOMP   2
#define ACOMP   3
#define BSPMAX_SAMPLE   128
#define BSPMAX_DEPTH   32

Typedefs

typedef struct Boxf Boxf
typedef struct ISBBranch ISBBranch
typedef struct BSPFace BSPFace

Functions

static void copy_to_ztile (int *rectz, int size, int x1, int y1, int tile, char *r1)
static float * give_jitter_tab (int samp)
static void make_jitter_weight_tab (Render *re, ShadBuf *shb, short filtertype)
static int verg_deepsample (const void *poin1, const void *poin2)
static int compress_deepsamples (DeepSample *dsample, int tot, float epsilon)
static float deep_alpha (Render *re, int obinr, int facenr, int strand)
static void compress_deepshadowbuf (Render *re, ShadBuf *shb, APixstr *apixbuf, APixstrand *apixbufstrand)
static void compress_shadowbuf (ShadBuf *shb, int *rectz, int square)
static void shadowbuf_autoclip (Render *re, LampRen *lar)
static void makeflatshadowbuf (Render *re, LampRen *lar, float *jitbuf)
static void makedeepshadowbuf (Render *re, LampRen *lar, float *jitbuf)
void makeshadowbuf (Render *re, LampRen *lar)
static void * do_shadow_thread (void *re_v)
static int thread_break (void *UNUSED(arg))
void threaded_makeshadowbufs (Render *re)
void freeshadowbuf (LampRen *lar)
static int firstreadshadbuf (ShadBuf *shb, ShadSampleBuf *shsample, int **rz, int xs, int ys, int nr)
static float readdeepvisibility (DeepSample *dsample, int tot, int z, int bias, float *biast)
static float readdeepshadowbuf (ShadBuf *shb, ShadSampleBuf *shsample, int bias, int xs, int ys, int zs)
static float readshadowbuf (ShadBuf *shb, ShadSampleBuf *shsample, int bias, int xs, int ys, int zs)
static void shadowbuf_project_co (float *x, float *y, float *z, ShadBuf *shb, const float co[3])
float testshadowbuf (Render *re, ShadBuf *shb, const float co[3], const float dxco[3], const float dyco[3], float inp, float mat_bias)
static float readshadowbuf_halo (ShadBuf *shb, ShadSampleBuf *shsample, int xs, int ys, int zs)
float shadow_halo (LampRen *lar, const float p1[3], const float p2[3])
static void init_box (Boxf *box)
static void bound_boxf (Boxf *box, const float v1[3])
static void bound_rectf (rctf *box, const float v1[2])
static void isb_bsp_split_init (ISBBranch *root, MemArena *mem, int level)
static void isb_bsp_split (ISBBranch *root, MemArena *mem)
static int isb_bsp_insert (ISBBranch *root, MemArena *memarena, ISBSample *sample)
static void bspface_init_strand (BSPFace *face)
static int point_behind_strand (const float p[3], BSPFace *face)
static int point_behind_tria2d (const float p[3], const float v1[3], const float v2[3], const float v3[3])
static void isb_bsp_face_inside (ISBBranch *bspn, BSPFace *face)
static void isb_bsp_recalc_box (ISBBranch *root)
static void isb_bsp_test_strand (ZSpan *zspan, int obi, int zvlnr, float *v1, float *v2, float *v3, float *v4)
static void isb_bsp_test_face (ZSpan *zspan, int obi, int zvlnr, float *v1, float *v2, float *v3, float *v4)
static int testclip_minmax (const float ho[4], const float minmax[4])
static void isb_bsp_fillfaces (Render *re, LampRen *lar, ISBBranch *root)
static int viewpixel_to_lampbuf (ShadBuf *shb, ObjectInstanceRen *obi, VlakRen *vlr, float x, float y, float co_r[3])
static void isb_add_shadfac (ISBShadfacA **isbsapp, MemArena *mem, int obi, int facenr, short shadfac, short samples)
static int isb_add_samples (RenderPart *pa, ISBBranch *root, MemArena *memarena, ISBSample **samplebuf)
static void isb_make_buffer (RenderPart *pa, LampRen *lar)
static ISBSampleAisb_alloc_sample_transp (ISBSampleA **isbsa, MemArena *mem)
static int isb_add_samples_transp (RenderPart *pa, ISBBranch *root, MemArena *memarena, ISBSampleA ***samplebuf)
static void isb_make_buffer_transp (RenderPart *pa, APixstr *apixbuf, LampRen *lar)
float ISB_getshadow (ShadeInput *shi, ShadBuf *shb)
void ISB_create (RenderPart *pa, APixstr *apixbuf)
void ISB_free (RenderPart *pa)

Variables

struct Render R
static volatile int g_break = 0

Detailed Description

Definition in file shadbuf.c.


Define Documentation

#define ACOMP   3

Definition at line 73 of file shadbuf.c.

Referenced by compress_shadowbuf(), readshadowbuf(), and readshadowbuf_halo().

#define BCOMP   2

Definition at line 72 of file shadbuf.c.

Referenced by compress_shadowbuf(), readshadowbuf(), and readshadowbuf_halo().

#define BSPMAX_DEPTH   32

Definition at line 1430 of file shadbuf.c.

Referenced by isb_bsp_insert().

#define BSPMAX_SAMPLE   128

Definition at line 1429 of file shadbuf.c.

Referenced by isb_bsp_insert(), isb_bsp_split(), and isb_bsp_split_init().

#define GCOMP   1

Definition at line 71 of file shadbuf.c.

Referenced by compress_shadowbuf(), readshadowbuf(), and readshadowbuf_halo().

#define RCOMP   0

Definition at line 70 of file shadbuf.c.


Typedef Documentation

typedef struct Boxf Boxf
typedef struct BSPFace BSPFace
typedef struct ISBBranch ISBBranch

Function Documentation

static void bound_boxf ( Boxf box,
const float  v1[3] 
) [static]
static void bound_rectf ( rctf box,
const float  v1[2] 
) [static]

Definition at line 1483 of file shadbuf.c.

References rctf::xmax, rctf::xmin, rctf::ymax, and rctf::ymin.

Referenced by isb_make_buffer(), and isb_make_buffer_transp().

static void bspface_init_strand ( BSPFace face) [static]
static int compress_deepsamples ( DeepSample dsample,
int  tot,
float  epsilon 
) [static]

Definition at line 185 of file shadbuf.c.

References div, KDL::epsilon, fabs(), max, MAX2, min, MIN2, DeepSample::v, and DeepSample::z.

Referenced by compress_deepshadowbuf().

static void compress_deepshadowbuf ( Render re,
ShadBuf shb,
APixstr apixbuf,
APixstrand apixbufstrand 
) [static]
static void compress_shadowbuf ( ShadBuf shb,
int *  rectz,
int  square 
) [static]
static void copy_to_ztile ( int *  rectz,
int  size,
int  x1,
int  y1,
int  tile,
char *  r1 
) [static]

Definition at line 88 of file shadbuf.c.

References size().

Referenced by compress_shadowbuf().

static float deep_alpha ( Render re,
int  obinr,
int  facenr,
int  strand 
) [static]
static void* do_shadow_thread ( void *  re_v) [static]
static int firstreadshadbuf ( ShadBuf shb,
ShadSampleBuf shsample,
int **  rz,
int  xs,
int  ys,
int  nr 
) [static]

Definition at line 943 of file shadbuf.c.

References ShadSampleBuf::cbuf, ShadSampleBuf::deepbuf, ShadBuf::size, and ShadSampleBuf::zbuf.

Referenced by testshadowbuf().

void freeshadowbuf ( LampRen lar)
static float* give_jitter_tab ( int  samp) [static]

Definition at line 125 of file shadbuf.c.

References BLI_initjit(), and jit.

Referenced by makeshadowbuf().

static void init_box ( Boxf box) [static]
static int isb_add_samples ( RenderPart pa,
ISBBranch root,
MemArena memarena,
ISBSample **  samplebuf 
) [static]
static int isb_add_samples_transp ( RenderPart pa,
ISBBranch root,
MemArena memarena,
ISBSampleA ***  samplebuf 
) [static]
static void isb_add_shadfac ( ISBShadfacA **  isbsapp,
MemArena mem,
int  obi,
int  facenr,
short  shadfac,
short  samples 
) [static]

Definition at line 2130 of file shadbuf.c.

References BLI_memarena_alloc(), NULL, R, and RE_QUAD_OFFS.

Referenced by isb_make_buffer(), and isb_make_buffer_transp().

static ISBSampleA* isb_alloc_sample_transp ( ISBSampleA **  isbsa,
MemArena mem 
) [static]

Definition at line 2343 of file shadbuf.c.

References BLI_memarena_alloc(), and NULL.

Referenced by isb_make_buffer_transp().

static void isb_bsp_face_inside ( ISBBranch bspn,
BSPFace face 
) [static]
static void isb_bsp_fillfaces ( Render re,
LampRen lar,
ISBBranch root 
) [static]
static int isb_bsp_insert ( ISBBranch root,
MemArena memarena,
ISBSample sample 
) [static]
static void isb_bsp_recalc_box ( ISBBranch root) [static]
static void isb_bsp_split ( ISBBranch root,
MemArena mem 
) [static]
static void isb_bsp_split_init ( ISBBranch root,
MemArena mem,
int  level 
) [static]
static void isb_bsp_test_face ( ZSpan zspan,
int  obi,
int  zvlnr,
float *  v1,
float *  v2,
float *  v3,
float *  v4 
) [static]
static void isb_bsp_test_strand ( ZSpan zspan,
int  obi,
int  zvlnr,
float *  v1,
float *  v2,
float *  v3,
float *  v4 
) [static]
void ISB_create ( RenderPart pa,
APixstr apixbuf 
)
void ISB_free ( RenderPart pa)
float ISB_getshadow ( ShadeInput shi,
ShadBuf shb 
)
static void isb_make_buffer ( RenderPart pa,
LampRen lar 
) [static]
static void isb_make_buffer_transp ( RenderPart pa,
APixstr apixbuf,
LampRen lar 
) [static]
static void make_jitter_weight_tab ( Render re,
ShadBuf shb,
short  filtertype 
) [static]
static void makedeepshadowbuf ( Render re,
LampRen lar,
float *  jitbuf 
) [static]
static void makeflatshadowbuf ( Render re,
LampRen lar,
float *  jitbuf 
) [static]
void makeshadowbuf ( struct Render re,
LampRen lar 
)
static int point_behind_strand ( const float  p[3],
BSPFace face 
) [static]

Definition at line 1667 of file shadbuf.c.

References BSPFace::len, BSPFace::radline_end, BSPFace::rc, sqrt(), and BSPFace::vec1.

Referenced by isb_bsp_face_inside().

static int point_behind_tria2d ( const float  p[3],
const float  v1[3],
const float  v2[3],
const float  v3[3] 
) [static]

Definition at line 1708 of file shadbuf.c.

References div.

Referenced by isb_bsp_face_inside().

static float readdeepshadowbuf ( ShadBuf shb,
ShadSampleBuf shsample,
int  bias,
int  xs,
int  ys,
int  zs 
) [static]

Definition at line 1007 of file shadbuf.c.

References ShadSampleBuf::deepbuf, readdeepvisibility(), ShadBuf::size, and ShadSampleBuf::totbuf.

Referenced by readshadowbuf().

static float readdeepvisibility ( DeepSample dsample,
int  tot,
int  z,
int  bias,
float *  biast 
) [static]

Definition at line 972 of file shadbuf.c.

References DeepSample::v, and DeepSample::z.

Referenced by readdeepshadowbuf().

static float readshadowbuf ( ShadBuf shb,
ShadSampleBuf shsample,
int  bias,
int  xs,
int  ys,
int  zs 
) [static]
static float readshadowbuf_halo ( ShadBuf shb,
ShadSampleBuf shsample,
int  xs,
int  ys,
int  zs 
) [static]
float shadow_halo ( LampRen lar,
const float  p1[3],
const float  p2[3] 
)

Determines the shadow factor for lamp <lar>, between <p1> and <p2>. (Which CS?)

Definition at line 1294 of file shadbuf.c.

References ShadBuf::buffers, co, ListBase::first, MIN2, mul_m4_v4(), ShadSampleBuf::next, readshadowbuf_halo(), LampRen::sh_zfac, ShadBuf::shadhalostep, LampRen::shb, ShadBuf::size, ShadBuf::totbuf, and ShadBuf::winmat.

Referenced by spothalo().

static void shadowbuf_autoclip ( Render re,
LampRen lar 
) [static]
static void shadowbuf_project_co ( float *  x,
float *  y,
float *  z,
ShadBuf shb,
const float  co[3] 
) [static]

Definition at line 1102 of file shadbuf.c.

References copy_v3_v3(), mul_m4_v4(), ShadBuf::persmat, ShadBuf::size, and size().

Referenced by testshadowbuf().

static int testclip_minmax ( const float  ho[4],
const float  minmax[4] 
) [static]

Definition at line 1931 of file shadbuf.c.

Referenced by isb_bsp_fillfaces().

float testshadowbuf ( struct Render re,
struct ShadBuf shb,
const float  rco[3],
const float  dxco[3],
const float  dyco[3],
float  inp,
float  mat_bias 
)

Determines the shadow factor for a face and lamp. There is some communication with global variables here.

Returns:
The shadow factors: 1.0 for no shadow, 0.0 for complete shadow.
Parameters:
shbThe shadowbuffer to find the shadow factor in.
inpThe inproduct between viewvector and ?

Definition at line 1118 of file shadbuf.c.

References add_v3_v3v3(), ShadBuf::bias, ShadBuf::buffers, fabs(), ListBase::first, firstreadshadbuf(), get_render_shadow_samples(), ShadBuf::jit, jit, ShadSampleBuf::next, NULL, Render::r, readshadowbuf(), ShadBuf::samp, shadowbuf_project_co(), ShadBuf::soft, ShadBuf::totbuf, and ShadBuf::weight.

Referenced by lamp_get_shadow(), render_lighting_halo(), and vol_get_shadow().

static int thread_break ( void *  UNUSEDarg) [static]

Definition at line 835 of file shadbuf.c.

References g_break.

Referenced by threaded_makeshadowbufs().

void threaded_makeshadowbufs ( Render re)
static int verg_deepsample ( const void *  poin1,
const void *  poin2 
) [static]

Definition at line 175 of file shadbuf.c.

References DeepSample::z.

Referenced by compress_deepshadowbuf().

static int viewpixel_to_lampbuf ( ShadBuf shb,
ObjectInstanceRen obi,
VlakRen vlr,
float  x,
float  y,
float  co_r[3] 
) [static]

Variable Documentation

volatile int g_break = 0 [static]

Definition at line 834 of file shadbuf.c.

Referenced by thread_break().

struct Render R

Definition at line 127 of file pipeline.c.