Shader params that are arrays of unspecified length #481
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
You could previously declare OSL functions that have parameters that are arrays of unspecified length (like 'float foo[]'), but there was not an effective way to make shader parameters like that.
This patch, mostly the work of Max Liani from Animal Logic (with a little touch-up from LG), more or less fully enables shader parameters that are arrays of unspecified length. When an instance value is provided, which must itself be of definite length, it fixes the length of the shader parameter. Or, within a shader group, when an upstream shader's output parameter (of definite length) is connected to a downstream shader's parameter of unspecified length, it fixes the length. This provides some interesting new flexibility to write shaders that take arrays as parameters, without knowing the maximum length when you are writing or compiling the shader.
It's still a little dicey to alter one of these parameters for "re-rendering". Even if you mark it as "lockgeom=0", once the length becomes fixed, it's fixed, and you can't (without redeclaring the shader group and starting over) change its length again. So beware of situations like that.
Max - I hope you approve of my changes. The overall logic is still as you had it, I just fixed a couple edge cases to address some bugs that I noticed when I made the test cases, and added lots of comments.