Skip to content
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

Shader params that are arrays of unspecified length #481

Merged
merged 3 commits into from Mar 18, 2015

Conversation

lgritz
Copy link
Collaborator

@lgritz lgritz commented Mar 16, 2015

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.

// Store the actual length in the shader instance parameter
// override info.
so->arraylen (valuetype.arraylen);
// Allocate space for the new param size and the end of its
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: at the end

@aconty
Copy link
Contributor

aconty commented Mar 16, 2015

LGTM

lgritz and others added 2 commits March 17, 2015 08:39
becomes definite when an instance value is attached, or when a
connection is made. This was always intended but missing logic to make
it work properly.

This is primarily the work of Max Liani. Some debug/cleanup, comments,
and test cases added by LG follow in the next checkin.
work to allow shader parameters that are arrays of unspecified length.
lgritz added a commit that referenced this pull request Mar 18, 2015
Shader params that are arrays of unspecified length
@lgritz lgritz merged commit 4f80710 into AcademySoftwareFoundation:master Mar 18, 2015
@lgritz lgritz deleted the max-vararray branch March 18, 2015 21:43
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.

None yet

4 participants