RSX Code Reference
    Preparing search index...
    • rsx
    • CarbonMaterial

    Class CarbonMaterial

    The CarbonMaterial class implements a Material that is backed by a CarbonMaterialGraph that generates the underlying shader that is directly owned and serialized together with the CarbonMaterial.

    The CarbonMaterial supports the following features:

    Hierarchy (View Summary)

    Index
    _lastProgramCode: String

    Stores the last program code used to avoid recompilation if the code hasn't changed. This can be a string representing the code or undefined if no code has been set.

    • get isDestroyed(): boolean

      Determines if the resource is destroyed.

      Returns boolean

      This can happen when the Resource was forcefully unloaded or reverted. For this reason, it is safer to hold on to a instead of directly referencing a resource pointer, as the current Resource can always be retrieved via .value.

    • get isValid(): boolean

      Returns boolean

    • get model(): MaterialModel

      Sets a material model and applies all model parameters to the material.

      Returns MaterialModel

    • set model(value: MaterialModel): void

      Parameters

      Returns void

    • get name(): string

      Name of the resource. Use primarily for easier identification and not important to the engine itself.

      Returns string

    • get shader(): Shader

      Sets a shader that will be used by the material. Material will be initialized using all compatible techniques from the shader. Shader must be set before doing any other operations with the material.

      Returns Shader

    • set shader(value: Shader): void

      Sets a shader that will be used by the material. Material will be initialized using all compatible techniques from the shader. Shader must be set before doing any other operations with the material.

      Parameters

      Returns void

    • get shaderHandle(): ResourceHandle<Shader>

      Sets a shader that will be used by the material. Material will be initialized using all compatible techniques from the shader. Shader must be set before doing any other operations with the material.

      Returns ResourceHandle<Shader>

    • set shaderHandle(value: Shader | ResourceHandle<Shader>): void

      Parameters

      Returns void

    • get techniqueCount(): number

      Returns the total number of techniques supported by this material.

      Returns number

    • get uuid(): UUID

      Returns a universally unique identifier of this resource.

      Returns UUID

    • get variation(): ShaderVariation

      Set of parameters that determine which subset of techniques in the assigned shader should be used. Only the techniques that have the provided parameters with the provided values will match. This will control which technique is considered the default technique and which subset of techniques are searched during a call to findTechnique().

      Returns ShaderVariation

    • set variation(value: ShaderVariation): void

      Parameters

      Returns void

    • Compiles the specified variation asynchronously, if the variation is already compiled, the operation will complete immediately.

      Parameters

      • variation: ShaderVariation

        The variation to compile, if unspecified, compiles the material default variation.

      Returns AsyncOp<boolean>

    • Dispatch a compute shader using this material asynchronously.

      Parameters

      • groupCountX: number

        The number of thread groups to dispatch in the X dimension.

      • groupCountY: number

        The number of thread groups to dispatch in the Y dimension.

      • groupCountZ: number

        The number of thread groups to dispatch in the Z dimension.

      Returns UncertainAsyncOp<boolean, string>

      A handle to the async operation, which is marked as completed once the dispatch was queued on core.

      This method only queues the dispatch on the core thread, it does not wait for the dispatch to complete. The material must have a compute shader technique for this to work. Otherwise an error will be returned.

    • Duplicates the resource and creates a unique UUID for the duplicated resource.

      Returns Resource

      The duplicated resource or null, if the duplication failed.

    • Returns a boolean value assigned with the parameter with the specified name.

      Optionally if the parameter is an array you may provide an array index you which to retrieve.

      Parameters

      • name: string

        Parameter name.

      • OptionalarrayIndex: number

        Position index as an array.

      Returns boolean

    • Returns a buffer assigned with the parameter with the specified name.

      Parameters

      • name: string

      Returns GPUBuffer

    • Returns a color assigned with the parameter with the specified name. If a color gradient is assigned to this parameter, returns the gradient color evaluated at time 0.

      Optionally if the parameter is an array you may provide an array index you which to retrieve.

      Parameters

      • name: string
      • OptionalarrayIndex: number

      Returns LinearColor

    • Returns a color gradient assigned with the parameter with the specified name. If the parameter has a constant value bound instead of a gradient then this method returns an empty gradient.

      Optionally if the parameter is an array you may provide an array index you which to retrieve.

      Parameters

      • name: string
      • OptionalarrayIndex: number

      Returns ColorGradientHDR

    • Returns a float value assigned with the parameter with the specified name. If a curve is assigned to this parameter, returns the curve value evaluated at time 0.

      Optionally if the parameter is an array you may provide an array index you which to retrieve.

      Parameters

      • name: string
      • OptionalarrayIndex: number

      Returns number

    • Returns a curve value assigned to the parameter with the specified name. If the parameter has a constant value bound instead of a curve then this method returns an empty curve.

      Optionally if the parameter is an array you may provide an array index you which to retrieve.

      Parameters

      • name: string
      • OptionalarrayIndex: number

      Returns AnimationCurve

    • Gets the CarbonGraph and cooks the underlying shader immediately.

      Returns Resource

    • Returns an integer value assigned with the parameter with the specified name.

      Optionally if the parameter is an array you may provide an array index you which to retrieve.

      Parameters

      • name: string

        Parameter name.

      • OptionalarrayIndex: number

        Position index as an array.

      Returns number

    • Returns a 3x3 matrix assigned with the parameter with the specified name.

      Optionally if the parameter is an array you may provide an array index you which to retrieve.

      Parameters

      • name: string
      • OptionalarrayIndex: number

      Returns Matrix3

    • Returns a 4x4 matrix assigned with the parameter with the specified name.

      Optionally if the parameter is an array you may provide an array index you which to retrieve.

      Parameters

      • name: string
      • OptionalarrayIndex: number

      Returns Matrix4

    • Returns a SpriteImage assigned to the material parameter.

      Parameters

      • name: string

        Name of the texture parameter.

      Returns SpriteImage

      SpriteImage assigned to the specified material or null if not found.

    • Returns a texture assigned to the material. If the material has a sprite texture assigned, this will return the parent texture of the sprite.

      Parameters

      • name: string

        Name of the texture parameter.

      Returns Texture

      Texture assigned to the specified material

    • Returns an unsigned integer value assigned with the parameter with the specified name.

      Optionally if the parameter is an array you may provide an array index you which to retrieve.

      Parameters

      • name: string

        Parameter name.

      • OptionalarrayIndex: number

        Position index as an array.

      Returns number

    • Returns a 2D vector assigned with the parameter with the specified name.

      Optionally if the parameter is an array you may provide an array index you which to retrieve.

      Parameters

      • name: string
      • OptionalarrayIndex: number

      Returns Vector2

    • Returns a 2D vector assigned with the parameter with the specified name.

      Optionally if the parameter is an array you may provide an array index you which to retrieve.

      Parameters

      • name: string
      • OptionalarrayIndex: number

      Returns Vector2

    • Returns a 2D vector assigned with the parameter with the specified name.

      Optionally if the parameter is an array you may provide an array index you which to retrieve.

      Parameters

      • name: string
      • OptionalarrayIndex: number

      Returns Vector2

    • Returns a 3D vector assigned with the parameter with the specified name.

      Optionally if the parameter is an array you may provide an array index you which to retrieve.

      Parameters

      • name: string
      • OptionalarrayIndex: number

      Returns Vector3

    • Returns a 3D vector assigned with the parameter with the specified name.

      Optionally if the parameter is an array you may provide an array index you which to retrieve.

      Parameters

      • name: string
      • OptionalarrayIndex: number

      Returns Vector3

    • Returns a 3D vector assigned with the parameter with the specified name.

      Optionally if the parameter is an array you may provide an array index you which to retrieve.

      Parameters

      • name: string
      • OptionalarrayIndex: number

      Returns Vector3

    • Returns a 4D vector assigned with the parameter with the specified name.

      Optionally if the parameter is an array you may provide an array index you which to retrieve.

      Parameters

      • name: string
      • OptionalarrayIndex: number

      Returns Vector4

    • Returns a 4D vector assigned with the parameter with the specified name.

      Optionally if the parameter is an array you may provide an array index you which to retrieve.

      Parameters

      • name: string
      • OptionalarrayIndex: number

      Returns Vector4

    • Returns a 4D vector assigned with the parameter with the specified name.

      Optionally if the parameter is an array you may provide an array index you which to retrieve.

      Parameters

      • name: string
      • OptionalarrayIndex: number

      Returns Vector4

    • Checks does the data parameter with the specified name currently contains animated data. This could be an animation curve or a color gradient.

      Parameters

      • name: string
      • OptionalarrayIndex: number

      Returns boolean

    • Virtual

      Method called by RSX to perform actions required after the creation of the resource.

      Returns void

    • Virtual

      Method called by RSX to perform any operations needed after deserialization.

      Returns void

      Use this API to restore your serializable data into live objects.

    • Virtual

      Method called by RSX to disable the resource.

      Returns void

      Use this API to deactivate the resource before it is serialized.

    • Virtual

      Method called by RSX to enable the resource.

      Returns void

      Use this API to activate the resource after it has been disabled by serialization.

    • Virtual

      Method called by RSX to perform initialization of the resource.

      Returns void

      Use this API to initialize data and default construct all fields.

    • Virtual

      Method called by RSX to perform any operations before serialization.

      Returns void

      Use this API to bake your live data into serializable data.

    • Reverts the resource to the on-disk representation.

      Returns boolean

      This is a potentially expensive call, as it needs to deserialize and replace all existing in-memory resource handles.

    • Assigns a boolean value to the shader parameter with the specified name.

      Optionally if the parameter is an array you may provide an array index to assign the value to.

      Parameters

      • name: string
      • value: boolean
      • OptionalarrayIndex: number

      Returns void

    • Assigns a buffer to the shader parameter with the specified name.

      Parameters

      Returns void

    • Assigns a color to the shader parameter with the specified name.

      Optionally if the parameter is an array you may provide an array index to assign the value to.

      Parameters

      Returns void

    • Assigns a color gradient to the shader parameter with the specified name. The system will automatically evaluate the gradient with the passage of time and apply the evaluated value to the parameter.

      Optionally if the parameter is an array you may provide an array index to assign the value to.

      Parameters

      Returns void

    • Assigns a float value to the shader parameter with the specified name.

      Optionally if the parameter is an array you may provide an array index to assign the value to.

      Parameters

      • name: string
      • value: number
      • OptionalarrayIndex: number

      Returns void

    • Sets the CarbonGraph and cooks the underlying shader immediately.

      Parameters

      Returns boolean

    • Assigns an integer value to the shader parameter with the specified name.

      Optionally if the parameter is an array you may provide an array index to assign the value to.

      Parameters

      • name: string
      • value: number
      • OptionalarrayIndex: number

      Returns void

    • Assigns a 3x3 matrix to the shader parameter with the specified name.

      Optionally if the parameter is an array you may provide an array index to assign the value to.

      Parameters

      Returns void

    • Assigns a 4x4 matrix to the shader parameter with the specified name.

      Optionally if the parameter is an array you may provide an array index to assign the value to.

      Parameters

      Returns void

    • Assigns an unsigned integer value to the shader parameter with the specified name.

      Optionally if the parameter is an array you may provide an array index to assign the value to.

      Parameters

      • name: string
      • value: number
      • OptionalarrayIndex: number

      Returns void

    • Assigns a 2D vector to the shader parameter with the specified name.

      Optionally if the parameter is an array you may provide an array index to assign the value to.

      Parameters

      Returns void

    • Assigns a 2D vector to the shader parameter with the specified name.

      Optionally if the parameter is an array you may provide an array index to assign the value to.

      Parameters

      Returns void

    • Assigns a 2D vector to the shader parameter with the specified name.

      Optionally if the parameter is an array you may provide an array index to assign the value to.

      Parameters

      Returns void

    • Assigns a 3D vector to the shader parameter with the specified name.

      Optionally if the parameter is an array you may provide an array index to assign the value to.

      Parameters

      Returns void

    • Assigns a 3D vector to the shader parameter with the specified name.

      Optionally if the parameter is an array you may provide an array index to assign the value to.

      Parameters

      Returns void

    • Assigns a 3D vector to the shader parameter with the specified name.

      Optionally if the parameter is an array you may provide an array index to assign the value to.

      Parameters

      Returns void

    • Assigns a 4D vector to the shader parameter with the specified name.

      Optionally if the parameter is an array you may provide an array index to assign the value to.

      Parameters

      Returns void

    • Assigns a 4D vector to the shader parameter with the specified name.

      Optionally if the parameter is an array you may provide an array index to assign the value to.

      Parameters

      Returns void

    • Assigns a 4D vector to the shader parameter with the specified name.

      Optionally if the parameter is an array you may provide an array index to assign the value to.

      Parameters

      Returns void

    • Forcefully unloads the resource.

      Returns void

    onOutdatedCarbonMaterialDiscovered: Event<
        [recompliedMaterial: ResourceHandle<Resource>],
        boolean,
    >

    Triggered when a carbon material was initialized that has outdated dependencies. If the event returns false, the automatic recompilation begins.

    onOutdatedCarbonMaterialRecompiled: Event<
        [
            recompliedMaterial: ResourceHandle<Resource>,
            state: EnumValue<TaskState, number>,
        ],
    >

    Triggered when a carbon material was recompiled that had outdated dependencies. The material should be saved to the project.

    onCompilationStateChanged: Event<
        [
            taskUUID: UUID,
            taskState: EnumValue<TaskState, number>,
            taskTimeInSeconds: number,
        ],
    >

    Triggered when the state of a code compilation changed.