Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Update Matrix uniforms crashes V8 #10553

Closed
shirecoding opened this issue May 20, 2024 · 5 comments
Closed

Bug: Update Matrix uniforms crashes V8 #10553

shirecoding opened this issue May 20, 2024 · 5 comments
Assignees

Comments

@shirecoding
Copy link

Current Behavior

Unable to update uniform matrix in shader by setting the matrix as container's worldTransform

Expected Behavior

Should be able to update the uniform matrix by passing in the worldStage container's worldTransform

Steps to Reproduce

With the following shader

Shader.from({
        gl: shaders[s],
        resources: {
            uTexture: texture.source,
            uniforms: {
                uWorldStageTransform: { <----- this crashes
                    value: new Matrix(),
                    type: "mat3<f32>",
                },
                uTx: { <---- this works
                    value: 0,
                    type: "f32",
                },
                uTy: {
                    value: 0,
                    type: "f32",
                },
                uTextureHeight: {
                    value: pixelHeight,
                    type: "f32",
                },
                uTextureWidth: {
                    value: pixelWidth,
                    type: "f32",
                },
            },
        },
    });

Updating the uniforms

// This crashes
shader.resources.uniforms.uniforms.uWorldStageTransform.a =
worldStage.worldTransform;
(in the vert shader)
mat3 mvp = uProjectionMatrix * uWorldTransformMatrix * uWorldStageTransform * uTransformMatrix;

// This works
shader.resources.uniforms.uniforms.uTx = t.tx;
shader.resources.uniforms.uniforms.uTy = t.ty;
(in the vert shader)
gl_Position = vec4((mvp * vec3(aPosition + aInstancePosition + vec2(uTx, uTy), 1.0)).xy, 0.0, 1.0) ;

error:

Uncaught TypeError: Cannot read properties of undefined (reading 'replace')
    at generateUniformsSync (generateUniformsSync.ts:75:57)
    at GlUniformGroupSystem._generateUniformsSync (GlUniformGroupSystem.ts:102:16)
    at GlUniformGroupSystem._createUniformSyncFunction (GlUniformGroupSystem.ts:92:36)
    at GlUniformGroupSystem._getUniformSyncFunction (GlUniformGroupSystem.ts:80:21)
    at GlUniformGroupSystem.updateUniformGroup (GlUniformGroupSystem.ts:66:35)
    at eval (eval at generateShaderSyncCode (GenerateShaderSyncCode.ts:112:12), <anonymous>:20:29)
    at GlShaderSystem.bind (GlShaderSystem.ts:95:22)
    at GlEncoderSystem.draw (GlEncoderSystem.ts:56:25)
    at GlMeshAdaptor.execute (GlMeshAdaptor.ts:83:26)
    at MeshPipe.execute (MeshPipe.ts:193:23)

Environment

Pixi: 8.1.4

Possible Solution

No response

Additional Information

No response

@GoodBoyDigital
Copy link
Member

heya! please can you provide this as a playground? I can then help address! thanks!

@GoodBoyDigital GoodBoyDigital self-assigned this May 20, 2024
@shirecoding
Copy link
Author

Sure, here it is

https://www.pixiplayground.com/#/edit/ygcHzzCAKj51Z4OBlFQ26

you can uncomment out the part that works to see that the bunny is offset to 100 px

@GoodBoyDigital
Copy link
Member

heya, the type should be mat3x3<f32>

export type UNIFORM_TYPES_SINGLE =

@GoodBoyDigital
Copy link
Member

If you are using TS, it should give type safety! The PR should make it easier to catch in the future for js too! #10562

@shirecoding
Copy link
Author

ahh i see, i was using typescript, but it doesnt report the type errors somehow in VS code, it says it should be type string

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants