Skip to content

CustomBlock

Thomas Iché edited this page Oct 27, 2022 · 4 revisions

Custom Block

The custom block enables writing custom HLSL/Compute code and use it in the graph. While it is a custom block, and generates code, it can break easily as it can generate compilation errors. Benefits from this block include the use of iterative statements (for, while loops).

Using the block

The block can be added (by default) on all GPU-compatible contexts (initialize/update/output), for both particle, and particle strips.

The block can be configured using its own inspector. Once satisfied with your modifications, use the Apply Burton at the bottom.

image

Block Name : name of the block, as it will appear on the title

Configuration

  • Context Type : Contexts where the block is allowed
  • Compatible Data : Data type compatible with the block (Particles and/or ParticleStrips)

Attributes : The list of attributes used in the block and whether they can be read/written Custom Attributes : A list of additional custom (non-standard) attributes used in the block and whether they can be read/written in the block. Non-writable values will have changes on their value discarded, while Non-Readable values will not be

Properties : The list of properties (connectable) that will be available on the node.

Options

  • Use Total Time makes available the float totalTime value to be read in the block
  • Use Delta Time makes available the float deltaTime value to be read in the block
  • Use Random makes available the RAND and RAND3 macro values to be read in the block

Source code : in this textfield, you enter the HLSL code for tour block.

In order to apply all the changes, use the Apply Button.

Syntax

The general Syntax is the same as HLSL/Compute, however some values can be accessed/fetched using VFXGraph HLSL API.

Properties

Properties are accessed using their name (case sensitive) and sub-elements are accessed like any other properties. For instance, an AABox named Bounds will have its center and size available using float3 Bounds_center and float3 Bounds_size

Attributes

Same as properties, attributes can be accessed using their declared name. Internal attributes such as position, color are generally un-capitalized for their first character and separate nouns by capitals, for instance targetPosition.

Sampling Textures

Textures can be sampled using the SampleTexture(texture, coord) function, where coords depend on the texture dimensions.

Sampling Curves / Gradients

Curves and Gradients can be sampled using SampleGradient(Gradient, t); and SampleCurve(Alpha, t);