Blender V2.61 - r43446
Defines | Functions | Variables

rayshade.c File Reference

#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <float.h>
#include <assert.h>
#include "MEM_guardedalloc.h"
#include "DNA_material_types.h"
#include "DNA_lamp_types.h"
#include "BLI_blenlib.h"
#include "BLI_cpu.h"
#include "BLI_jitter.h"
#include "BLI_math.h"
#include "BLI_rand.h"
#include "BLI_utildefines.h"
#include "BKE_global.h"
#include "BKE_node.h"
#include "PIL_time.h"
#include "render_result.h"
#include "render_types.h"
#include "renderpipeline.h"
#include "rendercore.h"
#include "renderdatabase.h"
#include "pixelblending.h"
#include "pixelshading.h"
#include "shading.h"
#include "texture.h"
#include "volumetric.h"
#include "rayintersection.h"
#include "rayobject.h"
#include "raycounter.h"

Go to the source code of this file.

Defines

#define RAY_TRA   1
#define RAY_INSIDE   2
#define DEPTH_SHADOW_TRA   10

Functions

static int test_break (void *data)
static void RE_rayobject_config_control (RayObject *r, Render *re)
static RayObjectRE_rayobject_create (Render *re, int type, int size)
void freeraytree (Render *re)
static int is_raytraceable_vlr (Render *re, VlakRen *vlr)
static int is_raytraceable (Render *re, ObjectInstanceRen *obi)
RayObjectmakeraytree_object (Render *re, ObjectInstanceRen *obi)
static int has_special_rayobject (Render *re, ObjectInstanceRen *obi)
static void makeraytree_single (Render *re)
void makeraytree (Render *re)
static void shade_ray_set_derivative (ShadeInput *shi)
void shade_ray (Isect *is, ShadeInput *shi, ShadeResult *shr)
static int refraction (float refract[3], const float n[3], const float view[3], float index)
static void reflection_simple (float ref[3], float n[3], const float view[3])
static void reflection (float ref[3], float n[3], const float view[3], const float orn[3])
static float shade_by_transmission (Isect *is, ShadeInput *shi, ShadeResult *shr)
static void ray_fadeout_endcolor (float col[3], ShadeInput *origshi, ShadeInput *shi, ShadeResult *shr, Isect *isec, const float vec[3])
static void ray_fadeout (Isect *is, ShadeInput *shi, float col[3], const float blendcol[3], float dist_mir)
static void traceray (ShadeInput *origshi, ShadeResult *origshr, short depth, const float start[3], const float dir[3], float col[4], ObjectInstanceRen *obi, VlakRen *vlr, int traflag)
static void DP_energy (float *table, float vec[2], int tot, float xsize, float ysize)
static void jitter_plane_offset (float *jitter1, float *jitter2, int tot, float sizex, float sizey, float ofsx, float ofsy)
void init_jitter_plane (LampRen *lar)
static float * give_jitter_plane (LampRen *lar, int thread, int xs, int ys)
static void halton_sample (double *ht_invprimes, double *ht_nums, double *v)
static void hammersley_create (double *out, int n)
static struct QMCSamplerQMC_initSampler (int type, int tot)
static void QMC_initPixel (QMCSampler *qsa, int thread)
static void QMC_freeSampler (QMCSampler *qsa)
static void QMC_getSample (double *s, QMCSampler *qsa, int thread, int num)
static void QMC_samplePhong (float vec[3], QMCSampler *qsa, int thread, int num, float blur)
static void QMC_sampleRect (float vec[3], QMCSampler *qsa, int thread, int num, float sizex, float sizey)
static void QMC_sampleDisc (float vec[3], QMCSampler *qsa, int thread, int num, float radius)
static void QMC_sampleHemi (float vec[3], QMCSampler *qsa, int thread, int num)
void init_render_qmcsampler (Render *re)
static QMCSamplerget_thread_qmcsampler (Render *re, int thread, int type, int tot)
static void release_thread_qmcsampler (Render *UNUSED(re), int UNUSED(thread), QMCSampler *qsa)
void free_render_qmcsampler (Render *re)
static int adaptive_sample_variance (int samples, const float col[3], const float colsq[3], float thresh)
static int adaptive_sample_contrast_val (int samples, float prev, float val, float thresh)
static float get_avg_speed (ShadeInput *shi)
static void trace_refract (float col[4], ShadeInput *shi, ShadeResult *shr)
static void trace_reflect (float col[3], ShadeInput *shi, ShadeResult *shr, float fresnelfac)
void ray_trace (ShadeInput *shi, ShadeResult *shr)
static void addAlphaLight (float shadfac[4], const float col[3], float alpha, float filter)
static void ray_trace_shadow_tra (Isect *is, ShadeInput *origshi, int depth, int traflag, float col[4])
static int UNUSED_FUNCTION() ray_trace_shadow_rad (ShadeInput *ship, ShadeResult *shr)
static void RandomSpherical (float v[3])
static void DS_energy (float *sphere, int tot, float vec[3])
void init_ao_sphere (World *wrld)
static float * threadsafe_table_sphere (int test, int thread, int xs, int ys, int tot)
static float * sphere_sampler (int type, int resol, int thread, int xs, int ys, int reset)
static void ray_ao_qmc (ShadeInput *shi, float ao[3], float env[3])
static void ray_ao_spheresamp (ShadeInput *shi, float ao[3], float env[3])
void ray_ao (ShadeInput *shi, float ao[3], float env[3])
static void ray_shadow_jittered_coords (ShadeInput *shi, int max, float jitco[RE_MAX_OSA][3], int *totjitco)
static void ray_shadow_qmc (ShadeInput *shi, LampRen *lar, const float lampco[3], float shadfac[4], Isect *isec)
static void ray_shadow_jitter (ShadeInput *shi, LampRen *lar, const float lampco[3], float shadfac[4], Isect *isec)
void ray_shadow (ShadeInput *shi, LampRen *lar, float shadfac[4])

