pex-gl / pex-renderer

Physically based renderer (PBR) and scene graph for PEX.
https://pex-gl.github.io/pex-renderer/examples/index.html
MIT License
237 stars 16 forks source link

Add support for attribute.dirty #334

Closed vorg closed 1 year ago

vorg commented 1 year ago

We need a way to update only one attribute e.g. offsets without re-uploading all others. One solution would be to add .dirty = true/false property. This could be also used for invalidating bouds and and manually asking for recalculating bounding box.

dmnsgn commented 1 year ago

Revived instancing example and use it to demo attribute.dirty: https://github.com/pex-gl/pex-renderer/commit/13ed4154a4c7bf97fb00f7161f466415ae643022#diff-b9928ed31347ca26a5db354cc663e6275c0a7266edafd38ca237539ca95d2cd0R184-R188

The main change in the system are:

https://github.com/pex-gl/pex-renderer/blob/13ed4154a4c7bf97fb00f7161f466415ae643022/systems/geometry.js#L53-L65

https://github.com/pex-gl/pex-renderer/blob/13ed4154a4c7bf97fb00f7161f466415ae643022/systems/geometry.js#L92

dmnsgn commented 1 year ago

Performance in example (updating offsets/rotations/colors only instead of positions/normals/uvs/cells/offsets/scales/rotations/colors): 10ms -> 3.5ms