-
Notifications
You must be signed in to change notification settings - Fork 333
feat: define DATA_VALUE_TYPE and DATA_VALUE_TYPE_IS_* for shaders
#856
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
Just my thoughts... DATA_TYPE or dataType would be a preferable name. dataType x = toNormalized(getDataValue());Also, the several following |
|
Maybe |
|
Can you also add this to the documentation (https://github.com/google/neuroglancer/blob/master/src/sliceview/image_layer_rendering.md)? |
|
|
||
| ```glsl | ||
| DATA_VALUE_TYPE value = getDataValue(); | ||
| #if DATA_VALUE_TYPE == float |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wait does that actually work?
I thought the GLSL preprocessor was similar to the C preprocessor except more limited? Without token pasting ## most of the "advanced C preprocessor" tricks are unavailable.
In particular, using the C preprocessor it is possible through advanced techniques to perform an equality check like you have above but I don't know that it would be possible in GLSL.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having float in the conditional errors for me, it seems to restricted to integer values.
#define FOO 6
#if FOO == 6
setColor(vec4(1.0, 0.0, 0.0, 1.0));
#endifThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks both for catching that! I should have tested that basic use case. How about the proposed solution in c93afc3?
E.g. shader
#uicontrol invlerp normalized
void main() {
DATA_VALUE_TYPE value = getDataValue();
#if DATA_VALUE_TYPE_IS_UINT8_T
if (value.value > 80u) {
emitRGBA(vec4(1.0f, 0.0, 0.0f, 1.0f));
return;
}
#endif
emitGrayscale(normalized());
}There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm curious what your actual use case is for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The main use case for my lab is to check for a data-type dependent sentinel value for masking. Doing this at runtime in neuroglancer is much simpler than what we do currently, and I'd guess other people may find some utility in this.
SHADER_TYPE for shadersDATA_VALUE_TYPE and DATA_VALUE_TYPE_IS_* for shaders
Since `getDataValue` etc returns a single channel
This is handy for writing generic user shaders that use
getDataValue()etc