Skip to content

feat: interpolation in shader UI controls invlerp/transfer function and use interpolation in multi-channel setup for volume rendering#855

Open
seankmartin wants to merge 10 commits intogoogle:masterfrom
MetaCell:feat/interpolation-in-ui-controls
Open

feat: interpolation in shader UI controls invlerp/transfer function and use interpolation in multi-channel setup for volume rendering#855
seankmartin wants to merge 10 commits intogoogle:masterfrom
MetaCell:feat/interpolation-in-ui-controls

Conversation

@seankmartin
Copy link
Copy Markdown
Contributor

@seankmartin seankmartin commented Oct 21, 2025

Summary

Adds an interpolation parameter to the invlerp and transferFunction shader ui controls, which enables trilinear interpolation when sampling the data. The default remains as using the nearest neighbour.

New parameter

#uicontrol invlerp contrast
#uicontrol vec3 color color
void main() {
  if (VOLUME_RENDERING) {
    float contrast_value = contrast(true /* interpolation */);
    emitRGBA(vec4(color * contrast_value, contrast_value));
  }
  else {
    float contrast_value = contrast(false /* no interpolation */);
    emitRGB(color * contrast_value);
  }
}

@jbms
Copy link
Copy Markdown
Collaborator

jbms commented Nov 3, 2025

I suppose it may commonly be desired to have interpolation enabled for volume rendering and disabled otherwise, which indeed makes it less useful to have as a property of the invlerp control unless we also add separate volume rendering and non-volume rendering options.

@seankmartin
Copy link
Copy Markdown
Contributor Author

seankmartin commented Nov 4, 2025

Thanks Jeremy, I think maybe best to go down a route similar to Option 1 for now then. Unsure what would be clearer for the user in the shader.

Could do something like:

#uicontrol invlerp contrast

contrast() /* as normal, has all the available parameters */
contrastInterpolated() /* with interpolation */

As opposed to an overload of the contrast function that takes in a bool as a parameter.

Edit: just realised we can't do that because we could get redefinition if the user has another invlerp called contrastInterpolated. Will set back to using overloads.

@seankmartin seankmartin changed the title Feat: interpolation in shader UI controls invlerp/transfer function feat: interpolation in shader UI controls invlerp/transfer function and use interpolation in multi-channel setup for volume rendering Nov 4, 2025
@seankmartin seankmartin marked this pull request as ready for review November 4, 2025 12:28
@seankmartin seankmartin marked this pull request as draft February 20, 2026 11:08
@seankmartin seankmartin marked this pull request as ready for review February 20, 2026 12:09
@seankmartin
Copy link
Copy Markdown
Contributor Author

Hi @jbms @fcollman I've expanded this to include a test for the behaviour and also the docs to include the new parameter

@chrisj
Copy link
Copy Markdown
Contributor

chrisj commented Feb 26, 2026

code looks good!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants