last update:20 Sept 2002

  Density_File Extension Patch


This is a patch of POV-Ray 3.5. This is unofficial version. If you have questions or comments, please mail to r-suzuki@aist.go.jp


Executable File for Windows


Source files


   
 

The density_file pattern in POV-Ray 3.5 is extremely flexible. It may be used anywhere any pattern, functions, etc. However, the resolution of the density_file in the official version is only 8 bit and there are only two interpolation options (no interpolatnion and tri-linear interpolation). These are not enough for some purposes, e.g. for isosurfaces. Thus, I have made an unofficial patch for the density files. Using this patch one can use density files of float values, 16 bit integer values with binary or text format. Furthermore, tri-cubic interpolation options are included.


Extended Density_file format       

The syntax of the extended density_file in the POV Scene Description Language is the same as the official version, but several interpolation options are added.

#declare DATA3D= pattern{
    density_file df3 "filename.df"        
    [interpolate Type_Number] 
    [frequency Freq_Number]                     
  }

---------------------------------------------------
Type_Number
  0: No interpolation         [default]  
  1: Tri-linear interpolation   
  2: Tri-cubic interpolation    
Freq_Number
  0: Without clipping 
  other: same as the official version [default:1]

Furthermore, this patch has an internal density_file type just like as the function image(see POV-Help 6.7.11.16). Following is an example.
#declare DATA3D= pattern{
    density_file function 20, 20, 20 {f_sphere(x,y,z,0.5)} 
    [save_file "filename"]

    [interpolate Type_Number]
    [frequency Freq_Number]                     
  }

The keyword save_file allows you to save the internal density_file.


The patched version can read both the binary format (original df3 format) and the text format, which is the extended density_file format. The text format syntax is following.

dfd   //This specifies the extended density_file description format.
[file_name] filename.ext //File name of the data file (Optional). 
                         // The data after the [Data] line is effective if 
                         // the filename is none. 
[Type] Float             //Data type   Float,  Int(2byte), Char:8bit(1byte)
[Format] Text            //Data format Text | Binary
[X_size] NX              //Dimension of X     NX>=4
[Y_size] NY              //Dimension of Y     NY>=4
[Z_size] NZ              //Dimension of Z     NZ>=1
[Endian] Little          //Endian for binary format
[Cyclic] On              //On | Off
[Offset] 0               //Offset of the data file
[Data]

Data Order: (((D(x,y,z), x=1,NX), y=1,NY), z=1,NZ)



   
Example scene file
Right:Scene file
Below:dftest.df
dfd
[file_name] df_data.txt
[Type] Float
[Format] Text
[X_size] 4
[Y_size] 4
[Z_size] 4
[Endian] Little
[Cyclic] On
[Data]
df_data.txt
 
#version unofficial dfe 3.5;                          

camera { location  <25, 20, -40.0> look_at <0,0,0> direction 50.*z}

light_source { <1,1.4,-1>*5 color rgb <1.4,1.2,1.0>*1.7 }
light_source { <-0.5,-0.94,-1>*6  color rgb <0.9,1.0,1.0>*1.0 }

#declare DATA3D2= function { pattern{
    density_file df3 "dftest.df"        // 3D raster file (df) pattern
    interpolate 2                       // optional interpolation
    frequency 0
  }
}

 
#macro ISO3D(TH, Filter)
 isosurface{ function{TH-DATA3D2(x-0.5,y-0.5,z-0.5)   }
   contained_by{box{<-0.5,-0.5,-0.5>,<0.5,0.5,0.5>}} 
   max_gradient 4                      
   texture{ pigment{color <0.86,0.8,0.6, Filter>}  
          finish{phong 0.30 phong_size 90}  }    
   no_shadow
 }
#end

#declare TH=0.42;
ISO3D(TH, 0.6)
#declare TH=0.45;
ISO3D(TH, 0) 


Version-up information

V04 20 Sept. '02 Added 'frequency 0'
V03 11 Sept. '02 Added 'save_file' option.
V02 30 Aug. '02 Added internal density file.
V01 24 Aug. '02 First release.

Images created with the density file extension patch



© 2001 AIST. All rights reserved. AIST