Commit graph

19615 commits

Author SHA1 Message Date
Ben Richards
45a73c1d2d Complete canvas clear logic. 2024-04-26 20:34:36 +12:00
Ben Richards
af2e4449a0 Add scissor handling and simplify clearing on DrawingContext.
Clearing was just too complex. It was optimized for edge cases,
and made it hard to create DrawingContexts for multiple cameras
drawing to the same framebuffer.
2024-04-26 19:05:32 +12:00
Ben Richards
a007adf05b Document and add textures to main draw method. 2024-04-26 12:14:38 +12:00
Ben Richards
2c2d856b14 Improve batch texture performance. 2024-04-26 11:20:38 +12:00
Ben Richards
dd2bc50628 Fix batch flushing at texture limit instead of over limit. 2024-04-24 17:05:26 +12:00
Ben Richards
ecda5880da Add WebGLVertexBufferLayoutWrapper to standardise buffer handling. 2024-04-24 16:03:10 +12:00
Ben Richards
3b4956cc16 Simplify vertex buffer length. 2024-04-24 11:16:23 +12:00
Ben Richards
b00a6fdc04 Fix massive memory usage and non-managed program. 2024-04-24 11:05:15 +12:00
Ben Richards
a26972d77e Do matrix transforms in vertex shader. 2024-04-23 21:07:34 +12:00
Ben Richards
cc78cf9480 Fix old framebuffer invocation. 2024-04-23 16:32:16 +12:00
Ben Richards
8d790b6ac4 Add basic RenderNode system.
This currently only handles basic multi-textured images/sprites
through a basic camera. It forms the basis of a major overhaul.

We assume everything is based on independent quads.
Our shaders are initialized with VAOs,
and drawn using instanced quads.
The buffer memory usage is about 1/6th previous.

Most render systems don't work, and WebGLRenderer is a mess.
That's OK; we just needed to get this committed before it got any
more complicated.
2024-04-23 16:29:08 +12:00
Ben Richards
9b5a21f20f Integrate Program Wrapper changes to WebGLRenderer.
Also define some return types.
2024-04-23 16:21:26 +12:00
Ben Richards
c95c8c527a Add DrawingContext for tracking current drawing settings.
This is not at all complete yet, but it's doing some useful stuff.
2024-04-23 16:18:38 +12:00
Ben Richards
4f367741b7 Add renderbuffer handling to WebGLFramebufferWrapper. 2024-04-23 16:17:02 +12:00
Ben Richards
d33845eb3b Add Vertex Array Object (VAO) wrapper.
Add VAO to global state.
Define a way to clearly denote attribute buffer layout.
Integrate buffer layout into Program Wrapper for auto-completion.
2024-04-23 16:09:09 +12:00
Ben Richards
fbcc3580a5 Add padding support to WebGLProgramWrapper.setVertexBuffer layout. 2024-03-28 15:20:21 +13:00
Ben Richards
30eef85537 Upgrade WebGLProgramWrapper to set uniforms and attributes.
This necessitated expanding the map of WebGL constants/functions,
resulting in `WebGLShaderSetterWrapper`.
2024-03-26 13:12:53 +13:00
Ben Richards
de3fc50979 Upgrade WebGLProgramWrapper to generate uniforms and attributes.
It assumes that programs do not change after creation, so these values
are static, and much can be inferred about their behaviour.
Uniform-setting code is implemented and has been tested on Shader.
Attribute binding has not been finished.
- Change `gl` parameter to `renderer`.
2024-03-22 17:09:59 +13:00
Ben Richards
8272cf1a26 Fix reference to old resources on context restore. 2024-03-22 11:22:08 +13:00
Ben Richards
419d846498 Update WebGLBufferWrapper to use WebGLGlobalWrapper.
- Add `WebGLBufferWrapper.bind` to simplify attachment.
- Change `WebGLBufferWrapper` parameter `gl` to `renderer`.
2024-03-20 17:12:19 +13:00
Ben Richards
7cdd59eaf0 Make WebGLTextureUnitsWrapper.bind parameter units mandatory.
Allowing it to search for textures caused anomalies in video textures.
2024-03-20 16:16:07 +13:00
Ben Richards
4de15331dd Deprecate WebGLPipeline.bindTexture. 2024-03-20 15:53:50 +13:00
Ben Richards
13ed52f478 Use TextureUnits binding throughout the codebase.
- Remove `WebGLPipeline.activeTextures`, which is now covered by
  the more universal TextureUnit system.
- Change TextureUnitsWrapper to only bind `activeTexture` if the texture
  is not bound to that unit already.
- Remove `gl.isContextLost` check from `WebGLTextureWrapper`.
  The process should run without effect if context is lost,
  and we skip fetching data if it is not.
2024-03-19 22:08:59 +13:00
Ben Richards
d02c1f4a70 Fix WebGL background color. 2024-03-19 16:45:01 +13:00
Ben Richards
741fb897bd Implement WebGLRenderer.clearFramebuffer and use it. 2024-03-19 16:37:22 +13:00
Ben Richards
32bdb8ef0e Implement WebGLTextureUnitsWrapper and manage core texture ops with it.
Also tweak several related areas:
- Use `glWrapper` in `PipelineManager.rebind`, making WebGL state
  redeclaration more succinct.
