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

sss.c File Reference

#include <math.h>
#include <string.h>
#include <stdio.h>
#include "MEM_guardedalloc.h"
#include "BLI_math.h"
#include "BLI_blenlib.h"
#include "BLI_utildefines.h"
#include "BLI_ghash.h"
#include "BLI_memarena.h"
#include "PIL_time.h"
#include "DNA_material_types.h"
#include "BKE_colortools.h"
#include "BKE_global.h"
#include "BKE_main.h"
#include "BKE_material.h"
#include "BKE_node.h"
#include "BKE_scene.h"
#include "render_types.h"
#include "rendercore.h"
#include "renderdatabase.h"
#include "shading.h"
#include "sss.h"
#include "zbuf.h"

Go to the source code of this file.

Classes

struct  ScatterSettings
struct  ScatterPoint
struct  ScatterNode
struct  ScatterTree
struct  ScatterResult
struct  SSSData
struct  SSSPoints

Defines

#define RD_TABLE_RANGE   100.0f
#define RD_TABLE_RANGE_2   10000.0f
#define RD_TABLE_SIZE   10000
#define MAX_OCTREE_NODE_POINTS   8
#define MAX_OCTREE_DEPTH   15
#define SUBNODE_INDEX(co, split)   ((co[0]>=split[0]) + (co[1]>=split[1])*2 + (co[2]>=split[2])*4)

Typedefs

typedef struct ScatterPoint ScatterPoint
typedef struct ScatterNode ScatterNode
typedef struct ScatterResult ScatterResult
typedef struct SSSData SSSData
typedef struct SSSPoints SSSPoints

Functions

static float f_Rd (float alpha_, float A, float ro)
static float compute_reduced_albedo (ScatterSettings *ss)
static float Rd_rsquare (ScatterSettings *ss, float rr)
static float Rd (ScatterSettings *ss, float r)
static void approximate_Rd_rgb (ScatterSettings **ss, float rr, float *rd)
static void build_Rd_table (ScatterSettings *ss)
ScatterSettingsscatter_settings_new (float refl, float radius, float ior, float reflfac, float frontweight, float backweight)
void scatter_settings_free (ScatterSettings *ss)
static void add_radiance (ScatterTree *tree, float *frontrad, float *backrad, float area, float backarea, float rr, ScatterResult *result)
static void traverse_octree (ScatterTree *tree, ScatterNode *node, float *co, int self, ScatterResult *result)
static void compute_radiance (ScatterTree *tree, float *co, float *rad)
static void sum_leaf_radiance (ScatterTree *UNUSED(tree), ScatterNode *node)
static void sum_branch_radiance (ScatterTree *UNUSED(tree), ScatterNode *node)
static void sum_radiance (ScatterTree *tree, ScatterNode *node)
static void subnode_middle (int i, float *mid, float *subsize, float *submid)
static void create_octree_node (ScatterTree *tree, ScatterNode *node, float *mid, float *size, ScatterPoint **refpoints, int depth)
ScatterTreescatter_tree_new (ScatterSettings *ss[3], float scale, float error, float(*co)[3], float(*color)[3], float *area, int totpoint)
void scatter_tree_build (ScatterTree *tree)
void scatter_tree_sample (ScatterTree *tree, float *co, float *color)
void scatter_tree_free (ScatterTree *tree)
static void sss_create_tree_mat (Render *re, Material *mat)
void sss_add_points (Render *re, float(*co)[3], float(*color)[3], float *area, int totpoint)
static void sss_free_tree (SSSData *sss)
void make_sss_tree (Render *re)
void free_sss (Render *re)
int sample_sss (Render *re, Material *mat, float *co, float *color)
int sss_pass_done (struct Render *re, struct Material *mat)

Variables

Render R

Detailed Description

Definition in file sss.c.


Define Documentation

#define MAX_OCTREE_DEPTH   15

Definition at line 98 of file sss.c.

Referenced by create_octree_node().

#define MAX_OCTREE_NODE_POINTS   8

Definition at line 97 of file sss.c.

Referenced by create_octree_node().

#define RD_TABLE_RANGE   100.0f

Definition at line 93 of file sss.c.

Referenced by approximate_Rd_rgb(), and build_Rd_table().

#define RD_TABLE_RANGE_2   10000.0f

Definition at line 94 of file sss.c.

Referenced by approximate_Rd_rgb(), and build_Rd_table().

#define RD_TABLE_SIZE   10000

Definition at line 95 of file sss.c.

Referenced by approximate_Rd_rgb(), and build_Rd_table().

#define SUBNODE_INDEX (   co,
  split 
)    ((co[0]>=split[0]) + (co[1]>=split[1])*2 + (co[2]>=split[2])*4)

