Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
0.8.3:volumerendering [2021/03/03 15:33] – [Upload Data] admin0.8.3:volumerendering [2022/04/08 10:06] (current) – [Gamut Mapping] admin
Line 17: Line 17:
   * Different render shapes: cube, sphere, cylinder   * Different render shapes: cube, sphere, cylinder
   * Changable ray front and back limit   * Changable ray front and back limit
 +  * Managable ray step detail
   * Clipping plane support for optimal slicing   * Clipping plane support for optimal slicing
   * RAW file support   * RAW file support
Line 153: Line 154:
 </file> </file>
  
 +You can setup a NRRD header yourself in case you have only a RAW file.
 +Just add some similar code at the beginning of your file:
 +
 +<code>
 +NRRD0001
 +content: "My NRRD File"
 +type: unsigned char
 +dimension: 3
 +sizes: 256 256 256
 +spacings: 1 1 1
 +encoding: raw
 +
 +[... RAW DATA ...]
 +</code>
 +
 +__NOTICE:__ **LF** and **CRLF** are supported as line endings.
 +
 +
 +==== Procedural Data ====
 +
 +You can of course fill the 3D data array also manually.
 +Pushing data to the 3D-texture by UpdateBuffer() expects to fill data correctly. Otherwise exception may occur.
 +
 +You have to take care of the 3D-texture size by the "Sizes" property of the component and the configured "DataType".
 +
 +In the following a simple code snippet showing a procedure to fill a 512 x 512 x 512 with 4-Byte float values.
 +
 +<file pascal>
 +uses Gorilla.Material.Types, Gorilla.Context.Texturing;
 +
 +TMyVolumetricMesh = class(TGorillaVolumetricMesh)
 +  procedure RandomFill();
 +end;
 +
 +{...}
 +
 +procedure TMyVolumetricMesh.RandomFill();
 +var LTex    : TGorillaTextureBitmap;
 +    LData   : TBytes;
 +    LDPtr   : PSingle; // vmdtFloat !!!
 +    LValue  : Byte;
 +    LOfs,
 +    w, h, d : Integer;
 +    LSizeF  : TPoint3D;
 +    LSizeI  : record
 +                X : Integer;
 +                Y : Integer;
 +                Z : Integer;
 +              end;
 +    LFSize,
 +    LDSize  : Integer;
 +begin
 +  Self.Sizes := TGorillaVolumetricMeshSize.vms512x512x512;
 +  Self.DataType := vmdtFloat; /// !!!
 + 
 +  // get size in fragments
 +  LSizeF := Self.GetSizeAsVector();
 +  LSizeI.X := Round(LSizeF.X);
 +  LSizeI.Y := Round(LSizeF.Y);
 +  LSizeI.Z := Round(LSizeF.Z);
 +
 +  LFSize := GORILLA_VOLUMETRIC_MESH_DATASIZE[Self.DataType];
 +
 +  // create data array
 +  LDSize := LSizeI.X * LSizeI.Y * LSizeI.Z * LFSize;
 +  System.SetLength(LData, LDSize);
 +  try
 +    LDPtr := @LData[0];
 +    // fill data with perlin noise
 +    for w := 0 to (LSizeI.X - 1) do
 +    begin
 +      for h := 0 to (LSizeI.Y - 1) do
 +      begin
 +        for d := 0 to (LSizeI.Z - 1) do
 +        begin
 +          // NOTICE: MAYBE THE VALUE NEED TO BE IN REVERSED BYTE ORDER!
 +          LDPtr^ := Single(RandomRange(0, 10000) / 10000);
 +          Inc(LDPtr);
 +      end;
 +    end;
 +
 +    // push data to 3D texture
 +    LTex := TGorillaVolumetricMeshMaterialSource(FMaterial).Texture as TGorillaTextureBitmap;
 +    LTex.UpdateBuffer(LData, LDSize);
 +  finally
 +    System.SetLength(LData, 0);
 +  end;
 +end;
 +</file>
 ===== Scene Setup ===== ===== Scene Setup =====
  
Line 248: Line 338:
 </file> </file>
  
 +===== Gamut Mapping =====
 +
 +Gamut is a colored texture to define how 3D values will be colored. 
 +Since 0.8.3.2265 this feature is available.
 +
 +Here an example of a simple gradient gamut texture:
 +
 +{{:0.8.3:gamut.jpg?nolink|}}
 +
 +
 +TGorillaVolumetricMesh allows to configure the coloring method by some properties:
 +
 +^Property^Description^
 +|Gamut|Texture used for mapping the 3D value during Raytracing|
 +|GamutMode|Defines when and how the value-color mapping happens. Here different modes are available: GamutNone, GamutByValue, GamutByValueMultiply, GamutBySum, GamutBySumMultiply|
 +|GamutFactor|A factor applied to the absolute 3D value before mapping onto the gamut texture (default value is 1.0)|
 +
 +=== Modes ===
 +
 +The available gamut modes allow to control the output of color mapping. 
 +
 +^Mode^Description^
 +|GamutNone|Gamut mapping is disabled|
 +|GamutByValue|Gamut mapping will be applied to each 3D value on the casted ray.|
 +|GamutByValueMultiply|Gamut mapping will be applied to each 3D value on the casted ray and afterwards multiplied with the previously computed color value.|
 +|GamutBySum|Gamut mapping will be applied to the final casted ray value.|
 +|GamutBySumMultiply|Gamut mapping will be applied to the final casted ray value and afterwards multiplied with the previously computed color value.|
 +
 +Next step: [[particles|Particles]]