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

OSL ShadingEngine : add *_index* as user data #2067

Merged
merged 1 commit into from May 5, 2017

Conversation

donboie
Copy link
Contributor

@donboie donboie commented Apr 28, 2017

@andrewkaufman mentioned it would be helpful if we had access the index of the vertex being shaded in OSLObject.

Called the user data _index to reduce the chance of collisions with primvars called index. Considered only adding the variable if a prim var doesn't exist but thought this was more confusing. Not very happy with this underscore convention but couldn't come up with anything neater.

InFloat can read this new _index primvar but not if the source data is defined as u64 so I attempt to use s32 before falling back to u64

}
else
{
return ShadingSystem::convert_value( value, type, &m_pointIndex, OIIO::TypeDesc( OIIO::TypeDesc::UINT64 ) );
Copy link
Member

Choose a reason for hiding this comment

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

Is there an OSL query where the UINT64 code path works? If this path is basically non-useful, I'm wondering if it might be better to always use the Int32 bit path, but issue a warning on overflow, rather than have a silent failure.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just assumed I'd be able to call the u64 version but it does look non-useful - didn't actually read the OSL language docs. Isn't the return code sufficient to indicate there is a problem, if not is there existing warn N times functionality I can use?

Copy link
Member

Choose a reason for hiding this comment

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

OSL docs seem to hedge and say that ints are "at least 32 bit", but in the implementation it looks like they are 32 bit, and looking at the source for convert_value, it doesn't appear to support anything else. The getattribute() return value could be used to detect failure from a shader, but I doubt anyone will check it for something they think of as built-in. I don't think we have an N-times functionality in the IECore::MessageHandler, but if we did, it wouldn't affect how you'd output the message - it'd be filtered after the fact.

I'm nitpicking really - just didn't like to have a code path that looks functional but isn't. Maybe we just add a comment explaining the situation and merge?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I committed a version which emits a warning but it looks out of place as we don't do that in the other cases where we return false from RenderState::userData. I don't have strong opinions either way on this.

@johnhaddon johnhaddon merged commit 6d2682a into GafferHQ:master May 5, 2017
@johnhaddon
Copy link
Member

Thanks Don!

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

2 participants