diff options
author | Matt Ebb <matt@mke3.net> | 2008-12-13 08:41:34 +0300 |
---|---|---|
committer | Matt Ebb <matt@mke3.net> | 2008-12-13 08:41:34 +0300 |
commit | 92f5c719aedf79db7e45d3b887146a559321981e (patch) | |
tree | 877e8a5c91f19a17dcce8cc5d14f2dda00ef6e80 /source/blender/blenkernel/intern/texture.c | |
parent | aef61a7000c279a96f1bb0e1fedf7da2574292fd (diff) |
* Volume Rendering: Voxel data
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
Diffstat (limited to 'source/blender/blenkernel/intern/texture.c')
-rw-r--r-- | source/blender/blenkernel/intern/texture.c | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c index c972d70d927..c9cae91da6f 100644 --- a/source/blender/blenkernel/intern/texture.c +++ b/source/blender/blenkernel/intern/texture.c @@ -420,6 +420,7 @@ void free_texture(Tex *tex) if(tex->coba) MEM_freeN(tex->coba); if(tex->env) BKE_free_envmap(tex->env); if(tex->pd) BKE_free_pointdensity(tex->pd); + if(tex->vd) BKE_free_voxeldata(tex->vd); BKE_previewimg_free(&tex->preview); BKE_icon_delete((struct ID*)tex); tex->id.icon_id = 0; @@ -490,6 +491,11 @@ void default_tex(Tex *tex) tex->pd->radius = 0.3f; tex->pd->falloff_type = TEX_PD_FALLOFF_STD; } + + if (tex->vd) { + tex->vd->resolX=50; + tex->vd->interp_type=0; + } pit = tex->plugin; if (pit) { @@ -588,6 +594,7 @@ Tex *copy_texture(Tex *tex) if(texn->coba) texn->coba= MEM_dupallocN(texn->coba); if(texn->env) texn->env= BKE_copy_envmap(texn->env); if(texn->pd) texn->pd= BKE_copy_pointdensity(texn->pd); + if(texn->vd) texn->vd=BKE_copy_voxeldata(texn->vd); if(tex->preview) texn->preview = BKE_previewimg_copy(tex->preview); @@ -945,6 +952,48 @@ void BKE_free_pointdensity(PointDensity *pd) MEM_freeN(pd); } + +void BKE_free_voxeldatadata(struct VoxelData *vd) +{ + if (vd->dataset) { + MEM_freeN(vd->dataset); + vd->dataset = NULL; + } + +} + +void BKE_free_voxeldata(struct VoxelData *vd) +{ + BKE_free_voxeldatadata(vd); + MEM_freeN(vd); +} + +struct VoxelData *BKE_add_voxeldata(void) +{ + VoxelData *vd; + + vd= MEM_callocN(sizeof(struct VoxelData), "voxeldata"); + vd->dataset = NULL; + vd->resolX = 1; + vd->resolY = 1; + vd->resolZ = 1; + vd->interp_type= TEX_VD_NEARESTNEIGHBOR; + vd->int_multiplier = 1.0; + + return vd; + } + +struct VoxelData *BKE_copy_voxeldata(struct VoxelData *vd) +{ + VoxelData *vdn; + + vdn= MEM_dupallocN(vd); + vdn->dataset = NULL; + + return vdn; +} + + /* ------------------------------------------------------------------------- */ int BKE_texture_dependsOnTime(const struct Tex *texture) { |