Skip to content

IECoreScene Camera : Add depthOfField accessors #1475

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
10.x.x.x (relative to 10.5.x.x)
========

Improvements
------------

- IECoreScene::Camera : Added "depthOfField" parameter accessors.

Fixes
-----

Expand Down
7 changes: 7 additions & 0 deletions include/IECoreScene/Camera.h
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,13 @@ class IECORESCENE_API Camera : public PreWorldRenderable
void setShutter( const Imath::V2f &shutter );
void removeShutter();

/// Override whether the camera should render with depth of field blur. The amount of blur
/// can be controlled from the fStop parameter.
bool hasDepthOfField() const;
bool getDepthOfField() const;
void setDepthOfField( const bool &depthOfField );
void removeDepthOfField();

/// Given window with an arbitrary aspect, compute a box that fits it with a particular fit mode,
/// to achieve a desired target aspect ratio.
static Imath::Box2f fitWindow( const Imath::Box2f &window, Camera::FilmFit fitMode, float targetAspect );
Expand Down
1 change: 1 addition & 0 deletions src/IECoreScene/Camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ DECLARE_ACCESSORS_FOR_OPTIONAL( OverscanTop, "overscanTop", FloatData, 0.0f );
DECLARE_ACCESSORS_FOR_OPTIONAL( OverscanBottom, "overscanBottom", FloatData, 0.0f );
DECLARE_ACCESSORS_FOR_OPTIONAL( CropWindow, "cropWindow", Box2fData, Box2f() );
DECLARE_ACCESSORS_FOR_OPTIONAL( Shutter, "shutter", V2fData, V2f( -0.5f, 0.5f ) );
DECLARE_ACCESSORS_FOR_OPTIONAL( DepthOfField, "depthOfField", BoolData, false );

namespace {

Expand Down
5 changes: 5 additions & 0 deletions src/IECoreScene/bindings/CameraBinding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,11 @@ void bindCamera()
.def( "getShutter", &Camera::getShutter )
.def( "removeShutter", &Camera::removeShutter )

.def( "hasDepthOfField", &Camera::hasDepthOfField )
.def( "setDepthOfField", &Camera::setDepthOfField )
.def( "getDepthOfField", &Camera::getDepthOfField )
.def( "removeDepthOfField", &Camera::removeDepthOfField )

.def( "fitWindow", &Camera::fitWindow ).staticmethod( "fitWindow" )
.def<Imath::Box2f (Camera::*)() const>( "frustum", &Camera::frustum )
.def<Imath::Box2f (Camera::*)(Camera::FilmFit) const>( "frustum", &Camera::frustum )
Expand Down
6 changes: 6 additions & 0 deletions test/IECoreScene/Camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ def testRenderOverrides( self ):
self.assertEqual( c.hasOverscanBottom(), False )
self.assertEqual( c.hasCropWindow(), False )
self.assertEqual( c.hasShutter(), False )
self.assertEqual( c.hasDepthOfField(), False )

c.setFilmFit( IECoreScene.Camera.FilmFit.Vertical )
c.setResolution( imath.V2i( 1280, 720 ) )
Expand All @@ -175,6 +176,7 @@ def testRenderOverrides( self ):
c.setOverscanBottom( 0.4 )
c.setCropWindow( imath.Box2f( imath.V2f( 0.1, 0.2 ), imath.V2f( 0.8, 0.9 ) ) )
c.setShutter( imath.V2f( -0.7, 0.3 ) )
c.setDepthOfField( True )

self.assertEqual( c.hasFilmFit(), True )
self.assertEqual( c.hasResolution(), True )
Expand All @@ -187,6 +189,7 @@ def testRenderOverrides( self ):
self.assertEqual( c.hasOverscanBottom(), True )
self.assertEqual( c.hasCropWindow(), True )
self.assertEqual( c.hasShutter(), True )
self.assertEqual( c.hasDepthOfField(), True )

self.assertEqual( c.getFilmFit(), IECoreScene.Camera.FilmFit.Vertical )
self.assertEqual( c.getResolution(), imath.V2i( 1280, 720 ) )
Expand All @@ -199,6 +202,7 @@ def testRenderOverrides( self ):
self.assertAlmostEqual( c.getOverscanBottom(), 0.4 )
self.assertBox2fEqual( c.getCropWindow(), 0.1, 0.2, 0.8, 0.9 )
self.assertAlmostEqual( c.getShutter(), imath.V2f( -0.7, 0.3 ) )
self.assertEqual( c.getDepthOfField(), True )

c.removeFilmFit()
c.removeResolution()
Expand All @@ -211,6 +215,7 @@ def testRenderOverrides( self ):
c.removeOverscanBottom()
c.removeCropWindow()
c.removeShutter()
c.removeDepthOfField()

self.assertEqual( c.hasFilmFit(), False )
self.assertEqual( c.hasResolution(), False )
Expand All @@ -223,6 +228,7 @@ def testRenderOverrides( self ):
self.assertEqual( c.hasOverscanBottom(), False )
self.assertEqual( c.hasCropWindow(), False )
self.assertEqual( c.hasShutter(), False )
self.assertEqual( c.hasDepthOfField(), False )

def testHash( self ) :
c = IECoreScene.Camera()
Expand Down