Skip to content

Commit ceedfd8

Browse files
committed
Merge pull request #456 from appleseedhq/IECoreAppleseed
IECoreAppleseed: test improvements
2 parents aba2328 + d1b675b commit ceedfd8

File tree

10 files changed

+231
-11
lines changed

10 files changed

+231
-11
lines changed

contrib/IECoreAppleseed/src/IECoreAppleseed/RendererImplementation.cpp

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -135,13 +135,25 @@ void IECoreAppleseed::RendererImplementation::constructCommon()
135135

136136
// Insert some config params needed by the interactive renderer.
137137
asr::Configuration *cfg = m_project->configurations().get_by_name( "interactive" );
138-
asr::ParamArray &params = cfg->get_parameters();
139-
params.insert( "sample_renderer", "generic" );
140-
params.insert( "sample_generator", "generic" );
141-
params.insert( "tile_renderer", "generic" );
142-
params.insert( "frame_renderer", "progressive" );
143-
params.insert( "lighting_engine", "pt" );
144-
params.insert_path( "progressive_frame_renderer.max_fps", "5" );
138+
asr::ParamArray *params = &cfg->get_parameters();
139+
params->insert( "sample_renderer", "generic" );
140+
params->insert( "sample_generator", "generic" );
141+
params->insert( "tile_renderer", "generic" );
142+
params->insert( "frame_renderer", "progressive" );
143+
params->insert( "lighting_engine", "pt" );
144+
params->insert_path( "progressive_frame_renderer.max_fps", "5" );
145+
146+
// Insert some config params needed by the final renderer.
147+
cfg = m_project->configurations().get_by_name( "final" );
148+
params = &cfg->get_parameters();
149+
params->insert( "sample_renderer", "generic" );
150+
params->insert( "sample_generator", "generic" );
151+
params->insert( "tile_renderer", "generic" );
152+
params->insert( "frame_renderer", "generic" );
153+
params->insert( "lighting_engine", "pt" );
154+
params->insert( "pixel_renderer", "uniform" );
155+
params->insert( "sampling_mode", "rng" );
156+
params->insert_path( "uniform_pixel_renderer.samples", "1" );
145157

146158
// create some basic project entities.
147159
asf::auto_release_ptr<asr::Frame> frame( asr::FrameFactory::create( "beauty", asr::ParamArray().insert( "resolution", "640 480" ) ) );

contrib/IECoreAppleseed/src/IECoreAppleseed/outputDriver/DisplayTileCallback.cpp

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,14 @@ class DisplayTileCallback : public asr::TileCallbackBase
140140

141141
private:
142142

