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
234 stars 16 forks source link

Geometry pipeline doesn't update #253

Closed vorg closed 1 year ago

vorg commented 4 years ago

Currently to change e.g. primitive from triangles to lines requires creating new material that would trigger creating new geometry pipeline. This is especially troubling because we take primitive from geometry... primitive: geometry.primitive so changing geometry actually doesn't trigger pipeline change. https://github.com/pex-gl/pex-renderer/blob/master/index.js#L660

vorg commented 4 years ago

Currently we do

const hash = material.id + '_' + program.id
let pipeline = this._pipelineCache[hash]

One solution would be adding lastChangeTimestamp to the material. It would be up to material to not to change that flag if set props with values that actually didn't change.

const hash = material.id + 
'_' + material.lastChangeTimestamp + 
'_'+ program.id +
'_' + geometry.primitive
let pipeline = this._pipelineCache[hash]
vorg commented 4 years ago

To set that lastChangeTimestamp i would need to if check on set if any pipeline modifying props has been set. Eg if opts.blend || opts.depthTest || ... which is brittle (i need to check all props and remember to update if i add any new ones) but most GC friendly

vorg commented 1 year ago

Fixed with dirty flags