Definition at line 349 of file sss.c.

Referenced by create_octree_node(), and traverse_octree().


Typedef Documentation

typedef struct ScatterNode ScatterNode
typedef struct ScatterPoint ScatterPoint
typedef struct ScatterResult ScatterResult
typedef struct SSSData SSSData
typedef struct SSSPoints SSSPoints

Function Documentation

static void add_radiance ( ScatterTree tree,
float *  frontrad,
float *  backrad,
float  area,
float  backarea,
float  rr,
ScatterResult result 
) [static]
static void approximate_Rd_rgb ( ScatterSettings **  ss,
float  rr,
float *  rd 
) [static]
static void build_Rd_table ( ScatterSettings ss) [static]
static void compute_radiance ( ScatterTree tree,
float *  co,
float *  rad 
) [static]
static float compute_reduced_albedo ( ScatterSettings ss) [static]
static void create_octree_node ( ScatterTree tree,
ScatterNode node,
float *  mid,
float *  size,
ScatterPoint **  refpoints,
int  depth 
) [static]
static float f_Rd ( float  alpha_,
float  A,
float  ro 
) [static]

Definition at line 169 of file sss.c.

References expf, and sqrt().

Referenced by compute_reduced_albedo().

void free_sss ( Render re)
void make_sss_tree ( Render re)
static float Rd ( ScatterSettings ss,
float  r 
) [static]

Definition at line 229 of file sss.c.

References Rd_rsquare().

Referenced by build_Rd_table(), and SubsurfaceClosure::root_find_Rd().

static float Rd_rsquare ( ScatterSettings ss,
float  rr 
) [static]

Definition at line 216 of file sss.c.

References expf, M_PI, ScatterSettings::sigma, sqrt(), ScatterSettings::zr, and ScatterSettings::zv.

Referenced by approximate_Rd_rgb(), and Rd().

int sample_sss ( Render re,
Material mat,
float *  co,
float *  color 
)

Definition at line 1032 of file sss.c.

References BLI_ghash_lookup(), scatter_tree_sample(), Render::sss_hash, and SSSData::tree.

Referenced by shade_lamp_loop().

void scatter_settings_free ( ScatterSettings ss)

Definition at line 338 of file sss.c.

References MEM_freeN(), ScatterSettings::tableRd, and ScatterSettings::tableRd2.

Referenced by sss_free_tree().

ScatterSettings* scatter_settings_new ( float  refl,
float  radius,
float  ior,
float  reflfac,
float  frontweight,
float  backweight 
)
void scatter_tree_build ( ScatterTree tree)
void scatter_tree_free ( ScatterTree tree)
ScatterTree* scatter_tree_new ( ScatterSettings ss[3],
float  scale,
float  error,
float(*)  co[3],
float(*)  color[3],
float *  area,
int  totpoint 
)
void scatter_tree_sample ( ScatterTree tree,
float *  co,
float *  color 
)

Definition at line 817 of file sss.c.

References compute_radiance(), copy_v3_v3(), mul_v3_fl(), and ScatterTree::scale.

Referenced by sample_sss().

void sss_add_points ( Render re,
float(*)  co[3],
float(*)  color[3],
float *  area,
int  totpoint 
)
static void sss_create_tree_mat ( Render re,
Material mat 
) [static]
static void sss_free_tree ( SSSData sss) [static]

Definition at line 982 of file sss.c.

References MEM_freeN(), scatter_settings_free(), scatter_tree_free(), SSSData::ss, and SSSData::tree.

Referenced by free_sss().

int sss_pass_done ( struct Render re,
struct Material mat 
)

Definition at line 1051 of file sss.c.

References BLI_ghash_lookup(), Render::flag, RenderData::mode, Render::r, R_BAKING, R_SSS, and Render::sss_hash.

Referenced by shade_lamp_loop().

static void subnode_middle ( int  i,
float *  mid,
float *  subsize,
float *  submid 
) [static]

Definition at line 646 of file sss.c.

Referenced by create_octree_node().

static void sum_branch_radiance ( ScatterTree UNUSEDtree,
ScatterNode node 
) [static]
static void sum_leaf_radiance ( ScatterTree UNUSEDtree,
ScatterNode node 
) [static]
static void sum_radiance ( ScatterTree tree,
ScatterNode node 
) [static]

Definition at line 630 of file sss.c.

References ScatterNode::child, i, sum_branch_radiance(), sum_leaf_radiance(), and ScatterNode::totpoint.

Referenced by scatter_tree_build().

static void traverse_octree ( ScatterTree tree,
ScatterNode node,
float *  co,
int  self,
ScatterResult result 
) [static]

Variable Documentation

Definition at line 127 of file pipeline.c.