143+
void copy_optional_param( const char *key, CompoundDataMap &dst ) const
144+
{
145+
if( m_params.strings().exist( key ) )
146+
{
147+
dst[key] = new StringData( m_params.get( key ) );
148+
}
149+
}
150+
143151
void init_display( const asr::Frame *frame )
144152
{
145153
assert( !m_display_initialized );
@@ -169,12 +177,14 @@ class DisplayTileCallback : public asr::TileCallbackBase
169177

170178
CompoundDataPtr parameters = new CompoundData();
171179
CompoundDataMap &p = parameters->writable();
172-
p["displayHost"] = new StringData( m_params.get( "displayHost" ) );
173-
p["displayPort"] = new StringData( m_params.get( "displayPort" ) );
174-
p["driverType"] = new StringData( m_params.get( "driverType" ) );
175-
p["remoteDisplayType"] = new StringData( m_params.get( "remoteDisplayType" ) );
176180
p["type"] = new StringData( m_params.get( "type" ) );
177181

182+
copy_optional_param( "displayHost", p );
183+
copy_optional_param( "displayPort", p );
184+
copy_optional_param( "driverType", p );
185+
copy_optional_param( "remoteDisplayType", p );
186+
copy_optional_param( "handle", p );
187+
178188
// reserve space for one tile
179189
const asf::CanvasProperties &frameProps = frame->image().properties();
180190
m_tile_width = frameProps.m_tile_width;

contrib/IECoreAppleseed/test/IECoreAppleseed/All.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,10 @@
3737

3838
import IECore
3939

40+
from AttributeTest import AttributeTest
4041
from CameraTest import CameraTest
4142
from LightTest import LightTest
43+
from MeshTest import MeshTest
4244
from MotionTest import MotionTest
4345
from PrimitiveConverterTest import PrimitiveConverterTest
4446
from RendererTest import RendererTest

contrib/IECoreAppleseed/test/IECoreAppleseed/AppleseedTest.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,10 @@ def _countAssemblyInstances( self, r ) :
7373

7474
ass = self._getMainAssembly( r )
7575
return len( ass.assembly_instances() )
76+
77+
def _writeProject( self, r, filename ) :
78+
79+
proj = r.appleseedProject()
80+
opts = appleseed.ProjectFileWriterOptions.OmitBringingAssets | appleseed.ProjectFileWriterOptions.OmitWritingGeometryFiles
81+
w = appleseed.ProjectFileWriter()
82+
w.write( proj, filename, opts )
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
##########################################################################
2+
#
3+
# Copyright (c) 2015, Esteban Tovagliari. All rights reserved.
4+
#
5+
# Redistribution and use in source and binary forms, with or without
6+
# modification, are permitted provided that the following conditions are
7+
# met:
8+
#
9+
# * Redistributions of source code must retain the above copyright
10+
# notice, this list of conditions and the following disclaimer.
11+
#
12+
# * Redistributions in binary form must reproduce the above copyright
13+
# notice, this list of conditions and the following disclaimer in the
14+
# documentation and/or other materials provided with the distribution.
15+
#
16+
# * Neither the name of Image Engine Design nor the names of any
17+
# other contributors to this software may be used to endorse or
18+
# promote products derived from this software without specific prior
19+
# written permission.
20+
#
21+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
22+
# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
23+
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24+
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
25+
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
26+
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27+
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
28+
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
29+
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
30+
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31+
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32+
#
33+
##########################################################################
34+
35+
import os
36+
import unittest
37+
38+
import appleseed
39+
40+
import IECore
41+
import IECoreAppleseed
42+
43+
import AppleseedTest
44+
45+
class AttributeTest( AppleseedTest.TestCase ):
46+
47+
def testVisbility( self ) :
48+
49+
r = IECoreAppleseed.Renderer()
50+
r.worldBegin()
51+
52+
m = IECore.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( -1 ), IECore.V2f( 1 ) ) )
53+
54+
r.attributeBegin()
55+
r.setAttribute( "name", IECore.StringData( "plane" ) )
56+
r.setAttribute( "as:visibility:camera", IECore.BoolData( False ) )
57+
r.setAttribute( "as:visibility:diffuse", IECore.BoolData( False ) )
58+
m.render( r )
59+
r.attributeEnd()
60+
61+
ass = self._getMainAssembly( r )
62+
obj_instance = ass.assembly_instances()['plane_assembly_instance']
63+
params = obj_instance.get_parameters()
64+
65+
self.failUnless( params['visibility']['camera'] == False )
66+
self.failUnless( params['visibility']['diffuse'] == False )
67+
68+
def testShadingSamples( self ) :
69+
70+
r = IECoreAppleseed.Renderer()
71+
r.worldBegin()
72+
73+
self._createDefaultShader( r )
74+
75+
m = IECore.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( -1 ), IECore.V2f( 1 ) ) )
76+
77+
r.attributeBegin()
78+
r.setAttribute( "name", IECore.StringData( "plane1" ) )
79+
r.setAttribute( "as:shading_samples", IECore.IntData( 4 ) )
80+
m.render( r )
81+
r.attributeEnd()
82+
83+
r.attributeBegin()
84+
r.setAttribute( "name", IECore.StringData( "plane2" ) )
85+
r.setAttribute( "as:shading_samples", IECore.IntData( 2 ) )
86+
m.render( r )
87+
r.attributeEnd()
88+
89+
ass = self._getMainAssembly( r )
90+
sshader = ass.surface_shaders()[0]
91+
self.failUnless( sshader.get_parameters()['front_lighting_samples'] == 4 )
92+
self.failUnless( sshader.get_parameters()['back_lighting_samples'] == 4 )
93+
94+
sshader = ass.surface_shaders()[1]
95+
self.failUnless( sshader.get_parameters()['front_lighting_samples'] == 2 )
96+
self.failUnless( sshader.get_parameters()['back_lighting_samples'] == 2 )
97+
98+
def testAlphaMaps( self ) :
99+
100+
r = IECoreAppleseed.Renderer()
101+
102+
r.display( "test", "ieDisplay", "rgba", { "driverType" : "ImageDisplayDriver", "handle" : "testHandle" } )
103+
104+
r.setOption( "as:cfg:shading_engine:override_shading:mode", IECore.StringData( "object_instances" ) )
105+
106+
with IECore.WorldBlock( r ) :
107+
108+
r.attributeBegin()
109+
r.setAttribute( "name", IECore.StringData( "plane" ) )
110+
r.setAttribute( "as:alpha_map", IECore.StringData( os.path.dirname( __file__ ) + "/data/textures/leaf.exr" ) )
111+
r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 0, 0, -5 ) ) )
112+
IECore.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( -6 ), IECore.V2f( 6 ) ) ).render( r )
113+
r.attributeEnd()
114+
115+
del r
116+
117+
image = IECore.ImageDisplayDriver.removeStoredImage( "testHandle" )
118+
expectedImage = IECore.EXRImageReader( os.path.dirname( __file__ ) + "/data/referenceImages/expectedAlphaMaps.exr" ).read()
119+
120+
self.failIf( IECore.ImageDiffOp()( imageA=image, imageB=expectedImage, maxError=0.003 ).value )
121+
122+
if __name__ == "__main__":
123+
unittest.main()
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
##########################################################################
2+
#
3+
# Copyright (c) 2015, Esteban Tovagliari. All rights reserved.
4+
#
5+
# Redistribution and use in source and binary forms, with or without
6+
# modification, are permitted provided that the following conditions are
7+
# met:
8+
#
9+
# * Redistributions of source code must retain the above copyright
10+
# notice, this list of conditions and the following disclaimer.
11+
#
12+
# * Redistributions in binary form must reproduce the above copyright
13+
# notice, this list of conditions and the following disclaimer in the
14+
# documentation and/or other materials provided with the distribution.
15+
#
16+
# * Neither the name of Image Engine Design nor the names of any
17+
# other contributors to this software may be used to endorse or
18+
# promote products derived from this software without specific prior
19+
# written permission.
20+
#
21+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
22+
# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
23+
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24+
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
25+
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
26+
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27+
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
28+
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
29+
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
30+
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31+
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32+
#
33+
##########################################################################
34+
35+
import os
36+
import unittest
37+
38+
import IECore
39+
import IECoreAppleseed
40+
41+
import AppleseedTest
42+
43+
class MeshTest( AppleseedTest.TestCase ):
44+
45+
def testUVs( self ) :
46+
47+
r = IECoreAppleseed.Renderer()
48+
r.display( "test", "ieDisplay", "rgba", { "driverType" : "ImageDisplayDriver", "handle" : "testHandle" } )
49+
50+
r.setOption( "as:cfg:shading_engine:override_shading:mode", IECore.StringData( "uv" ) )
51+
52+
with IECore.WorldBlock( r ) :
53+
54+
r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 0, 0, -5 ) ) )
55+
IECore.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( -6 ), IECore.V2f( 6 ) ) ).render( r )
56+
57+
del r
58+
59+
image = IECore.ImageDisplayDriver.removeStoredImage( "testHandle" )
60+
expectedImage = IECore.EXRImageReader( os.path.dirname( __file__ ) + "/data/referenceImages/expectedMeshUVs.exr" ).read()
61+
62+
self.failIf( IECore.ImageDiffOp()( imageA=image, imageB=expectedImage, maxError=0.003 ).value )
63+
64+
if __name__ == "__main__":
65+
unittest.main()

contrib/IECoreAppleseed/test/IECoreAppleseed/RendererTest.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ def testTypeName( self ) :
5656
self.assertEqual( r.typeName(), "IECoreAppleseed::Renderer" )
5757

5858
def testAppleseedOutput( self ) :
59+
5960
r = IECoreAppleseed.Renderer( self.__appleseedFileName )
6061
self.failIf( os.path.exists( self.__appleseedFileName ) )
6162

412 KB
Binary file not shown.
251 KB
Binary file not shown.
107 KB
Binary file not shown.

0 commit comments

Comments
 (0)