FNNDSC / FNNDSC/ami

[refactoring] improve WebGL shaders GLSLIFY-like on demand generation

Open
#196 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
745
Forks
212
PR merge metrics
No merged PRs in 30d

Description

We would like to generate specialized shaders on demand.

The current system works but is hard to read/work with.

I was hoping to leverage ES6 string template literals but didn't manage to do it yet.

We used to rely on GLSLIFY but the shaders can not be generated dynamically on the front end.
Ideally we would like to generate shaders in a similar manner as GLSLIFY from the front end.

Most important is that is must be "easy" to read/edit shaders.

For instance we have 2 interpolation methods:
```
void identity(in vec3 currentVoxel, out vec4 dataValue){
...
}

void linear(in vec3 currentVoxel, out vec4 dataValue){
...
}
```

Ideally our base fragment shader would replace its "interpolation" method by the one we want.

We can leverage uniforms to know which interpolation method should be injected.
```
void main() {
//
vec3 voxel = ...;
vec4 value = ...;
${interpolationMethod...}(voxel, value);
...
}
```

https://github.com/FNNDSC/ami/blob/dev/src/shaders/shaders.data.fragment.js#L74

Also it has to work recursively... (that was the main challenge)

In our case, interpolation could also in turn inject a specify "unpack" method, depending on which type of data is being visualized.

Please do not hesitate to ask question if it looks like an interesting challenge to you!

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.