2011-02-23 10:52:22 +00:00
|
|
|
/*
|
2006-12-05 16:43:01 +00:00
|
|
|
* ***** 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,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2006-12-05 16:43:01 +00:00
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2006 Blender Foundation
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
*/
|
|
|
|
|
2011-02-27 19:31:27 +00:00
|
|
|
/** \file blender/render/intern/include/shading.h
|
|
|
|
* \ingroup render
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2006-12-05 16:43:01 +00:00
|
|
|
struct ShadeInput;
|
|
|
|
struct ShadeResult;
|
|
|
|
struct RenderPart;
|
|
|
|
struct RenderLayer;
|
|
|
|
struct PixStr;
|
2006-12-08 09:40:44 +00:00
|
|
|
struct LampRen;
|
2007-12-04 13:57:28 +00:00
|
|
|
struct VlakRen;
|
|
|
|
struct StrandPoint;
|
2011-05-10 13:11:36 +00:00
|
|
|
struct ObjectInstanceRen;
|
2008-09-24 07:38:12 +00:00
|
|
|
struct Isect;
|
2006-12-05 16:43:01 +00:00
|
|
|
|
|
|
|
/* shadeinput.c */
|
|
|
|
|
2006-12-21 13:47:27 +00:00
|
|
|
#define RE_MAX_OSA 16
|
2006-12-05 16:43:01 +00:00
|
|
|
|
|
|
|
/* needed to calculate shadow and AO for an entire pixel */
|
|
|
|
typedef struct ShadeSample {
|
2008-01-28 16:33:59 +00:00
|
|
|
int tot; /* amount of shi in use, can be 1 for not FULL_OSA */
|
2018-06-08 08:07:48 +02:00
|
|
|
|
2008-01-28 16:33:59 +00:00
|
|
|
RenderLayer *rlpp[RE_MAX_OSA]; /* fast lookup from sample to renderlayer (fullsample buf) */
|
2018-06-08 08:07:48 +02:00
|
|
|
|
2006-12-08 09:40:44 +00:00
|
|
|
/* could be malloced once */
|
2006-12-21 13:47:27 +00:00
|
|
|
ShadeInput shi[RE_MAX_OSA];
|
|
|
|
ShadeResult shr[RE_MAX_OSA];
|
2006-12-05 16:43:01 +00:00
|
|
|
} ShadeSample;
|
|
|
|
|
|
|
|
|
|
|
|
/* also the node shader callback */
|
|
|
|
void shade_material_loop(struct ShadeInput *shi, struct ShadeResult *shr);
|
|
|
|
|
Render Instancing
=================
Big commit, but little user visible changes.
- Dupliverts and duplifaces are now rendered as instances, instead
of storing all of the geometry for each dupli, now an instance is
created with a matrix transform refering to the source object.
This should allow us to render tree leaves more memory efficient.
- Radiosity and to some degree raytracing of such objects is not
really efficient still. For radiosity this is fundamentally hard
to solve, but raytracing an octree could be created for each object,
but the current octree code with it's fixed size doesn't allow this
efficiently.
- The regression tests survived, but with I expect that some bugs will
pop up .. hopefully not too many :).
Implementation Notes
====================
- Dupligroups and linked meshes are not rendered as instances yet,
since they can in fact be different due to various reasons,
instancing of these types of duplis that are the same can be added
for them at a later point.
- Each ObjectRen now stores it's own database, instead of there being
one big databases of faces, verts, .. . Which objects that are actually
rendered are defined by the list of ObjectRenInstances, which all refer
to an ObjectRen.
- Homogeneous coordinatess and clipping is now not stored in vertices
anymore, but instead computed on the fly. This couldn't work for
instances. That does mean some extra computation has to be done, but
memory lookups can be slow too, and this saves some memory. Overall
I didn't find a significant speed impact.
- OSA rendering for solid and ztransp now is different. Instead of e.g.
going 8 times over the databases times and rendering the z-buffer, it
now goes over the database once and renders each polygon 8 times. That
was necessary to keep instances efficient, and can also give some
performance improvement without instances.
- There was already instancing support in the yafray export code, now it
uses Blender's render instances for export.
- UV and color layer storage in the render was a bit messy before, now
should be easier to understand.
- convertblender.c was reorganized somewhat. Regular render, speedvector
and baking now use a single function to create the database, previously
there was code duplicated for it.
- Some of these changes were done with future multithreading of scene
and shadow buffer creation in mind, though especially for scene creation
much work remains to be done to make it threadsafe, since it also involves
a lot of code from blenkernel, and there is an ugly conflict with the way
dupli groups work here .. though in the render code itself it's almost there.
2007-12-15 20:41:45 +00:00
|
|
|
void shade_input_set_triangle_i(struct ShadeInput *shi, struct ObjectInstanceRen *obi, struct VlakRen *vlr, short i1, short i2, short i3);
|
2017-08-03 07:10:20 +10:00
|
|
|
void shade_input_set_triangle(struct ShadeInput *shi, int obi, int facenr, int normal_flip);
|
2006-12-05 16:43:01 +00:00
|
|
|
void shade_input_copy_triangle(struct ShadeInput *shi, struct ShadeInput *from);
|
2012-10-15 23:11:59 +00:00
|
|
|
void shade_input_calc_viewco(struct ShadeInput *shi, float x, float y, float z, float view[3], float dxyview[2], float co[3], float dxco[3], float dyco[3]);
|
2008-10-07 15:01:44 +00:00
|
|
|
void shade_input_set_viewco(struct ShadeInput *shi, float x, float y, float sx, float sy, float z);
|
2006-12-05 16:43:01 +00:00
|
|
|
void shade_input_set_uv(struct ShadeInput *shi);
|
|
|
|
void shade_input_set_normals(struct ShadeInput *shi);
|
2011-02-22 17:19:02 +00:00
|
|
|
void shade_input_set_vertex_normals(struct ShadeInput *shi);
|
Render Instancing
=================
Big commit, but little user visible changes.
- Dupliverts and duplifaces are now rendered as instances, instead
of storing all of the geometry for each dupli, now an instance is
created with a matrix transform refering to the source object.
This should allow us to render tree leaves more memory efficient.
- Radiosity and to some degree raytracing of such objects is not
really efficient still. For radiosity this is fundamentally hard
to solve, but raytracing an octree could be created for each object,
but the current octree code with it's fixed size doesn't allow this
efficiently.
- The regression tests survived, but with I expect that some bugs will
pop up .. hopefully not too many :).
Implementation Notes
====================
- Dupligroups and linked meshes are not rendered as instances yet,
since they can in fact be different due to various reasons,
instancing of these types of duplis that are the same can be added
for them at a later point.
- Each ObjectRen now stores it's own database, instead of there being
one big databases of faces, verts, .. . Which objects that are actually
rendered are defined by the list of ObjectRenInstances, which all refer
to an ObjectRen.
- Homogeneous coordinatess and clipping is now not stored in vertices
anymore, but instead computed on the fly. This couldn't work for
instances. That does mean some extra computation has to be done, but
memory lookups can be slow too, and this saves some memory. Overall
I didn't find a significant speed impact.
- OSA rendering for solid and ztransp now is different. Instead of e.g.
going 8 times over the databases times and rendering the z-buffer, it
now goes over the database once and renders each polygon 8 times. That
was necessary to keep instances efficient, and can also give some
performance improvement without instances.
- There was already instancing support in the yafray export code, now it
uses Blender's render instances for export.
- UV and color layer storage in the render was a bit messy before, now
should be easier to understand.
- convertblender.c was reorganized somewhat. Regular render, speedvector
and baking now use a single function to create the database, previously
there was code duplicated for it.
- Some of these changes were done with future multithreading of scene
and shadow buffer creation in mind, though especially for scene creation
much work remains to be done to make it threadsafe, since it also involves
a lot of code from blenkernel, and there is an ugly conflict with the way
dupli groups work here .. though in the render code itself it's almost there.
2007-12-15 20:41:45 +00:00
|
|
|
void shade_input_flip_normals(struct ShadeInput *shi);
|
2006-12-05 16:43:01 +00:00
|
|
|
void shade_input_set_shade_texco(struct ShadeInput *shi);
|
2007-12-04 13:57:28 +00:00
|
|
|
void shade_input_set_strand(struct ShadeInput *shi, struct StrandRen *strand, struct StrandPoint *spoint);
|
|
|
|
void shade_input_set_strand_texco(struct ShadeInput *shi, struct StrandRen *strand, struct StrandVert *svert, struct StrandPoint *spoint);
|
2006-12-05 16:43:01 +00:00
|
|
|
void shade_input_do_shade(struct ShadeInput *shi, struct ShadeResult *shr);
|
|
|
|
|
2009-07-17 02:43:15 +00:00
|
|
|
void shade_input_init_material(struct ShadeInput *shi);
|
2006-12-08 09:40:44 +00:00
|
|
|
void shade_input_initialize(struct ShadeInput *shi, struct RenderPart *pa, struct RenderLayer *rl, int sample);
|
|
|
|
|
2006-12-05 16:43:01 +00:00
|
|
|
void shade_sample_initialize(struct ShadeSample *ssamp, struct RenderPart *pa, struct RenderLayer *rl);
|
2006-12-08 09:40:44 +00:00
|
|
|
void shade_samples_do_AO(struct ShadeSample *ssamp);
|
2008-01-17 19:27:16 +00:00
|
|
|
void shade_samples_fill_with_ps(struct ShadeSample *ssamp, struct PixStr *ps, int x, int y);
|
2006-12-05 16:43:01 +00:00
|
|
|
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);
|
|
|
|
|
|
|
|
void calc_R_ref(struct ShadeInput *shi);
|
|
|
|
|
2016-02-18 01:35:52 +01:00
|
|
|
void barycentric_differentials_from_position(
|
|
|
|
const float co[3], const float v1[3], const float v2[3], const float v3[3],
|
|
|
|
const float dxco[3], const float dyco[3], const float facenor[3], const bool differentials,
|
|
|
|
float *u, float *v, float *dx_u, float *dx_v, float *dy_u, float *dy_v);
|
2006-12-05 16:43:01 +00:00
|
|
|
|
|
|
|
/* shadeoutput. */
|
|
|
|
void shade_lamp_loop(struct ShadeInput *shi, struct ShadeResult *shr);
|
|
|
|
|
|
|
|
void shade_color(struct ShadeInput *shi, ShadeResult *shr);
|
|
|
|
|
|
|
|
void ambient_occlusion(struct ShadeInput *shi);
|
2010-02-07 15:24:10 +00:00
|
|
|
void environment_lighting_apply(struct ShadeInput *shi, struct ShadeResult *shr);
|
2006-12-05 16:43:01 +00:00
|
|
|
|
2008-09-22 01:51:24 +00:00
|
|
|
ListBase *get_lights(struct ShadeInput *shi);
|
2011-09-24 14:34:24 +00:00
|
|
|
float lamp_get_visibility(struct LampRen *lar, const float co[3], float lv[3], float *dist);
|
|
|
|
void lamp_get_shadow(struct LampRen *lar, ShadeInput *shi, float inp, float shadfac[4], int do_real);
|
2006-12-05 16:43:01 +00:00
|
|
|
|
2016-12-15 15:03:28 +03:00
|
|
|
float fresnel_fac(const float view[3], const float vn[3], float fresnel, float fac);
|
* Volumetrics scene integration
Now other objects (and sky) correctly render if they're partially
inside or behind a volume. Previously all other objects were ignored,
and volumes just rendered on black. The colour of surfaces inside or
behind the volume gets correctly attenuated by the density of the
volume in between - i.e. thicker volumes will block the light coming
from behind. However, other solid objects don't receive volume shadows
yet, this is to be worked on later.
http://mke3.net/blender/devel/rendering/volumetrics/vol_inside_behind.png
Currently this uses raytracing to find intersections within the volume,
and rays are also traced from the volume, heading behind into the
scene, to see what's behind it (similar effect to ray transp with IOR
1). Because of this, objects inside or behind the volume will not be
antialiased. Perhaps I can come up with a solution for this, but until
then, for antialiasing, you can turn on Full OSA (warning, this will
incur a slowdown). Of course you can always avoid this by rendering
volumes on a separate renderlayer, and compositing in post, too.
Another idea I've started thinking about is to calculate an alpha
value, then use ztransp to overlay on top of other objects. This won't
accurately attenuate and absorb light coming from objects behind the
volume, but for some situations it may be fine, and faster too.
2008-09-24 02:52:47 +00:00
|
|
|
|
|
|
|
/* rayshade.c */
|
|
|
|
extern void shade_ray(struct Isect *is, struct ShadeInput *shi, struct ShadeResult *shr);
|