Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Ebb <matt@mke3.net>2009-06-20 10:41:50 +0400
committerMatt Ebb <matt@mke3.net>2009-06-20 10:41:50 +0400
commit3b2ec949778649f19b83c5ada413f3a50bb0e0e8 (patch)
tree6364fe340dcb19f77046d406193cacd694b71d77 /source/blender/src/buttons_shading.c
parent44cebb39b88a6f411dbe0eb05109869ae82bbc9f (diff)
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.
Diffstat (limited to 'source/blender/src/buttons_shading.c')
-rw-r--r--source/blender/src/buttons_shading.c198
1 files changed, 138 insertions, 60 deletions
diff --git a/source/blender/src/buttons_shading.c b/source/blender/src/buttons_shading.c
index f74afde5e81..54fc639059d 100644
--- a/source/blender/src/buttons_shading.c
+++ b/source/blender/src/buttons_shading.c
@@ -1053,67 +1053,7 @@ static void texture_panel_pointdensity_modify(Tex *tex)
}
-static void texture_panel_voxeldata(Tex *tex)
-{
- uiBlock *block;
- VoxelData *vd;
- short yco=PANEL_YMAX;
-
- block= uiNewBlock(&curarea->uiblocks, "texture_panel_voxeldata", UI_EMBOSS, UI_HELV, curarea->win);
- if(uiNewPanel(curarea, block, "Voxel Data", "Texture", PANELX, PANELY, PANELW, PANELH+YSPACE)==0) return;
- uiSetButLock(tex->id.lib!=0, ERROR_LIBDATA_MESSAGE);
-
- if(tex->vd==NULL) {
- tex->vd= BKE_add_voxeldata();
- }
-
- if(tex->vd) {
- vd= tex->vd;
-
- uiDefBut(block, LABEL, B_NOP, "Data source:",
- X2CLM1, yco-=BUTH, BUTW2, BUTH, 0, 0, 0, 0, 0, "");
-
- uiDefIconTextBut(block, BUT, B_VOXELDATA_LOAD, ICON_FILESEL, "Open",
- X4CLM1, yco-=BUTH, BUTW4, BUTH, 0, 0, 0, 0, 0, "");
- uiDefBut(block, TEX, 0, "",
- X4CLM2+XSPACE, yco, BUTW2+BUTW4+2*XSPACE, BUTH, &vd->source_path, 0.0, 79.0, 0, 0, "File path to the voxel data set");
- yco -= YSPACE;
-
- uiDefBut(block, LABEL, B_NOP, "Interpolation:",
- X2CLM1, yco-=BUTH, BUTW2, BUTH, 0, 0, 0, 0, 0, "");
- uiDefButI(block, MENU, B_REDR, "None %x0|Linear %x1|Tricubic %x2",
- X2CLM1, yco-=BUTH, BUTW2, BUTH, &vd->interp_type, 0.0, 0.0, 0, 0, "Interpolation type");
-
- yco -= YSPACE;
-
- uiDefButF(block, NUM, B_REDR, "Intensity: ",
- X2CLM1, yco-=BUTH, BUTW2, BUTH, &(vd->int_multiplier), 0.0001, 10000.0, 0, 0, "Multiplier to scale up or down the texture's intensity");
-
- yco = PANEL_YMAX - 2*BUTH - 2*YSPACE;
-
- uiDefBut(block, LABEL, B_NOP, "Resolution:",
- X2CLM2, yco-=BUTH, BUTW2, BUTH, 0, 0, 0, 0, 0, "");
- uiBlockBeginAlign(block);
- uiDefButI(block, NUM, B_REDR, "X: ",
- X2CLM2, yco-=BUTH, BUTW2, BUTH, &(vd->resolX), 1, 10000, 0, 0, "Resolution of the voxel data");
- uiDefButI(block, NUM, B_REDR, "Y: ",
- X2CLM2, yco-=BUTH, BUTW2, BUTH, &(vd->resolY), 1, 10000, 0, 0, "Resolution of the voxel data");
- uiDefButI(block, NUM, B_REDR, "Z: ",
- X2CLM2, yco-= BUTH, BUTW2, BUTH, &(vd->resolZ), 1, 10000, 0, 0, "Resolution of the voxel data");
- uiBlockEndAlign(block);
-
- yco -= YSPACE;
-
- uiBlockBeginAlign(block);
- uiDefButI(block,TOG, B_REDR, "Still",
- X2CLM2, yco-=BUTH, BUTW2, BUTH, &(vd->still), 0,1, 0, 0, "Use a still frame from the data sequence for the entire rendered animation");
- if (vd->still) uiDefButI(block, NUM, B_REDR, "Frame: ",
- X2CLM2, yco-=BUTH, BUTW2, BUTH, &(vd->still_frame), 1, 10000, 0, 0, "The frame to pause on for the entire rendered animation");
- uiBlockEndAlign(block);
-
- }
-}
static char *layer_menu(RenderResult *rr, short *curlay)
{
@@ -1791,6 +1731,144 @@ static void texture_panel_envmap(Tex *tex)
}
}
+static void texture_panel_voxeldata(Tex *tex)
+{
+ uiBlock *block;
+ VoxelData *vd;
+ short yco=PANEL_YMAX;
+
+ block= uiNewBlock(&curarea->uiblocks, "texture_panel_voxeldata", UI_EMBOSS, UI_HELV, curarea->win);
+ if(uiNewPanel(curarea, block, "Voxel Data", "Texture", PANELX, PANELY, PANELW, PANELH+BUTH+2*YSPACE)==0) return;
+ uiSetButLock(tex->id.lib!=0, ERROR_LIBDATA_MESSAGE);
+
+ if(tex->vd==NULL) {
+ tex->vd= BKE_add_voxeldata();
+ }
+
+ if(tex->vd) {
+ vd= tex->vd;
+
+ uiDefBut(block, LABEL, B_NOP, "Data source:",
+ X2CLM1, yco-=BUTH, BUTW2, BUTH, 0, 0, 0, 0, 0, "");
+
+ if (vd->file_format != TEX_VD_IMAGE_SEQUENCE) {
+ uiDefIconTextBut(block, BUT, B_VOXELDATA_LOAD, ICON_FILESEL, "Open",
+ X4CLM1, yco-=BUTH, BUTW4, BUTH, 0, 0, 0, 0, 0, "");
+ uiDefBut(block, TEX, 0, "",
+ X4CLM2+XSPACE, yco, BUTW2+BUTW4+2*XSPACE, BUTH, &vd->source_path, 0.0, 79.0, 0, 0, "File path to the voxel data set");
+ }
+ else {
+ char *strp;
+ char str[128];
+ ImageUser *iuser = &(tex->iuser);
+ uiBut *but;
+
+ /* Browse */
+ IMAnames_to_pupstring(&strp, NULL, NULL, &(G.main->image), NULL, &iuser->menunr);
+
+ uiBlockBeginAlign(block);
+ but= uiDefButS(block, MENU, B_REDR, strp,
+ X2CLM1, yco-=BUTH, ICONBUTW, BUTH, &iuser->menunr, 0, 0, 0, 0, "Selects an existing Image or Movie");
+ uiButSetFunc(but, image_browse_cb, &(tex->ima), iuser);
+
+ MEM_freeN(strp);
+
+ if (tex->ima) {
+ uiSetButLock(tex->ima->id.lib!=NULL, ERROR_LIBDATA_MESSAGE);
+ but= uiDefIconBut(block, BUT, B_REDR, ICON_FILESEL,
+ X2CLM1+ICONBUTW, yco, X2CLM1+ICONBUTW, BUTH, 0, 0, 0, 0, 0, "Open Fileselect to load new Image");
+ uiButSetFunc(but, image_load_fs_cb, &(tex->ima), iuser);
+
+ but= uiDefBut(block, TEX, B_IDNAME, "IM:",
+ X2CLM1+2*ICONBUTW, yco, PANEL_XMAX-4*ICONBUTW-BUTW4, BUTH, tex->ima->id.name+2, 0.0, 21.0, 0, 0, "Current Image Datablock name.");
+ uiButSetFunc(but, test_idbutton_cb, tex->ima->id.name, NULL);
+
+ but= uiDefBut(block, BUT, B_REDR, "Reload",
+ PANEL_XMAX-2*ICONBUTW-BUTW4, yco, BUTW4, BUTH, NULL, 0, 0, 0, 0, "Reloads Image or Movie");
+ uiButSetFunc(but, image_reload_cb, &(tex->ima), iuser);
+
+ but= uiDefIconBut(block, BUT, B_REDR, ICON_X,
+ PANEL_XMAX-2*ICONBUTW, yco, ICONBUTW, BUTH, 0, 0, 0, 0, 0, "Unlink Image block");
+ uiButSetFunc(but, image_unlink_cb, &(tex->ima), NULL);
+
+ sprintf(str, "%d", tex->ima->id.us);
+ uiDefBut(block, BUT, B_NOP, str,
+ PANEL_XMAX-ICONBUTW, yco, ICONBUTW, BUTH, 0, 0, 0, 0, 0, "Only displays number of users of Image block");
+ uiBlockEndAlign(block);
+
+ yco -= (BUTH);
+
+ uiBlockBeginAlign(block);
+ uiDefButI(block, NUM, B_NOP, "Slices:",
+ X2CLM1, yco, BUTW2, BUTH, &iuser->frames, 1.0, MAXFRAMEF, 0, 0, "Number of images in the sequence");
+ uiDefButI(block, NUM, B_NOP, "Offset:",
+ X2CLM2, yco, BUTW2, BUTH, &iuser->offset, -MAXFRAMEF, MAXFRAMEF, 0, 0, "Offsets the file number to consider as the start of the sequence");
+ uiBlockEndAlign(block);
+
+ } else {
+ but= uiDefBut(block, BUT, B_REDR, "Load",
+ X2CLM1+ICONBUTW, yco, BUTW2-ICONBUTW, BUTH, NULL, 0, 0, 0, 0, "Load new Image");
+ uiButSetFunc(but, image_load_fs_cb, &(tex->ima), iuser);
+ }
+ }
+
+ yco -= YSPACE;
+
+ uiDefBut(block, LABEL, B_NOP, "Interpolation:",
+ X2CLM1, yco-=BUTH, BUTW2, BUTH, 0, 0, 0, 0, 0, "");
+ uiDefButI(block, MENU, B_REDR, "None %x0|Linear %x1|Tricubic %x2",
+ X2CLM1, yco-=BUTH, BUTW2, BUTH, &vd->interp_type, 0.0, 0.0, 0, 0, "Interpolation type");
+
+ yco -= YSPACE;
+
+ uiDefBut(block, LABEL, B_NOP, "Extend:",
+ X2CLM1, yco-=BUTH, BUTW2, BUTH, 0, 0, 0, 0, 0, "");
+ uiDefButS(block, MENU, B_REDR, "Repeat %x3|Clip %x2|Extend %x1",
+ X2CLM1, yco-=BUTH, BUTW2, BUTH, &(tex->extend), 0.0, 0.0, 0, 0, "Extrapolation type");
+
+ yco -= YSPACE;
+
+ uiDefButF(block, NUM, B_REDR, "Intensity: ",
+ X2CLM1, yco-=BUTH, BUTW2, BUTH, &(vd->int_multiplier), 0.0001, 10000.0, 0, 0, "Multiplier to scale up or down the texture's intensity");
+
+ yco = PANEL_YMAX - 2*BUTH - YSPACE;
+ if (vd->file_format == TEX_VD_IMAGE_SEQUENCE) yco -= BUTH;
+
+ uiDefBut(block, LABEL, B_NOP, "File Format:",
+ X2CLM2, yco-=BUTH, BUTW2, BUTH, 0, 0, 0, 0, 0, "");
+ uiDefButS(block, MENU, B_REDR, "Blender Voxel %x0|Raw (8 bit) %x1|Image Sequence %x3",
+ X2CLM2, yco-=BUTH, BUTW2, BUTH, &vd->file_format, 0.0, 0.0, 0, 0, "File format of the voxel data file");
+
+ if (ELEM(vd->file_format, TEX_VD_RAW_8BIT, TEX_VD_RAW_16BIT)) {
+ uiDefBut(block, LABEL, B_NOP, "Resolution:",
+ X2CLM2, yco-=BUTH, BUTW2, BUTH, 0, 0, 0, 0, 0, "");
+ uiBlockBeginAlign(block);
+ uiDefButI(block, NUM, B_REDR, "X: ",
+ X2CLM2, yco-=BUTH, BUTW2, BUTH, &(vd->resolX), 1, 10000, 0, 0, "Resolution of the voxel data");
+ uiDefButI(block, NUM, B_REDR, "Y: ",
+ X2CLM2, yco-=BUTH, BUTW2, BUTH, &(vd->resolY), 1, 10000, 0, 0, "Resolution of the voxel data");
+ uiDefButI(block, NUM, B_REDR, "Z: ",
+ X2CLM2, yco-= BUTH, BUTW2, BUTH, &(vd->resolZ), 1, 10000, 0, 0, "Resolution of the voxel data");
+ uiBlockEndAlign(block);
+
+ yco -= YSPACE;
+ }
+
+ if (vd->file_format == TEX_VD_BLENDERVOXEL) {
+ yco -= (BUTH+YSPACE);
+ uiBlockBeginAlign(block);
+ uiDefButI(block,TOG, B_REDR, "Still",
+ X2CLM2, yco-=BUTH, BUTW2, BUTH, &(vd->still), 0,1, 0, 0, "Use a still frame from the data sequence for the entire rendered animation");
+ if (vd->still)
+ uiDefButI(block, NUM, B_REDR, "Frame: ",
+ X2CLM2, yco-=BUTH, BUTW2, BUTH, &(vd->still_frame), 1, 10000, 0, 0, "The frame to pause on for the entire rendered animation");
+ uiBlockEndAlign(block);
+ }
+
+
+ }
+}
+
static void texture_panel_colors(Tex *tex)
{
uiBlock *block;