Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
0.8.3:volumerendering [2021/03/03 15:37] – [NRRD File] admin | 0.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 169: | Line 170: | ||
__NOTICE:__ **LF** and **CRLF** are supported as line endings. | __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 " | ||
+ | |||
+ | 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, | ||
+ | |||
+ | TMyVolumetricMesh = class(TGorillaVolumetricMesh) | ||
+ | procedure RandomFill(); | ||
+ | end; | ||
+ | |||
+ | {...} | ||
+ | |||
+ | procedure TMyVolumetricMesh.RandomFill(); | ||
+ | var LTex : TGorillaTextureBitmap; | ||
+ | LData : TBytes; | ||
+ | LDPtr : PSingle; // vmdtFloat !!! | ||
+ | LValue | ||
+ | LOfs, | ||
+ | w, h, d : Integer; | ||
+ | LSizeF | ||
+ | LSizeI | ||
+ | X : Integer; | ||
+ | Y : Integer; | ||
+ | Z : Integer; | ||
+ | end; | ||
+ | LFSize, | ||
+ | LDSize | ||
+ | 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, | ||
+ | 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, | ||
+ | Inc(LDPtr); | ||
+ | end; | ||
+ | end; | ||
+ | |||
+ | // push data to 3D texture | ||
+ | LTex := TGorillaVolumetricMeshMaterialSource(FMaterial).Texture as TGorillaTextureBitmap; | ||
+ | LTex.UpdateBuffer(LData, | ||
+ | finally | ||
+ | System.SetLength(LData, | ||
+ | end; | ||
+ | end; | ||
+ | </ | ||
===== Scene Setup ===== | ===== Scene Setup ===== | ||
Line 264: | Line 338: | ||
</ | </ | ||
+ | ===== 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: | ||
+ | |||
+ | {{: | ||
+ | |||
+ | |||
+ | 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, | ||
+ | |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]] |