From 78c50f7af1d694252984885e0eac87682647e2d2 Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Fri, 26 Sep 2008 01:54:31 +0000 Subject: Wheee! Initial commit for supporting rendering particles directly as volume density. It works by looking up how many particles are within a specified radius of the currently shaded point and using that to calculate density (which is used just as any other measure of density would be). http://mke3.net/blender/devel/rendering/volumetrics/smoke_test01.mov http://mke3.net/blender/devel/rendering/volumetrics/smoke_test01.blend Right now it's an early implementation, just to see that it can work - it may end up changing quite a bit. Currently, it's just a single switch on the volume material - it looks up all particles in the scene for density at the current shaded point in world space (so the volume region must enclose the particles in order to render them. This will probably change - one idea I have is to make the particle density estimation a procedural texture with options for: * the object and particle system to use * the origin of the co-ordinate system, i.e. object center, world space, etc. This would allow you in a sense, to instance particle systems for render - you only need to bake one particle system, but you can render it anywhere. Anyway, plenty of work to do here, firstly on getting a nice density evaluation with falloff etc... --- source/blender/render/intern/include/render_types.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'source/blender/render/intern/include/render_types.h') diff --git a/source/blender/render/intern/include/render_types.h b/source/blender/render/intern/include/render_types.h index 1768b052b54..2db70c460f9 100644 --- a/source/blender/render/intern/include/render_types.h +++ b/source/blender/render/intern/include/render_types.h @@ -198,6 +198,8 @@ struct Render ListBase *sss_points; struct Material *sss_mat; + struct KDTree *particles_tree; + ListBase customdata_names; struct Object *excludeob; @@ -347,6 +349,16 @@ typedef struct HaloRen /* ------------------------------------------------------------------------- */ +typedef struct ParticleRen +{ + struct ParticleRen *next, *prev; + float co[3]; // location + // float col[3]; // colour + // float vec[3]; // direction +} ParticleRen; + +/* ------------------------------------------------------------------------- */ + typedef struct StrandVert { float co[3]; float strandco; -- cgit v1.2.3 From 8056705ae9b2467a013f2372c0579687d3723229 Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Sun, 28 Sep 2008 08:00:22 +0000 Subject: * Volumetrics Removed all the old particle rendering code and options I had in there before, in order to make way for... A new procedural texture: 'Point Density' Point Density is a 3d texture that find the density of a group of 'points' in space and returns that in the texture as an intensity value. Right now, its at an early stage and it's only enabled for particles, but it would be cool to extend it later for things like object vertices, or point cache files from disk - i.e. to import point cloud data into Blender for rendering volumetrically. Currently there are just options for an Object and its particle system number, this is the particle system that will get cached before rendering, and then used for the texture's density estimation. It works totally consistent with as any other procedural texture, so previously where I've mapped a clouds texture to volume density to make some of those test renders, now I just map a point density texture to volume density. Here's a version of the same particle smoke test file from before, updated to use the point density texture instead: http://mke3.net/blender/devel/rendering/volumetrics/smoke_test02.blend There are a few cool things about implementing this as a texture: - The one texture (and cache) can be instanced across many different materials: http://mke3.net/blender/devel/rendering/volumetrics/pointdensity_instanced.png This means you can calculate and bake one particle system, but render it multiple times across the scene, with different material settings, at no extra memory cost. Right now, the particles are cached in world space, so you have to map it globally, and if you want it offset, you have to do it in the material (as in the file above). I plan to add an option to bake in local space, so you can just map the texture to local and it just works. - It also works for solid surfaces too, it just gets the density at that particular point on the surface, eg: http://mke3.net/blender/devel/rendering/volumetrics/pointdensity_solid.mov - You can map it to whatever you want, not only density but the various emissions and colours as well. I'd like to investigate using the other outputs in the texture too (like the RGB or normal outputs), perhaps with options to colour by particle age, generating normals for making particle 'dents' in a surface, whatever! --- source/blender/render/intern/include/render_types.h | 11 ----------- 1 file changed, 11 deletions(-) (limited to 'source/blender/render/intern/include/render_types.h') diff --git a/source/blender/render/intern/include/render_types.h b/source/blender/render/intern/include/render_types.h index 2db70c460f9..b0003cadb55 100644 --- a/source/blender/render/intern/include/render_types.h +++ b/source/blender/render/intern/include/render_types.h @@ -198,8 +198,6 @@ struct Render ListBase *sss_points; struct Material *sss_mat; - struct KDTree *particles_tree; - ListBase customdata_names; struct Object *excludeob; @@ -347,15 +345,6 @@ typedef struct HaloRen struct Material *mat; } HaloRen; -/* ------------------------------------------------------------------------- */ - -typedef struct ParticleRen -{ - struct ParticleRen *next, *prev; - float co[3]; // location - // float col[3]; // colour - // float vec[3]; // direction -} ParticleRen; /* ------------------------------------------------------------------------- */ -- cgit v1.2.3 From b3000c5529d10ae5002d25384c50d934b233a216 Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Fri, 17 Oct 2008 05:54:42 +0000 Subject: non-working WIP commit to continue coding at home. nothing to see here, move along! --- source/blender/render/intern/include/render_types.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'source/blender/render/intern/include/render_types.h') diff --git a/source/blender/render/intern/include/render_types.h b/source/blender/render/intern/include/render_types.h index b0003cadb55..6f4537d84fb 100644 --- a/source/blender/render/intern/include/render_types.h +++ b/source/blender/render/intern/include/render_types.h @@ -201,6 +201,8 @@ struct Render ListBase customdata_names; struct Object *excludeob; + + ListBase vol_precache_obs; /* arena for allocating data for use during render, for * example dynamic TFaces to go in the VlakRen structure. @@ -285,6 +287,8 @@ typedef struct ObjectInstanceRen { float dupliorco[3], dupliuv[2]; float (*duplitexmat)[4]; + + float *volume_precache; float *vectors; int totvector; @@ -396,6 +400,16 @@ typedef struct StrandRen { float orco[3]; } StrandRen; +/* ------------------------------------------------------------------------- */ + +typedef struct VolPrecache +{ + struct VolPrecache *next, *prev; + struct Material *ma; + struct ObjectRen *obr; +} VolPrecache; + +/* ------------------------------------------------------------------------- */ struct LampRen; struct MTex; -- cgit v1.2.3 From 92f5c719aedf79db7e45d3b887146a559321981e Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Sat, 13 Dec 2008 05:41:34 +0000 Subject: * Volume Rendering: Voxel data MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit introduces a new texture ('Voxel Data'), used to load up saved voxel data sets for rendering, contributed by Raúl 'farsthary' Fernández Hernández with some additional tweaks. Thanks, Raúl! The texture works similar to the existing point density texture, currently it only provides intensity information, which can then be mapped (for example) to density in a volume material. This is an early version, intended to read the voxel format saved by Raúl's command line simulators, in future revisions there's potential for making a more full-featured 'Blender voxel file format', and also for supporting other formats too. Note: Due to some subtleties in Raúl's existing released simulators, in order to load them correctly the voxel data texture, you'll need to raise the 'resolution' value by 2. So if you baked out the simulation at resolution 50, enter 52 for the resolution in the texture panel. This can possibly be fixed in the simulator later on. Right now, the way the texture is mapped is just in the space 0,0,0 <-> 1,1,1 and it can appear rotated 90 degrees incorrectly. This will be tackled, for now, probably the easiest way to map it is with and empty, using Map Input -> Object. Smoke test: http://www.vimeo.com/2449270 One more note, trilinear interpolation seems a bit slow at the moment, we'll look into this. For curiosity, while testing/debugging this, I made a script that exports a mesh to voxel data. Here's a test of grogan (www.kajimba.com) converted to voxels, rendered as a volume: http://www.vimeo.com/2512028 The script is available here: http://mke3.net/projects/bpython/export_object_voxeldata.py * Another smaller thing, brought back early ray termination (was disabled previously for debugging) and made it user configurable. It now appears as a new value in the volume material: 'Depth Cutoff'. For some background info on what this does, check: http://farsthary.wordpress.com/2008/12/11/cutting-down-render-times/ * Also some disabled work-in-progess code for light cache --- source/blender/render/intern/include/render_types.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'source/blender/render/intern/include/render_types.h') diff --git a/source/blender/render/intern/include/render_types.h b/source/blender/render/intern/include/render_types.h index 6f4537d84fb..65bb12e059d 100644 --- a/source/blender/render/intern/include/render_types.h +++ b/source/blender/render/intern/include/render_types.h @@ -203,6 +203,8 @@ struct Render struct Object *excludeob; ListBase vol_precache_obs; + ListBase render_volumes_inside; + ListBase volumes; /* arena for allocating data for use during render, for * example dynamic TFaces to go in the VlakRen structure. @@ -409,6 +411,18 @@ typedef struct VolPrecache struct ObjectRen *obr; } VolPrecache; +typedef struct VolumeOb +{ + struct VolumeOb *next, *prev; + struct Material *ma; + struct ObjectRen *obr; +} VolumeOb; + +typedef struct MatInside { + struct MatInside *next, *prev; + struct Material *ma; +} MatInside; + /* ------------------------------------------------------------------------- */ struct LampRen; -- cgit v1.2.3 From be1d06a2c544a4ea27139475a72edb75afa37879 Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Mon, 22 Dec 2008 20:28:02 +0000 Subject: Volume rendering: * Multithreaded volume light cache While the render process itself is multithreaded, the light cache pre-process previously wasn't (painfully noticed this the other week rendering on some borrowed octocore nodes!). This commit adds threading, similar to the tiled render - it divides the light cache's voxel grid into 3d parts and renders them with the available threads. This makes the most significant difference on shots where the light cache pre- process is the bottleneck, so shots with either several lights, or a high res light cache, or both. On this file (3 lights, light cache res 120), on my Core 2 Duo it now renders in 27 seconds compared to 49 previously. http://mke3.net/blender/devel/rendering/volumetrics/threaded_cache.jpg --- .../blender/render/intern/include/render_types.h | 26 +++++++++++++++------- 1 file changed, 18 insertions(+), 8 deletions(-) (limited to 'source/blender/render/intern/include/render_types.h') diff --git a/source/blender/render/intern/include/render_types.h b/source/blender/render/intern/include/render_types.h index 65bb12e059d..8dbdde77726 100644 --- a/source/blender/render/intern/include/render_types.h +++ b/source/blender/render/intern/include/render_types.h @@ -202,9 +202,9 @@ struct Render struct Object *excludeob; - ListBase vol_precache_obs; ListBase render_volumes_inside; ListBase volumes; + ListBase volume_precache_parts; /* arena for allocating data for use during render, for * example dynamic TFaces to go in the VlakRen structure. @@ -404,13 +404,6 @@ typedef struct StrandRen { /* ------------------------------------------------------------------------- */ -typedef struct VolPrecache -{ - struct VolPrecache *next, *prev; - struct Material *ma; - struct ObjectRen *obr; -} VolPrecache; - typedef struct VolumeOb { struct VolumeOb *next, *prev; @@ -423,6 +416,23 @@ typedef struct MatInside { struct Material *ma; } MatInside; +typedef struct VolPrecachePart +{ + struct VolPrecachePart *next, *prev; + struct RayTree *tree; + struct ShadeInput *shi; + struct ObjectInstanceRen *obi; + int num; + int minx, maxx; + int miny, maxy; + int minz, maxz; + int res; + float bbmin[3]; + float voxel[3]; + int working, done; +} VolPrecachePart; + + /* ------------------------------------------------------------------------- */ struct LampRen; -- cgit v1.2.3 From 3b2ec949778649f19b83c5ada413f3a50bb0e0e8 Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Sat, 20 Jun 2009 06:41:50 +0000 Subject: Voxel data & volume light cache * Added support for additional file types in the voxel data texture. I added support for 8 bit raw files, but most notably for image sequences. Image sequences generate the voxel grid by stacking layers of image slices on top of each other to generate the voxels in the Z axis - the number of slices in the sequence is the resolution of the voxel grid's Z axis. i.e. http://mke3.net/blender/devel/rendering/volumetrics/skull_layers.jpg The image sequence option is particularly useful for loading medical data into Blender. 3d medical data such as MRIs or CT scans are often stored as DICOM format image sequences. It's not in Blender's scope to support the DICOM format, but there are plenty of utilities such as ImageMagick, Photoshop or OsiriX that can easily convert DICOM files to formats that Blender supports, such as PNG or JPEG. Here are some example renderings using these file formats to load medical data: http://vimeo.com/5242961 http://vimeo.com/5242989 http://vimeo.com/5243228 Currently the 8 bit raw and image sequence formats only support the 'still' rendering feature. * Changed the default texture placement to be centred around 0.5,0.5,0.5, rather than within the 0.0,1.0 cube. This is more consistent with image textures, and it also means you can easily add a voxel data texture to a default cube without having to mess around with mapping. * Added some more extrapolation modes such as Repeat and Extend rather than just clipping http://mke3.net/blender/devel/rendering/volumetrics/bradybunch.jpg * Changed the voxel data storage to use MEM_Mapalloc (memory mapped disk cache) rather than storing in ram, to help cut down memory usage. * Refactored and cleaned up the code a lot. Now the access and interpolation code is separated into a separate voxel library inside blenlib. This is now properly shared between voxel data texture and light cache (previously there was some duplicated code). * Made volume light cache support non-cubic voxel grids. Now the resolution specified in the material properties is used for the longest edge of the volume object's bounding box, and the shorter edges are proportional (similar to how resolution is calculated for fluid sim domains). This is *much* more memory efficient for squashed volume regions like clouds layer bounding boxes, allowing you to raise the resolution considerably while still keeping memory usage acceptable. --- source/blender/render/intern/include/render_types.h | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'source/blender/render/intern/include/render_types.h') diff --git a/source/blender/render/intern/include/render_types.h b/source/blender/render/intern/include/render_types.h index 8dbdde77726..9703ab10821 100644 --- a/source/blender/render/intern/include/render_types.h +++ b/source/blender/render/intern/include/render_types.h @@ -290,8 +290,8 @@ typedef struct ObjectInstanceRen { float dupliorco[3], dupliuv[2]; float (*duplitexmat)[4]; - float *volume_precache; - + struct VolumePrecache *volume_precache; + float *vectors; int totvector; } ObjectInstanceRen; @@ -426,12 +426,19 @@ typedef struct VolPrecachePart int minx, maxx; int miny, maxy; int minz, maxz; - int res; + int res[3]; float bbmin[3]; float voxel[3]; int working, done; } VolPrecachePart; +typedef struct VolumePrecache +{ + int res[3]; + float *data_r; + float *data_g; + float *data_b; +} VolumePrecache; /* ------------------------------------------------------------------------- */ -- cgit v1.2.3 From 970c9214b543c95921dbb51a681457b5d6597133 Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Sun, 30 Aug 2009 07:07:02 +0000 Subject: * Fixes for shading objects inside volumes --- source/blender/render/intern/include/render_types.h | 1 + 1 file changed, 1 insertion(+) (limited to 'source/blender/render/intern/include/render_types.h') diff --git a/source/blender/render/intern/include/render_types.h b/source/blender/render/intern/include/render_types.h index c4910f7733d..e50e498228d 100644 --- a/source/blender/render/intern/include/render_types.h +++ b/source/blender/render/intern/include/render_types.h @@ -419,6 +419,7 @@ typedef struct VolumeOb typedef struct MatInside { struct MatInside *next, *prev; struct Material *ma; + struct ObjectInstanceRen *obi; } MatInside; typedef struct VolPrecachePart -- cgit v1.2.3