-
Notifications
You must be signed in to change notification settings - Fork 353
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
Remove MslRenderer camera initialization #1465
Remove MslRenderer camera initialization #1465
Conversation
@ashwinbhat @Morteeza @jstone-lucasfilm: Please have a look when you get a chance |
This change looks good to me, thanks @nicolassavva-autodesk, and I'd be interested in thoughts from @Morteeza and @ashwinbhat. |
I believe the difference comes from the following line: |
true. That probably will fix the issue. Btw, I noticed metal rendering tests were broken before. I opened a PR to fix it in case you want to try it locally. |
Also I believe this line needs to be removed too |
@@ -35,7 +35,12 @@ ShaderRenderer::ShaderRenderer(unsigned int width, unsigned int height, Image::B | |||
float fW = fH * 1.0f; | |||
_camera = Camera::create(); | |||
_camera->setViewMatrix(Camera::createViewMatrix(DEFAULT_EYE_POSITION, DEFAULT_TARGET_POSITION, DEFAULT_UP_VECTOR)); | |||
_camera->setProjectionMatrix(Camera::createPerspectiveMatrix(-fW, fW, -fH, fH, DEFAULT_NEAR_PLANE, DEFAULT_FAR_PLANE)); | |||
|
|||
#if defined (__APPLE__) |
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 might also want to make this Metal specific so that it can still work with OpenGL based MacOS
@jstone-lucasfilm: what would you recommend for the cleanest way for supporting both here?
Perhaps we can move the MaterialXView specific customization to a reusable place:
https://github.com/AcademySoftwareFoundation/MaterialX/blob/main/source/MaterialXView/CMakeLists.txt#L8-L27
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.
Should we remove the default camera in ShaderRenderer and have it setup by the caller?
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'm open to that option, @ashwinbhat, though I'm imagining that there may still be value in providing a default camera for simple use cases. As long as we continue to provide the option of overriding the default camera, it seems reasonable to make this default as suitable as possible for each platform.
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.
@nicolassavva-autodesk What if we were to pass a perspective matrix convention boolean into the constructor for ShaderRenderer
, allowing the caller to state which convention should be used for the default perspective matrix? This would allow the platform-independent ShaderRenderer class to remain agnostic of this platform detail, without requiring us to remove the default camera from ShaderRender entirely.
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 introduced an enum to select between OpenGL and Metal (in lieu of a boolean)
This should suffice for now and we should eventually consider propagating the changes into a future refactor of the Camera
class and the MaterialXViewer
d385cc7
to
169d64a
Compare
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 would recommend removing the default camera initialization ShaderRenderer so that the client can create and supply a camera that is suitable based on the underlying API implementation.
We already have setCamera API to allow this workflow.
@jstone-lucasfilm @Morteeza any thoughts on this suggestion?
@@ -35,7 +35,12 @@ ShaderRenderer::ShaderRenderer(unsigned int width, unsigned int height, Image::B | |||
float fW = fH * 1.0f; | |||
_camera = Camera::create(); | |||
_camera->setViewMatrix(Camera::createViewMatrix(DEFAULT_EYE_POSITION, DEFAULT_TARGET_POSITION, DEFAULT_UP_VECTOR)); | |||
_camera->setProjectionMatrix(Camera::createPerspectiveMatrix(-fW, fW, -fH, fH, DEFAULT_NEAR_PLANE, DEFAULT_FAR_PLANE)); | |||
|
|||
#if defined (__APPLE__) |
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.
Should we remove the default camera in ShaderRenderer and have it setup by the caller?
f01b0bb
to
c00d0b4
Compare
Thanks @nicolassavva-autodesk for changes and the rendered test.
Change look good as is. But as Ashwin suggested maybe it will be more explicit to remove camera GL/Metal camera initialization, and move it to test code implementations; something like this: |
Yes, agreed though perhaps that can wait for a future code refactor |
c00d0b4
to
ba0c7db
Compare
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.
This looks like a good approach to me, thanks @nicolassavva-autodesk.
With respect to naming conventions, what would you think about the following enumerated type for the new input argument?
enum MatrixConvention
{
MatrixOpenGL = 0,
MatrixMetal = 1
};
This would help to clarify which convention we're specifying with this argument, and the new enumeration could potentially be moved into a lower-level library (e.g. a math library) if needed further in the future.
Yes, renaming the enums to something more explicit sounds good to me |
I take it we are still keeping it as an
|
That's completely fine, and although we don't always use enum classes in MaterialX, I think it's a good direction for the future. |
… camera modification).
2110b08
to
d0d21fc
Compare
I just renamed the enum as discussed above and rebased the PR branch |
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.
This looks good to me, thanks @nicolassavva-autodesk!
84adc65
into
AcademySoftwareFoundation:main
Allow
ShaderRenderer
camera to be modified by the client in subclass renderers when using Metal.The PR removes the Metal Renderer specific camera initialization in
MslRenderer
(and now handled byShaderRenderer
).This addresses the same issue in a similar way to what was previously done for the
GlslRenderer
:"Improvements to ShaderRenderer"(60b1053)