Code generation only works for PixelShader (Dx11) / Fragment Shader (OpenGL)
When performing lookup table sampling, OpenColorIO uses the following :
outColor.r = ocio_lut1d_0.Sample(ocio_lut1d_0Sampler, ocio_lut1d_0_computePos(outColor.r)).r;
This makes it impossible to use the generated code outside of a pixel shader, since in compute or other stages, we are not able to have automatic mip selection.
generated code should be :
outColor.r = ocio_lut1d_0.SampleLevel(ocio_lut1d_0Sampler, ocio_lut1d_0_computePos(outColor.r),0).r;
This is the same in OpenGL where we should enforce LOD = 0
This change should be for both 3d and 1d lookup textures.
I'm happy to make a PR if needed, if you prefer to avoid potential breaking changes, I'm also happy to make it as an Option in settings:
`shaderDesc->useLodSampling(true);
Thank Julien
Thanks for the suggestion. You are certainly welcome to make a PR. We have some breaking changes to the GPU API coming in OCIO 2.5 which will release in September, so clients will all need to review their GPU code when updating to that.
From what I looked, given the way sampling works, it should never look for another level than 0 (and that would badly break 1d luts anyway).
So I think instead of adding an option we could go straight to enforcing it, so at least it's clearer and does not clutter the api with a confusing option.
If you happy with that will make PR next week (I already tested it on d3d11, also got an opengl pipeline using it so I can verify there too)
We certainly never want mipmapping to be applied to the LUT textures. So it seems fine to enforce that as long as it does not break people's code that uses older versions of the shading languages.
Ok so it would be fine to add the change for GPU_LANGUAGE_HLSL_SM_5_0 GPU_LANGUAGE_GLSL_4_0
(For other it requires an extension and older versions don't really support compute anyway so it would not benefit from that change)