- Add `WebGLRenderer.glTextureUnits` property.
- Deprecate `WebGLRenderer.textureindexes` property.
- Simplify WebGL context restoration with `glWrapper`.
- Remove `WebGLRenderer.createTemporaryTextures`.
- Remove texture units and binding from WebGLGlobalParameters.
- Change `WebGLTextureWrapper` to take `renderer` instead of `gl` as its
  first parameter. This allows us to use `glWrapper` code internally.
- `WebGLTextureWrapper` currently doesn't unbind textures after use,
  which might cause issues with framebuffers etc. We'll ensure that
  state management makes this a non-issue.
2024-03-19 14:52:49 +13:00
Ben Richards
46c9c95c02 Implement WebGLGlobalWrapper and manage blend modes with it.
The Wrapper won't do its job until everything uses wrappers,
but this is a start.
API changes:
- WebGLRenderer.blendModes type is now WebGLBlendParameters[]
  instead of untyped array.
- WebGLRenderer.updateBlendMode parameters now specify how to use
  separate parameters. The function no longer treats the `equation`
  parameter as optional.
2024-03-17 19:26:35 +13:00
Ben Richards
5b0af2f34c Correct transpose parameter for gl.uniformMatrixNfv().
The `transpose` property is never defined.
2024-03-08 18:28:24 +13:00
Ben Richards
9898a6aaae Update documentation on using compressed textures.
Correct the multiAtlas example.
Remove link to Mali, which has been discontinued.
Expand guidance on making valid compressed textures.
2024-03-07 18:06:51 +13:00
Ben Richards
0a2bede95e Limit textures probed by TextureManager.getPixel and getPixelAlpha. 2024-03-05 15:42:04 +13:00
Ben Richards
3c7bee4e08 Fix WebGL parameters on context restore. 2024-03-05 11:17:40 +13:00
Ben Richards
b851e591c7 Reduce synchronous calls to getShaderParameter.
This should reduce round-trip calls to the GPU.
We also delete the shaders after they're used.
Spector debug uses the shaders, so we hold onto them if debug is on.
2024-03-04 12:08:24 +13:00
Ben Richards
cd2beb06da Remove flipY parameter from Shader.setRenderToTexture. 2024-02-28 17:18:36 +13:00
Ben Richards
928ce1a1e7 Fix LightPipeline failing to render two objects in a batch. 2024-02-28 16:48:58 +13:00
Richard Davey
1ba01834ff Updated readme and change log for 3.80.1 2024-02-27 15:56:03 +00:00
Richard Davey
4f7445f8d7 v3.80.1 2024-02-27 15:53:24 +00:00
Richard Davey
8acc797b64 Updated documentation and removed Transform component 2024-02-27 15:48:31 +00:00
Richard Davey
6943c9bbca Reverted a change made in TouchManager that would prevent clicks from outside the game window from being registered. Fix #6747 2024-02-27 15:36:34 +00:00
Richard Davey
229f9232f4 Modified onMouseUpWindow and onMouseDownWindow in the MouseManager so they now check for sourceCapabilities.firesTouchEvents and if found, abort registering the event. This new browser event property is designed to prevent you accidentally registering a Mouse Event when a Touch Event has just occurred (see https://developer.mozilla.org/en-US/docs/Web/API/InputDeviceCapabilities/firesTouchEvents) #6747 2024-02-27 15:36:23 +00:00
Richard Davey
fb47fcf455 Update const.js 2024-02-27 14:59:29 +00:00
Ben Richards
b1806fd721 Remove unsynced flipY from Shader and DynamicTexture textures.
This might be causing some issues with context restore,
and seems entirely unnecessary.
2024-02-27 17:29:49 +13:00
Ben Richards
1b77881dd4 Ensure TextureSource.setFlipY always updates the texture.
When it's a Canvas or Video, at least.
2024-02-27 15:17:52 +13:00
Ben Richards
ec4a9d7328 Also revert release name. 2024-02-27 11:40:33 +13:00
Ben Richards
2615cf6a0f Prepare 3.80.1 bugfix release. 2024-02-27 11:24:04 +13:00
Ben Richards
37ba3510f2 Fix RenderTexture crashing in the presence of a light.
More generally, anything with a default/no normal map should be fixed.
2024-02-26 17:45:52 +13:00
Ben Richards
7eede9d236 Standardise texture update in Shader.initSampler2D. 2024-02-26 16:19:24 +13:00
Ben Richards
cab4bab15e Eliminate duplicate code in WebGL video handling.
This involves a new method, `videoToTexture`.
2024-02-23 19:16:18 +13:00
Ben Richards
9a5b51dd27 Eliminate duplicate code in WebGL texture creation/update.
This should make the code lighter and more maintainable.
`UNPACK_FLIP_Y_WEBGL` is now always set, where previously it was allowed
to just remain default (false); this is necessary for the new code path.
`Uint8Array` sources are now allowed to generate MIPMaps.
`WebGLTextureWrapper.update` now checks the type of `pixels`, although
it should only ever be the final case.
2024-02-23 18:43:27 +13:00
Ben Richards
42039a144e Fix failure to restore compressed textures after WebGL context loss. 2024-02-23 17:55:03 +13:00
Ben Richards
3cd756dbe9 Fix new WebGLTextures remaining bound after creation.
This caused an error when calling `Shader.setRenderToTexture()`
after the game started running.
The leftover texture caused a temporary cyclic reference with the new
Framebuffer. The actual rendering pipeline was not affected.
2024-02-22 19:01:03 +13:00