Variables

struct Render R

Detailed Description

Definition in file rayshade.c.


Define Documentation

#define DEPTH_SHADOW_TRA   10

Definition at line 75 of file rayshade.c.

Referenced by ray_shadow(), ray_shadow_jitter(), and ray_shadow_qmc().

#define RAY_INSIDE   2

Definition at line 73 of file rayshade.c.

Referenced by trace_refract(), and traceray().

#define RAY_TRA   1

Definition at line 72 of file rayshade.c.

Referenced by ray_trace_shadow_tra().


Function Documentation

static int adaptive_sample_contrast_val ( int  samples,
float  prev,
float  val,
float  thresh 
) [static]

Definition at line 1278 of file rayshade.c.

References fabsf.

Referenced by ray_ao_qmc().

static int adaptive_sample_variance ( int  samples,
const float  col[3],
const float  colsq[3],
float  thresh 
) [static]

Definition at line 1256 of file rayshade.c.

References thresh.

Referenced by ray_shadow_qmc(), trace_reflect(), and trace_refract().

static void addAlphaLight ( float  shadfac[4],
const float  col[3],
float  alpha,
float  filter 
) [static]

Definition at line 1601 of file rayshade.c.

References fb().

Referenced by ray_trace_shadow_tra().

static void DP_energy ( float *  table,
float  vec[2],
int  tot,
float  xsize,
float  ysize 
) [static]

Definition at line 896 of file rayshade.c.

References floorf, min, MIN2, Render::result, and table.

Referenced by init_jitter_plane().

static void DS_energy ( float *  sphere,
int  tot,
float  vec[3] 
) [static]

Definition at line 1765 of file rayshade.c.

References add_v3_v3(), mul_v3_fl(), normalize_v3(), sub_v3_v3v3(), and QMCSampler::tot.

Referenced by init_ao_sphere().

void free_render_qmcsampler ( Render re)
void freeraytree ( Render re)
static float get_avg_speed ( ShadeInput shi) [static]

Definition at line 1289 of file rayshade.c.

