viaWebGL
viaWebGL copied to clipboard
add interactivity to openSeadragonGL
We now copy the rendered canvas before any application of shaders. Then, all shaders take the original rendered canvas as input for every subsequent update to the tiles. This allows interactive updating of parameters passed to the shaders.
Additionally, the world is updating on init of openSeadragonGL. Previously, one could only observe the effect of the shaders if the openseadragon world happened to update after the init of openSeadragonGL due to interaction or loading of tiles.
I tried this but found the GLSL updates were not being rendered. To fix it, I changed tools/openSeadragonGL.js
to make sure GLSL is called on every tile draw (instead of only the first time each tile is drawn):
'tile-drawing': function(callback, e) {
- if (e.tile.loaded !==1) {
+ // if (e.tile.loaded !==1) {
+ if (true) {
e.tile.loaded = 1;
callback(e);
}
In the gamma change handler in my top-level script that calls OpenSeadragonGL, I set the gamma to a new value and then add a call to forceRedraw()
:
var forceRedraw = function () {
for (var i = 0; i < viewer.world.getItemCount(); i++) {
var tiled_image = viewer.world.getItemAt(i);
tiled_image._needsDraw = true;
}
viewer.world.update();
}
Now changing the gamma updates the display instantly, which is lovely.
As a further improvement, it would be good to flag when the input parameters to GLSL change, so that the tile-drawing callback only invokes GLSL when required.