-
Notifications
You must be signed in to change notification settings - Fork 124
Usd camera support test #1034
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
Usd camera support test #1034
Conversation
Merge ImageEngine cortex master to my fork
Add functions to UsdScene.cpp so that usdGeomCamera will be read correctly and converted to IECoreScene camera. Tests : Add Unit test for importing UsdGeomCamera
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.
Thanks for the PR Naiqi ! These are only suggestions on how to improve the PR and hopefully they're uncontentious to the official cortex developers.
Gafffer & Cortex have reasonably strict formatting rules and these stand out to me :
- Use tabs instead of spaces
- There is almost always a space after '(' and before ')' unless it's '()'
- rebase your branch onto origin/master to avoid merge commits to update your topic branch to upstream/master
GetStereoRoleAttr
perhaps this should be copied to the Camera somewheere? A Camera is a BlindDataHolder
so perhaps the attribute should be serialized there and written back out if it exists?
result->setApertureOffset(Imath::V2f(horizontalOff / 10.0f, verticalOff / 10.0f)); | ||
|
||
} | ||
else { } |
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.
Currently all possible values for projToken are covered. Perhaps we should warn in the else if another camera type is added to USD?
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.
We don't handle it on the way out, so I'd be happy just leaving out the else {}
for now.
self.assertTrue( camera.hasObject() ) | ||
|
||
cameraObj = camera.readObject( 0.0 ) | ||
self.failUnless( isinstance( cameraObj, IECoreScene.Camera ) ) |
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'd test all of the attributes in we expect to be transferred from the camera. In fact it would be great to round trip a camera in testing, i.e. create a camera in cortex, write to USD and read back in again with as little data loss as possible.
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.
Yeah, definitely need to test all values for read at minimum. A roundtrip test as well would be ideal, but in addition to a read test - to make sure we test reading data in we haven't authored.
Hey Naiqi, thanks for getting this up! Looking promising. I'll get back to you with a proper review soon - sorry we're just in the middle of a big Gaffer release so have been somewhat busy.
Thanks @dboogert, you are spot on with your comments there. |
Hey guys
@dboogert Don, Thanks for the comments and suggestions, I will tweak my
submission accordingly.
@tom, I do have a question for this: I just found out for this camera to be
able to work properly inside of Gaffer as a renderable camera, I need to
change some of Gaffer's RenderController code as well. I am wondering in
this kind of situation, what's the proper procedure to submit PR for Gaffer
repo?
Thanks guys!
Naiqi
…On Thu, Feb 6, 2020 at 11:19 PM Tom Cowland ***@***.***> wrote:
Hey Naiqi, thanks for getting this up! Looking promising. I'll get back to
you with a proper review soon - sorry we're just in the middle of a big
Gaffer release so have been somewhat busy.
These are only suggestions on how to improve the PR and hopefully they're
uncontentious to the official cortex developers.
Thanks @dboogert <https://github.com/dboogert>, you are spot on with your
comments there.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#1034?email_source=notifications&email_token=ABS5XWBWCFVWMDIURPWMRQDRBQS6XA5CNFSM4KOSUEV2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEK7SZ2A#issuecomment-582954216>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABS5XWE2YNH265HRH33JTV3RBQS6XANCNFSM4KOSUEVQ>
.
|
Are you able to explain a little more why you need to change RenderController? I wouldn't expect there to be any changes needed there.
The procedure for gaffer is pretty much the same as for cortex. ie:
'best |
Hi, Tom
This is the reason: if I only convert the output object of SceneReader to
be IECore::camera into the scene, when you have the following graph for
rendering, Arnold can't recognize this object as known camera, therefore it
will crash if you click on the render button on "InterativeArnoldRender"
node. You can try it out with the cortex change and see.
[image: image.png]
I found in Gaffer source code, RenderControll.cpp, at the very end of
updateObject() function, if I replace
m_objectInterface = renderer->object( name, object.get(),
attributesInterface( renderer ) );
with the following code
bool updateObject( const ObjectPlug *objectPlug, Type type,
IECoreScenePreview::Renderer *renderer, const IECore::CompoundObject
*globals, const ScenePlug *scene, LightLinks *lightLinks )
{
....
else
{
if(object->typeId() == IECoreScene::Camera::staticTypeId())
{
if( const IECoreScene::Camera *camera =
runTimeCast<const IECoreScene::Camera>( object.get() ) )
{
IECoreScene::CameraPtr cameraCopy =
camera->copy();
RendererAlgo::applyCameraGlobals(
cameraCopy.get(), globals, scene );
m_objectInterface = renderer->camera( name,
cameraCopy.get(), attributesInterface( renderer ) );
}
}
else
m_objectInterface = renderer->object( name,
object.get(), attributesInterface( renderer ) );
}
return true;
}
Then in /GafferArnold/IECoreArnoldPreview/Renderer.cpp
updateCamera() will not crash on this line(line 3148):
Imath::V2i resolution = cortexCamera->renderResolution();
If I didn't have the above change in RenderController.cpp to register this
cortex camera to Arnold, when arnold is calling updateCamera(), it can't
find valid cortex camera and "cortexCamera" is nullptr and the above
renderResolution() call will crash Gaffer.
I may not understand the whole updating mechanism in Gaffer well, so this
may be a hacky solution. Please let me know if there is any way to make
this work nicely.
Naiqi
…On Fri, Feb 7, 2020 at 5:06 PM Tom Cowland ***@***.***> wrote:
@tom <https://github.com/tom>, I do have a question for this: I just
found out for this camera to be able to work properly inside of Gaffer as a
renderable camera, I need to change some of Gaffer's RenderController code
as well.
Are you able to explain a little more why you need to change
RenderController? I wouldn't expect there to be any changes needed there.
I am wondering in this kind of situation, what's the proper procedure to
submit PR for Gaffer
repo?
The procedure for gaffer is pretty much the same as for cortex. ie:
- Discuss the intended changes on the list first so we can make sure
it fits with the Gaffer approach before you spend any time on it.
- Fork gaffer and make a topic branch from the appropriate GafferHQ
branch with your changes (we have maintenance branches for older versions,
depending on the nature of the work).
- Submit a PR.
'best
Tom
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#1034?email_source=notifications&email_token=ABS5XWERUC5YO7Q5KGAQT5DRBUQCRA5CNFSM4KOSUEV2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOELCG2HI#issuecomment-583298333>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABS5XWBOQ4LJPS7UWQMNAZTRBUQCRANCNFSM4KOSUEVQ>
.
|
I suspect the Gaffer crash may be because the camera is not in the cameras set. We should probably look at generating the cameras set automatically in the USD reader as well. |
Hey Naiqi, Thanks for the extra details.
Right, cool. As John alluded to, this is actually a 'known issue we've been meaning to sort for a while. You have the same crash with alembic cameras. It happens as at the beginning of the render Gaffer translates all of the cameras in the
So don't worry about the Many thanks again for all the time you've spent on this! For now, you can also use the |
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.
Thanks for putting this together Naiqi, this is going to be a great addition. Don beat me to commenting on the more general coding standards topics. I've added a few other notes in here too.
result->setFocalLength(focalLengthVal / scale); | ||
result->setAperture(Imath::V2f(horizontalAper / scale, verticalAper / scale)); | ||
result->setApertureOffset(Imath::V2f(horizontalOff / scale, verticalOff / scale)); |
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 don't think we need to factor in scale
here. I believe it cancels out as long as they're in the same units. The only time the actual dimensions become meaningful is in relation to setFocusDistance
and the resulting DoF blur. @danieldresser-ie may be able to confirm.
// We store focalLength and aperture in arbitary units. USD uses tenths | ||
// of scene units | ||
float scale = 10.0f * result->getFocalLengthWorldScale(); |
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 think because of the USD assumption, this can just be:
result->setFocalLengthWorldScale( 0.1f );
I think this is working right now as the default for a newly created IECoreScene::Camera
is 0.1
so scale
will always end up just being 1.0f
.
I noticed that USD allows you to specify the linear encoding units in the file. I had a quick chat with @johnhaddon and we can leave supporting this for another time (as it needs some thought on the right way to do it), so just setting the 'assumed' scale is fine for now, unless it's going to cause issues for you.
result->setApertureOffset(Imath::V2f(horizontalOff / 10.0f, verticalOff / 10.0f)); | ||
|
||
} | ||
else { } |
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.
We don't handle it on the way out, so I'd be happy just leaving out the else {}
for now.
@@ -31,7 +31,6 @@ | |||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||
// | |||
////////////////////////////////////////////////////////////////////////// | |||
|
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.
Can we re-instate this line, we try to keep any whitespace changes in their own commits if they're required.
self.assertTrue( camera.hasObject() ) | ||
|
||
cameraObj = camera.readObject( 0.0 ) | ||
self.failUnless( isinstance( cameraObj, IECoreScene.Camera ) ) |
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.
Yeah, definitely need to test all values for read at minimum. A roundtrip test as well would be ideal, but in addition to a read test - to make sure we test reading data in we haven't authored.
Closing - IECoreUSD now reads cameras and the __cameras set. |
Add functions in USDScene.cpp so that SceneReader node will be able to read usdGeomCamera correctly and convert it to IECoreScene::camera into Gaffer.
Checklist