References PASS_VECTOR_MAX, sqrt(), and ShadeInput::winspeed.

Referenced by ray_ao_qmc().

static QMCSampler* get_thread_qmcsampler ( Render re,
int  thread,
int  type,
int  tot 
) [static]
static float* give_jitter_plane ( LampRen lar,
int  thread,
int  xs,
int  ys 
) [static]
static void halton_sample ( double *  ht_invprimes,
double *  ht_nums,
double *  v 
) [static]

Definition at line 1013 of file rayshade.c.

References credits_svn_gen::e, fabs(), i, and Render::r.

Referenced by QMC_initPixel().

static void hammersley_create ( double *  out,
int  n 
) [static]

Definition at line 1044 of file rayshade.c.

References p.

Referenced by QMC_initSampler().

static int has_special_rayobject ( Render re,
ObjectInstanceRen obi 
) [static]
void init_ao_sphere ( World wrld)
void init_jitter_plane ( LampRen lar)
void init_render_qmcsampler ( Render re)

Definition at line 1206 of file rayshade.c.

References BLENDER_MAX_THREADS, MEM_callocN(), and Render::qmcsamplers.

Referenced by RE_Database_Baking(), and RE_Database_FromScene().

static int is_raytraceable ( Render re,
ObjectInstanceRen obi 
) [static]
static int is_raytraceable_vlr ( Render re,
VlakRen vlr 
) [static]
static void jitter_plane_offset ( float *  jitter1,
float *  jitter2,
int  tot,
float  sizex,
float  sizey,
float  ofsx,
float  ofsy 
) [static]

Definition at line 930 of file rayshade.c.

Referenced by give_jitter_plane(), and init_jitter_plane().

void makeraytree ( Render re)
RayObject* makeraytree_object ( Render re,
ObjectInstanceRen obi 
) [read]
static void makeraytree_single ( Render re) [static]
static void QMC_freeSampler ( QMCSampler qsa) [static]

Definition at line 1107 of file rayshade.c.

References MEM_freeN(), and QMCSampler::samp2d.

Referenced by free_render_qmcsampler().

static void QMC_getSample ( double *  s,
QMCSampler qsa,
int  thread,
int  num 
) [static]
static void QMC_initPixel ( QMCSampler qsa,
int  thread 
) [static]
static struct QMCSampler* QMC_initSampler ( int  type,
int  tot 
) [static, read]
static void QMC_sampleDisc ( float  vec[3],
QMCSampler qsa,
int  thread,
int  num,
float  radius 
) [static]

Definition at line 1155 of file rayshade.c.

References cosf, M_PI, QMC_getSample(), sinf, KDL::sqr(), and sqrt().

Referenced by ray_shadow_qmc().

static void QMC_sampleHemi ( float  vec[3],
QMCSampler qsa,
int  thread,
int  num 
) [static]

Definition at line 1171 of file rayshade.c.

References cosf, M_PI, QMC_getSample(), sinf, KDL::sqr(), and sqrt().

Referenced by ray_ao_qmc().

static void QMC_samplePhong ( float  vec[3],
QMCSampler qsa,
int  thread,
int  num,
float  blur 
) [static]

Definition at line 1126 of file rayshade.c.

References cosf, M_PI, pow(), QMC_getSample(), sinf, KDL::sqr(), and sqrt().

Referenced by trace_reflect(), and trace_refract().

static void QMC_sampleRect ( float  vec[3],
QMCSampler qsa,
int  thread,
int  num,
float  sizex,
float  sizey 
) [static]

Definition at line 1143 of file rayshade.c.

References QMC_getSample().

Referenced by ray_shadow_qmc().

static void RandomSpherical ( float  v[3]) [static]

Definition at line 1751 of file rayshade.c.

References BLI_frand(), cosf, sinf, and sqrt().

Referenced by init_ao_sphere(), and sphere_sampler().

