Commit graph

19544 commits

Author SHA1 Message Date
Ben Richards
82738c78f2 Fix BatchHandler affecting unintended VAOs. 2024-05-29 21:01:08 +12:00
Ben Richards
d1a38d55c0 Remove renderer from RenderNode parameters.
It's easy to access via the manager parameter.
2024-05-28 19:36:03 +12:00
Ben Richards
7e16caeed7 Make render nodes customizable.
Game objects can now change their render node, in place of a pipeline.
Render nodes can be created with custom values,
to change their behavior or relationships.
Several nodes are renamed.
Program Wrapper now supports defining layouts with strings instead of
GLenums, to facilitate render node customization.
2024-05-27 18:32:34 +12:00
Ben Richards
9940554eba Optimize Program Wrapper. 2024-05-21 14:49:24 +12:00
Ben Richards
fedf494a4c Fix FillRect.
It wasn't updated to the latest batch paradigm. This fixes camera
fill, flash, and fade.
2024-05-20 17:03:41 +12:00
Ben Richards
261399642e Increase batch size to 16384.
This is the natural limit of 16-bit unsigned integer vertex indexes.
2024-05-17 17:17:49 +12:00
Ben Richards
6bbfde50da Use transformed elements instead of instanced rendering.
There is simply no good way to control instanced rendering with batches,
and there is no efficient way to use hardware transform when using
vertices to render.
2024-05-17 16:34:04 +12:00
Ben Richards
ce6324837e Transfer texture unit index array to WebGLRenderer.
This makes it universally accessible to any shader.
2024-05-16 12:08:20 +12:00
Ben Richards
8c5abcd060 Fix parallel texture unit check.
It was swapping mobile with desktop preferences, whoops.
2024-05-15 16:41:29 +12:00
Ben Richards
c43a45d985 Allow RenderNodeManager to change parallel texture unit count.
The BatchTexturedTintedRawQuads node listens to this, and will
recompile its shader to the indicated performance strategy.
2024-05-14 17:03:00 +12:00
Ben Richards
d120e0a4b5 Fix invalid create and destroy code in Program Wrapper.
There is no `deleteUniformLocation` command. (Thanks, AI hallucinations!)
2024-05-14 16:14:56 +12:00
Ben Richards
e57ed463b2 Reduce accessor use in VAO wrapper. 2024-05-13 15:25:50 +12:00
Ben Richards
c8c170672d Use sub-batches to handle many textures in batches.
This is the way 3.80 handles things, and is useful for performance on
mobile devices where we might only use 1 texture unit per sub-batch.
2024-05-13 15:23:01 +12:00
Richard Davey
2c1ad33e1a Update const.js 2024-05-02 14:41:51 +01:00
Ben Richards
717bd96879 Fix the last missing data from DrawingContext clones.
I hope.
2024-05-02 18:42:42 +12:00
Ben Richards
e7f1269c12 Fix DrawingContext missing critical data. 2024-05-02 18:36:55 +12:00
Ben Richards
f3d1da68a9 Fix and tidy code.
Fix camera background color not working (a call signature changed).
Fix render graph only recording the last camera
(by adding a synthetic root node to the graph).
2024-05-02 16:47:28 +12:00
Ben Richards
65e69a8369 Unify flipped crop handling. 2024-05-02 14:41:01 +12:00
Ben Richards
ee8ebbdd1c Render Video using the new system. 2024-05-01 18:36:29 +12:00
Ben Richards
f86a353a2d Render Text using the new system.
It may be more correct than ever, now that we've standardised it.
2024-05-01 17:34:23 +12:00
Ben Richards
3140edf0c3 Fix Text UV updates.
Previously, Text didn't update the TextureSource dimensions,
so its UVs were identical to resolution.
They should have been normalized to the 0-1 range.
It used `MultiPipeline.batchTexture` to render, which accommodated
these UVs.
These changes update the dimensions when Text changes its canvas size,
and this makes normalized UVs available.
2024-05-01 15:58:45 +12:00
Ben Richards
48d1164c16 Swap order of src and drawingContext parameters.
This makes the standard `renderWebGL` parameters more similar to their
original state: we're just replacing `camera` with `drawingContext`.
2024-04-30 18:09:25 +12:00
Ben Richards
45e89e4574 Make camera part of DrawingContext, and simplify RenderNode calls. 2024-04-30 16:58:45 +12:00
Ben Richards
9bf0276af9 Improve renderer event handling.
Hook batch rendering into resize events.
Fix context restore:
- Restore VAOs
- Fix Program uniform restore.
2024-04-30 12:14:10 +12:00
Ben Richards
061fd21e5f Disable PipelineManager in WebGLRenderer.
This eliminates a lot of unused resources. Some will be recreated later,
but for now it keeps development simple.
I'm not actually removing it, because I want to reference where it is
used for the moment.
2024-04-30 11:45:04 +12:00
Ben Richards
d8a64110f9 Add camera flash and fade effects. 2024-04-29 17:48:27 +12:00
Ben Richards
a7cc7472a6 Add FillRect render node, and camera background fill.
Also use a TextureWrapper instead of a Frame for quad batching,
which makes this possible.
2024-04-29 17:06:21 +12:00
Ben Richards
d43e45d2a4 Handle blend mode in DrawingContext and use it in ListCompositor. 2024-04-29 15:06:43 +12:00
Ben Richards
ef4731c8b1 Avoid Camera generating unchanged DrawingContext. 2024-04-29 10:21:43 +12:00
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