phaserjs / phaser

Phaser is a fun, free and fast 2D game framework for making HTML5 games for desktop and mobile web browsers, supporting Canvas and WebGL rendering.
https://phaser.io
MIT License
36.95k stars 7.08k forks source link

WebGLPipelineConfig Type is missing uniforms property from the type definition #6751

Closed scottwestover closed 2 weeks ago

scottwestover commented 6 months ago

Version

Description

The examples for shaders that extend the Phaser.Renderer.WebGL.Pipelines.PostFXPipeline class, include a property called uniforms, that is passed to to the parent class. When you use the same code with TypeScript, there is a warning about this property not existing on the WebGLPipelineConfig type.

Reference:

https://labs.phaser.io/edit.html?src=src/renderer/color%20post%20fx%20pipeline.js&v=3.80.1 and https://labs.phaser.io/assets/pipelines/BendPostFX.js

Example Test Code

Example code can be found here: https://github.com/scottwestover/template-vite-ts-bug-example. The main file is https://github.com/scottwestover/template-vite-ts-bug-example/blob/main/src/BendPostFX.ts, which is a slightly modified version of https://labs.phaser.io/assets/pipelines/BendPostFX.js.

To reproduce, in a TypeScript project, create a class that extends the Phaser.Renderer.WebGL.Pipelines.PostFXPipeline class, and in the super call, add in uniforms. You should see a TypeScript warning of uniforms not existing on the WebGLPipelineConfig type.

Additional Information

Screen Shot 2024-02-28 at 10 36 54 AM

Not sure if relevant, but when I don't provide the uniforms property to the configuration that is provide to the parent class, the code still works.

This might be related to https://github.com/phaserjs/phaser/issues/6737.

photonstorm commented 6 months ago

Hi Scott - This property is no longer required. A shader will automatically extract the uniforms via a WebGL call, so you don't need to list them anymore. However, it appears the examples have not been updated to reflect this. If you remove them from the example code, the example will still work just fine.

btw nice Phaser RPG series YouTube videos! Hopefully that's you? :)

scottwestover commented 6 months ago

Nice! Thanks for the quick response, and for your help.

Yes, that is me. Also, thank you for the kinds words about the series, really appreciate it :)

photonstorm commented 2 weeks ago

Ok, I have now fixed all of the pipeline examples so they no longer set uniforms.