void ray_ao ( ShadeInput shi,
float  ao[3],
float  env[3] 
)
static void ray_ao_qmc ( ShadeInput shi,
float  ao[3],
float  env[3] 
) [static]
static void ray_ao_spheresamp ( ShadeInput shi,
float  ao[3],
float  env[3] 
) [static]
static void ray_fadeout ( Isect is,
ShadeInput shi,
float  col[3],
const float  blendcol[3],
float  dist_mir 
) [static]

Definition at line 712 of file rayshade.c.

References ShadeInput::co, len_v3v3(), and Isect::start.

Referenced by traceray().

static void ray_fadeout_endcolor ( float  col[3],
ShadeInput origshi,
ShadeInput shi,
ShadeResult shr,
Isect isec,
const float  vec[3] 
) [static]
void ray_shadow ( ShadeInput shi,
LampRen lar,
float  shadfac[4] 
)
static void ray_shadow_jitter ( ShadeInput shi,
LampRen lar,
const float  lampco[3],
float  shadfac[4],
Isect isec 
) [static]
static void ray_shadow_jittered_coords ( ShadeInput shi,
int  max,
float  jitco[RE_MAX_OSA][3],
int *  totjitco 
) [static]
static void ray_shadow_qmc ( ShadeInput shi,
LampRen lar,
const float  lampco[3],
float  shadfac[4],
Isect isec 
) [static]
void ray_trace ( ShadeInput shi,
ShadeResult shr 
)
static int UNUSED_FUNCTION() ray_trace_shadow_rad ( ShadeInput ship,
ShadeResult shr 
) [static]
static void ray_trace_shadow_tra ( Isect is,
ShadeInput origshi,
int  depth,
int  traflag,
float  col[4] 
) [static]
static void RE_rayobject_config_control ( RayObject r,
Render re 
) [static]
static RayObject* RE_rayobject_create ( Render re,
int  type,
int  size 
) [static]
static void reflection ( float  ref[3],
float  n[3],
const float  view[3],
const float  orn[3] 
) [static]
static void reflection_simple ( float  ref[3],
float  n[3],
const float  view[3] 
) [static]

Definition at line 622 of file rayshade.c.

References dot_v3v3(), and madd_v3_v3v3fl().

Referenced by reflection(), trace_reflect(), trace_refract(), and traceray().

static int refraction ( float  refract[3],
const float  n[3],
const float  view[3],
float  index 
) [static]

Definition at line 595 of file rayshade.c.

References copy_v3_v3(), dot(), and sqrtf.

Referenced by trace_refract(), and traceray().

static void release_thread_qmcsampler ( Render UNUSEDre,
int   UNUSEDthread,
QMCSampler qsa 
) [static]

Definition at line 1232 of file rayshade.c.

References QMCSampler::used.

Referenced by ray_ao_qmc(), ray_shadow_qmc(), trace_reflect(), and trace_refract().

static float shade_by_transmission ( Isect is,
ShadeInput shi,
ShadeResult shr 
) [static]
void shade_ray ( Isect is,
ShadeInput shi,
ShadeResult shr 
)
static void shade_ray_set_derivative ( ShadeInput shi) [static]
static float* sphere_sampler ( int  type,
int  resol,
int  thread,
int  xs,
int  ys,
int  reset 
) [static]
static int test_break ( void *  data) [static]
static float* threadsafe_table_sphere ( int  test,
int  thread,
int  xs,
int  ys,
int  tot 
) [static]

Definition at line 1822 of file rayshade.c.

References BLENDER_MAX_THREADS, NULL, and R.

Referenced by sphere_sampler().

static void trace_reflect ( float  col[3],
ShadeInput shi,
ShadeResult shr,
float  fresnelfac 
) [static]
static void trace_refract ( float  col[4],
ShadeInput shi,
ShadeResult shr 
) [static]
static void traceray ( ShadeInput origshi,
ShadeResult origshr,
short  depth,
const float  start[3],
const float  dir[3],
float  col[4],
ObjectInstanceRen obi,
VlakRen vlr,
int  traflag 
) [static]

Variable Documentation

struct Render R

Definition at line 127 of file pipeline.c.