Skip to content

How can i use a texture in a shader ? #1009

Answered by ykafia
ykafia asked this question in Q&A
Discussion options

You must be logged in to vote

Self answering :

The best way to include a texture to a shader through the editor is to use composition.

shader ParameterTexture : Texturing, ComputeColor
{
    // This can be either a texture, a shader... Anything that implements ComputeColor
    compose ComputeColor MatrixTexture;

    override float4 Compute()
    {
        streams.TexCoord.x = 0;
        float4 color = MatrixTexture.Compute();
        return color;
    }
};

Replies: 1 comment

Comment options

ykafia
Jan 28, 2021
Maintainer Author

You must be logged in to vote
0 replies
Answer selected by ykafia
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant