Skip to content

Sign up to be notified when the ShaderHunt platform is available, along with interactive examples teaching TypeGPU from the ground up.

unstruct

unstruct<TProps>(properties): Unstruct<TProps>

Defined in: packages/typegpu/src/data/unstruct.ts:29

Creates a loose struct schema that can be used to construct vertex buffers. Describes structs with members of both loose and non-loose types.

The order of members matches the passed in properties object. Members are not aligned in respect to their byteAlignment, unless they are explicitly decorated with the custom align attribute via d.align function.

TProps extends Record<string, BaseData>

TProps

Record with string keys and TgpuData or TgpuLooseData values, each entry describing one struct member.

Unstruct<TProps>

const CircleStruct = d.unstruct({ radius: d.f32, pos: d.vec3f }); // packed struct with no padding
const CircleStruct = d.unstruct({ radius: d.f32, pos: d.align(16, d.vec3f) });