Skip to content

Getting options from an existing derived material #366

@repalash

Description

@repalash

Hello,

I am using the troika-three-text and rendering it to a GBuffer.

This is what I am doing right now -

const mat = new GBufferMaterial()
const gbufferMaterial = createTextDerivedMaterial(mat)
myText.customGBufferMaterial = gbufferMaterial 

customGBufferMaterial is then used similar to customDepthMaterial.

This works and the text is rendered to gbuffer.

The problem here is that the _prepareForRender function in Text is called multiple times a frame to update the 2 sets of uniforms in both the materials, which is not ideal.

So, Is there a way to create a custom depth/gbuffer material similar to how customDepthMaterial is created?
Or a simpler way could be to call createDerivedMaterial ourselves but that requires access to the options object that is passed in createDerivedMaterial when its first called for the text.
Another way is to set the isTroikaTextMaterial to false, and copy the uniforms by prefix, but it is set as read-only and non-configurable, so that's not possible.

Thanks for the library.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions