How to use the @pixi/core.UniformGroup.from function in @pixi/core

To help you get started, we’ve selected a few @pixi/core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pixijs / pixi.js / packages / graphics / src / Graphics.js View on Github external
{
                // if there is no shader here, we can use the default shader.
                // and that only gets created if we actually need it..
                if (!defaultShader)
                {
                    const sampleValues = new Int32Array(16);

                    for (let i = 0; i < 16; i++)
                    {
                        sampleValues[i] = i;
                    }

                    const uniforms = {
                        tint: new Float32Array([1, 1, 1, 1]),
                        translationMatrix: new Matrix(),
                        default: UniformGroup.from({ uSamplers: sampleValues }, true),
                    };

                    // we can bbase default shader of the batch renderers program
                    const program =  renderer.plugins.batch._shader.program;

                    defaultShader = new Shader(program, uniforms);
                }

                this.shader = defaultShader;
            }

            const uniforms = this.shader.uniforms;

            // lets set the transfomr
            uniforms.translationMatrix = this.transform.worldTransform;
github pixijs / pixi.js / packages / sprite / src / generateMultiTextureShader.js View on Github external
export default function generateMultiTextureShader(gl, maxTextures)
{
    const sampleValues = new Int32Array(maxTextures);

    for (let i = 0; i < maxTextures; i++)
    {
        sampleValues[i] = i;
    }

    const uniforms = {
        default: UniformGroup.from({ uSamplers: sampleValues }, true),
    };

    let fragmentSrc = fragTemplate;

    fragmentSrc = fragmentSrc.replace(/%count%/gi, maxTextures);
    fragmentSrc = fragmentSrc.replace(/%forloop%/gi, generateSampleSrc(maxTextures));

    const shader = Shader.from(vertex, fragmentSrc, uniforms);

    return shader;
}