Blender V2.61 - r43446
|
#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) |
ScatterSettings * | scatter_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) |
ScatterTree * | scatter_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 |
Definition in file sss.c.
#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().
Definition at line 349 of file sss.c.
Referenced by create_octree_node(), and traverse_octree().
typedef struct ScatterNode ScatterNode |
typedef struct ScatterPoint ScatterPoint |
typedef struct ScatterResult ScatterResult |
static void add_radiance | ( | ScatterTree * | tree, |
float * | frontrad, | ||
float * | backrad, | ||
float | area, | ||
float | backarea, | ||
float | rr, | ||
ScatterResult * | result | ||
) | [static] |
Definition at line 352 of file sss.c.
References approximate_Rd_rgb(), ScatterResult::backrad, ScatterResult::backrdsum, ScatterResult::rad, ScatterResult::rdsum, and ScatterTree::ss.
Referenced by traverse_octree().
static void approximate_Rd_rgb | ( | ScatterSettings ** | ss, |
float | rr, | ||
float * | rd | ||
) | [static] |
Definition at line 240 of file sss.c.
References Rd_rsquare(), RD_TABLE_RANGE, RD_TABLE_RANGE_2, RD_TABLE_SIZE, sqrt(), ScatterSettings::tableRd, and ScatterSettings::tableRd2.
Referenced by add_radiance().
static void build_Rd_table | ( | ScatterSettings * | ss | ) | [static] |
Definition at line 280 of file sss.c.
References i, MEM_mallocN(), Rd(), RD_TABLE_RANGE, RD_TABLE_RANGE_2, RD_TABLE_SIZE, size(), sqrt(), ScatterSettings::tableRd, and ScatterSettings::tableRd2.
Referenced by scatter_settings_new().
static void compute_radiance | ( | ScatterTree * | tree, |
float * | co, | ||
float * | rad | ||
) | [static] |
Definition at line 437 of file sss.c.
References add_v3_v3v3(), ScatterResult::backrad, ScatterResult::backrdsum, ScatterSettings::backweight, ScatterSettings::color, copy_v3_v3(), credits_svn_gen::e, ScatterSettings::frontweight, MAX2, mul_v3_fl(), ScatterResult::rad, ScatterResult::rdsum, ScatterTree::root, ScatterTree::ss, and traverse_octree().
Referenced by scatter_tree_sample().
static float compute_reduced_albedo | ( | ScatterSettings * | ss | ) | [static] |
Definition at line 177 of file sss.c.
References ScatterSettings::A, simple_enum_gen::d, credits_svn_gen::e, f_Rd(), fabsf, i, and ScatterSettings::ro.
Referenced by scatter_settings_new().
static void create_octree_node | ( | ScatterTree * | tree, |
ScatterNode * | node, | ||
float * | mid, | ||
float * | size, | ||
ScatterPoint ** | refpoints, | ||
int | depth | ||
) | [static] |
Definition at line 655 of file sss.c.
References ScatterTree::arena, BLI_memarena_alloc(), ScatterNode::child, co, i, MAX_OCTREE_DEPTH, MAX_OCTREE_NODE_POINTS, NULL, ScatterNode::points, ScatterNode::split, SUBNODE_INDEX, subnode_middle(), ScatterTree::tmppoints, and ScatterNode::totpoint.
Referenced by scatter_tree_build().
static float f_Rd | ( | float | alpha_, |
float | A, | ||
float | ro | ||
) | [static] |
Definition at line 169 of file sss.c.
Referenced by compute_reduced_albedo().
void free_sss | ( | Render * | re | ) |
Definition at line 1016 of file sss.c.
References BLI_ghash_free(), BLI_ghashIterator_free(), BLI_ghashIterator_getValue(), BLI_ghashIterator_isDone(), BLI_ghashIterator_new(), BLI_ghashIterator_step(), NULL, sss_free_tree(), and Render::sss_hash.
Referenced by RE_Database_Free().
void make_sss_tree | ( | Render * | re | ) |
Definition at line 993 of file sss.c.
References BLI_ghash_new(), BLI_ghashutil_ptrcmp(), BLI_ghashutil_ptrhash(), ListBase::first, Material::flag, G, Render::i, Material::id, RenderStats::infostr, MA_DIFF_SSS, MA_IS_USED, Render::main, Main::mat, ID::next, Render::sdh, sss_create_tree_mat(), Material::sss_flag, Render::sss_hash, Render::stats_draw, and ID::us.
Referenced by RE_Database_FromScene().
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().
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 | ||
) |
Definition at line 301 of file sss.c.
References ScatterSettings::A, ScatterSettings::alpha_, ScatterSettings::backweight, build_Rd_table(), ScatterSettings::color, compute_reduced_albedo(), ScatterSettings::D, ScatterSettings::eta, ScatterSettings::Fdr, ScatterSettings::frontweight, ScatterSettings::invsigma_t_, ScatterSettings::ld, MEM_callocN(), MIN2, ScatterSettings::ro, ScatterSettings::sigma, ScatterSettings::sigma_a, ScatterSettings::sigma_s_, ScatterSettings::sigma_t_, sqrtf, ScatterSettings::zr, and ScatterSettings::zv.
Referenced by sss_create_tree_mat().
void scatter_tree_build | ( | ScatterTree * | tree | ) |
Definition at line 778 of file sss.c.
References ScatterTree::arena, BLI_memarena_alloc(), BLI_memarena_new(), BLI_memarena_use_calloc(), create_octree_node(), ScatterTree::max, MEM_callocN(), MEM_freeN(), ScatterTree::min, NULL, ScatterTree::points, ScatterNode::points, ScatterTree::refpoints, ScatterTree::root, size(), sum_radiance(), ScatterTree::tmppoints, ScatterNode::totpoint, and ScatterTree::totpoint.
Referenced by sss_create_tree_mat().
void scatter_tree_free | ( | ScatterTree * | tree | ) |
Definition at line 827 of file sss.c.
References ScatterTree::arena, BLI_memarena_free(), MEM_freeN(), ScatterTree::points, and ScatterTree::refpoints.
Referenced by sss_free_tree().
ScatterTree* scatter_tree_new | ( | ScatterSettings * | ss[3], |
float | scale, | ||
float | error, | ||
float(*) | co[3], | ||
float(*) | color[3], | ||
float * | area, | ||
int | totpoint | ||
) |
Definition at line 737 of file sss.c.
References ScatterPoint::area, ScatterPoint::back, co, MakeCursor::color, copy_v3_v3(), DO_MINMAX, error(), ScatterTree::error, fabsf, i, INIT_MINMAX, ScatterTree::max, MEM_callocN(), ScatterTree::min, mul_v3_fl(), ScatterTree::points, ScatterTree::refpoints, ScatterTree::scale, ScatterTree::ss, and ScatterTree::totpoint.
Referenced by sss_create_tree_mat().
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 | ||
) |
Definition at line 964 of file sss.c.
References SSSPoints::area, BLI_addtail(), BLI_lock_thread(), BLI_unlock_thread(), co, SSSPoints::co, MakeCursor::color, SSSPoints::color, LOCK_CUSTOM1, MEM_callocN(), p, Render::sss_points, and SSSPoints::totpoint.
Referenced by zbufshade_sss_tile().
Definition at line 854 of file sss.c.
References SSSPoints::area, BLI_freelistN(), BLI_ghash_insert(), BLI_rw_mutex_lock(), BLI_rw_mutex_unlock(), SSSPoints::co, co, SSSPoints::color, ListBase::first, get_render_aosss_error(), Render::i, ListBase::last, MEM_callocN(), MEM_freeN(), MEM_mallocN(), RenderData::mode, SSSPoints::next, NULL, Render::osa, p, RenderStats::partsdone, Render::r, R_OSA, R_PREVIEWBUTS, RE_FreeRenderResult(), RE_TileProcessor(), Render::result, Render::resultmutex, scatter_settings_new(), scatter_tree_build(), scatter_tree_new(), RenderData::scemode, SSSData::ss, Material::sss_back, Material::sss_col, Material::sss_colfac, Material::sss_error, Material::sss_front, Render::sss_hash, Material::sss_ior, Render::sss_mat, Render::sss_points, Material::sss_radius, Material::sss_scale, Render::tbh, Render::test_break, THREAD_LOCK_WRITE, SSSPoints::totpoint, and SSSData::tree.
Referenced by make_sss_tree().
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().
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] |
Definition at line 550 of file sss.c.
References ScatterNode::area, ScatterNode::backarea, ScatterNode::backrad, ScatterNode::child, ScatterNode::co, credits_svn_gen::e, fabsf, i, NULL, and ScatterNode::rad.
Referenced by sum_radiance().
static void sum_leaf_radiance | ( | ScatterTree * | UNUSEDtree, |
ScatterNode * | node | ||
) | [static] |
Definition at line 476 of file sss.c.
References ScatterNode::area, ScatterPoint::area, ScatterPoint::back, ScatterNode::backarea, ScatterNode::backrad, ScatterPoint::co, ScatterNode::co, credits_svn_gen::e, fabsf, i, p, ScatterNode::points, ScatterPoint::rad, ScatterNode::rad, and ScatterNode::totpoint.
Referenced by sum_radiance().
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] |
Definition at line 386 of file sss.c.
References add_radiance(), ScatterNode::area, ScatterPoint::area, ScatterPoint::back, ScatterNode::backarea, ScatterNode::backrad, ScatterNode::child, ScatterNode::co, ScatterPoint::co, dot_v3v3(), ScatterTree::error, i, NULL, p, ScatterNode::points, ScatterNode::rad, ScatterPoint::rad, ScatterNode::split, sub_v3_v3v3(), SUBNODE_INDEX, and ScatterNode::totpoint.
Referenced by compute_radiance().
Definition at line 127 of file pipeline.c.