diff --git a/procedural/main.cpp b/procedural/main.cpp index 469c77d7c3..76aef7dc40 100644 --- a/procedural/main.cpp +++ b/procedural/main.cpp @@ -97,6 +97,7 @@ procedural_init data->SetFrame(AiNodeGetFlt(node, "frame")); data->SetDebug(AiNodeGetBool(node, "debug")); data->SetThreadCount(AiNodeGetInt(node, "threads")); + data->SetId(AiNodeGetUInt(node, "id")); AtNode *renderCam = AiUniverseGetCamera(); if (renderCam && diff --git a/testsuite/test_0176/README b/testsuite/test_0176/README new file mode 100755 index 0000000000..18456d2749 --- /dev/null +++ b/testsuite/test_0176/README @@ -0,0 +1,5 @@ +Testing setting the id parameter on the procedural. + +See usd#730 + +author: Pal Mezei diff --git a/testsuite/test_0176/data/builtin_shapes.usda b/testsuite/test_0176/data/builtin_shapes.usda new file mode 100755 index 0000000000..df77b83217 --- /dev/null +++ b/testsuite/test_0176/data/builtin_shapes.usda @@ -0,0 +1,46 @@ +#usda 1.0 +( + defaultPrim = "cube" +) + +def Cube "cube" +{ + double size=2 + float3 xformOp:translate= (4.8,0, 0) + uniform token[] xformOpOrder = ["xformOp:translate"] +} + +def Sphere "sphere" +{ + double radius=1.8 + float3 xformOp:translate= (-4.8,0, 0) + uniform token[] xformOpOrder = ["xformOp:translate"] +} + +def Cylinder "cylinder" +{ + double radius=1.1 + double height=3 + token axis="Y" + float3 xformOp:translate= (0,0, 0) + uniform token[] xformOpOrder = ["xformOp:translate"] +} + +def Cone "cone" +{ + double radius=1.6 + double height=2.7 + token axis="X" + float3 xformOp:translate= (0,5, 0) + uniform token[] xformOpOrder = ["xformOp:translate"] +} + +def Capsule "capsule" +{ + double radius=1.6 + double height=2.7 + token axis="X" + float3 xformOp:translate= (4,5, 0) + uniform token[] xformOpOrder = ["xformOp:translate"] +} + diff --git a/testsuite/test_0176/data/test.ass b/testsuite/test_0176/data/test.ass new file mode 100755 index 0000000000..2ebdd1fefb --- /dev/null +++ b/testsuite/test_0176/data/test.ass @@ -0,0 +1,162 @@ +### exported: Tue Dec 18 15:45:58 2018 +### from: Arnold 5.2.2.0 [30b8ba14] windows icc-17.0.2 oiio-2.0.1 osl-1.10.1 vdb-4.0.0 clm-1.0.3.513 rlm-12.4.2 2018/12/04 22:02:04 +### host app: MtoA 3.1.3.wip 7d48f6c4 (develop) Maya 2018 +### bounds: -1 -1 -1 1 1 1 +### user: blaines +### render_layer: defaultRenderLayer +### scene: D:/arnold/scenes/usd_builtin.ma + + + +options +{ + AA_samples 3 + AA_samples_max 8 + outputs "RGBA RGBA myfilter mydriver" + xres 960 + yres 540 + texture_per_file_stats on + texture_automip off + camera "perspShape" + frame 1 + GI_diffuse_depth 1 + GI_specular_depth 1 + GI_transmission_depth 8 + declare render_layer constant STRING + render_layer "defaultRenderLayer" +} + +gaussian_filter +{ + name myfilter +} + +driver_tiff +{ + name mydriver + filename "testrender.tif" + color_space "sRGB" +} + +persp_camera +{ + name perspShape + matrix + 0.99999392 -1.08420217e-19 0.00349065149 0 + 0.000781565788 0.974611521 -0.223901182 0 + -0.00340202916 0.223902553 0.97460562 0 + -0.949623287 7.26941013 21.0998859 1 + near_clip 0.100000001 + far_clip 10000 + screen_window_min -1 -1 + screen_window_max 1 1 + shutter_start 0 + shutter_end 0 + shutter_type "box" + rolling_shutter "off" + rolling_shutter_duration 0 + motion_start 0 + motion_end 0 + exposure 0 + fov 54.4322243 + uv_remap 0 0 0 1 + declare maya_full_name constant STRING + maya_full_name "|persp|perspShape" +} + +usd +{ + name aiUsdShape1 + visibility 255 + matrix + 1 0 0 0 + 0 1 0 0 + 0 0 1 0 + 0 0 0 1 + use_light_group off + override_nodes off + filename "builtin_shapes.usda" + object_path "/cube" + frame 1 + shader "myshader" + id 1 +} + +usd +{ + name aiUsdShape2 + visibility 255 + matrix + 1 0 0 0 + 0 1 0 0 + 0 0 1 0 + 0 0 0 1 + use_light_group off + override_nodes off + filename "builtin_shapes.usda" + object_path "/sphere" + frame 1 + shader "myshader" + id 2 +} + +usd +{ + name aiUsdShape3 + visibility 255 + matrix + 1 0 0 0 + 0 1 0 0 + 0 0 1 0 + 0 0 0 1 + use_light_group off + override_nodes off + filename "builtin_shapes.usda" + object_path "/cylinder" + frame 1 + shader "myshader" + id 3 +} + +usd +{ + name aiUsdShape4 + visibility 255 + matrix + 1 0 0 0 + 0 1 0 0 + 0 0 1 0 + 0 0 0 1 + use_light_group off + override_nodes off + filename "builtin_shapes.usda" + object_path "/cone" + frame 1 + shader "myshader" + id 4 +} + +usd +{ + name aiUsdShape5 + visibility 255 + matrix + 1 0 0 0 + 0 1 0 0 + 0 0 1 0 + 0 0 0 1 + use_light_group off + override_nodes off + filename "builtin_shapes.usda" + object_path "/capsule" + frame 1 + shader "myshader" + id 5 +} + +utility +{ + name myshader + color_mode "id" + shade_mode "flat" +} \ No newline at end of file diff --git a/testsuite/test_0176/ref/reference.log b/testsuite/test_0176/ref/reference.log new file mode 100644 index 0000000000..afb2941273 --- /dev/null +++ b/testsuite/test_0176/ref/reference.log @@ -0,0 +1,179 @@ +00:00:00 82MB | log started Wed Mar 31 22:10:55 2021 +00:00:00 82MB | Arnold 6.2.1.0 [3506c069] linux clang-10.0.1 oiio-2.3.2 osl-1.12.0 vdb-7.1.1 clm-2.0.0.235 rlm-14.1.3 optix-6.6.0 2021/03/31 06:56:58 +00:00:00 82MB | running on localhost.localdomain, pid=51637 +00:00:00 82MB | 2 x Intel(R) Xeon(R) Gold 5218 CPU @ 2.30GHz (32 cores, 64 logical) with 63820MB +00:00:00 82MB | NVIDIA driver version 455.38 (Optix 60700) +00:00:00 82MB | GPU 0: GeForce RTX 2080 Ti @ 1575MHz (compute 7.5) with 11017MB (9867MB available) (NVLink:0) +00:00:00 82MB | CentOS Linux 7 (Core), Linux kernel 3.10.0-1160.21.1.el7.x86_64 +00:00:00 82MB | soft limit for open files is set at 4094 +00:00:00 82MB | +00:00:00 82MB | loading plugins from /home/pal.mezei/projects/arnold-usd/build/linux_x86_64/gcc_opt/usd-0.20.11_arnold-6.2.1.0/procedural ... +00:00:00 82MB | usd_proc.so: usd uses Arnold 6.2.1.0 +00:00:00 82MB | loaded 1 plugins from 1 lib(s) in 0:00.00 +00:00:00 82MB | loading plugins from /home/pal.mezei/dist/arnold/bin/../plugins ... +00:00:00 82MB | alembic_proc.so: alembic uses Arnold 6.2.1.0 +00:00:00 82MB | skipping already loaded plugin: /home/pal.mezei/dist/arnold/bin/../plugins/usd_proc.so ... +00:00:00 82MB | cryptomatte.so: cryptomatte uses Arnold 6.2.1.0 +00:00:00 82MB | cryptomatte.so: cryptomatte_filter uses Arnold 6.2.1.0 +00:00:00 82MB | cryptomatte.so: cryptomatte_manifest_driver uses Arnold 6.2.1.0 +00:00:00 82MB | loaded 4 plugins from 2 lib(s) in 0:00.00 +00:00:00 82MB | [kick] command: /home/pal.mezei/dist/arnold/bin/kick test.ass -dw -r 160 120 -sm lambert -bs 16 -o testrender.tif -set driver_tiff.dither false -dp -v 6 +00:00:00 82MB | loading plugins from . ... +00:00:00 82MB | no plugins loaded +00:00:00 83MB | [metadata] loading metadata file: test.ass +00:00:00 84MB | [ass] loading test.ass ... +00:00:00 84MB | [ass] read 2494 bytes, 10 nodes in 0:00.00 +00:00:00 84MB | [kick] applying 2 attr value overrides +00:00:00 84MB | +00:00:00 84MB | authorizing with license manager: rlm ... +00:00:01 84MB | [rlm] authorized for "arnold 20231231" from server license.arnold.autodesk.com in 0:01.80 +00:00:01 84MB | [rlm] expiration date: 31-dec-2023 (1006 days left) +00:00:01 84MB | +00:00:01 85MB | [color_manager] no color manager is active +00:00:01 85MB | [color_manager] rendering color space is "linear" with declared chromaticities: +00:00:01 85MB | r(0.6400, 0.3300) g(0.3000, 0.6000) b(0.1500, 0.0600) and w(0.3127, 0.3290) +00:00:01 98MB | +00:00:01 98MB | there are 0 lights and 6 objects: +00:00:01 98MB | 1 persp_camera +00:00:01 98MB | 2 utility +00:00:01 98MB | 1 driver_tiff +00:00:01 98MB | 1 gaussian_filter +00:00:01 98MB | 1 list_aggregate +00:00:01 98MB | 5 usd +00:00:01 98MB | +00:00:01 98MB | rendering image at 160 x 120, 3 AA samples +00:00:01 98MB | AA samples max +00:00:01 98MB | AA sample clamp +00:00:01 98MB | diffuse samples 2 / depth 1 +00:00:01 98MB | specular samples 2 / depth 1 +00:00:01 98MB | transmission samples 2 / depth 8 +00:00:01 98MB | volume indirect +00:00:01 98MB | total depth 10 +00:00:01 98MB | bssrdf samples 2 +00:00:01 98MB | transparency depth 10 +00:00:01 98MB | initializing 12 nodes ... +00:00:01 165MB | [proc] aiUsdShape2: loaded 3 nodes (1 objects, 2 shaders) +00:00:02 161MB | [proc] aiUsdShape1: loaded 3 nodes (1 objects, 2 shaders) +00:00:02 161MB | [proc] aiUsdShape4: loaded 3 nodes (1 objects, 2 shaders) +00:00:02 161MB | [proc] aiUsdShape3: loaded 3 nodes (1 objects, 2 shaders) +00:00:02 161MB | [proc] aiUsdShape5: loaded 3 nodes (1 objects, 2 shaders) +00:00:02 161MB | creating root object list ... +00:00:02 161MB | node initialization done in 0:00.08 (multithreaded) +00:00:02 161MB | updating 28 nodes ... +00:00:02 161MB | scene bounds: (-6.60000038 -1.79999995 -1.79999995) -> (5.80000019 6.60000086 1.79999995) +00:00:02 161MB | node update done in 0:00.00 (multithreaded) +00:00:02 161MB | [aov] parsing 1 output statements ... +00:00:02 161MB | [aov] registered driver: "mydriver" (driver_tiff) +00:00:02 161MB | [aov] * "RGBA" of type RGBA filtered by "myfilter" (gaussian_filter) +00:00:02 161MB | [aov] done preparing 2 AOVs for 1 output to 1 driver (0 deep AOVs) +00:00:02 162MB | starting 64 bucket workers of size 16x16 ... +00:00:02 165MB | [accel] list_aggregate bvh4 done - 0:00.00 (wall time) - 5 prims, 1 key +00:00:02 165MB | 0% done - 205 rays/pixel +00:00:02 165MB | 5% done - 67 rays/pixel +00:00:02 165MB | 10% done - 21 rays/pixel +00:00:02 165MB | 15% done - 13 rays/pixel +00:00:02 165MB | 20% done - 6 rays/pixel +00:00:02 165MB | 25% done - 6 rays/pixel +00:00:02 165MB | 30% done - 17 rays/pixel +00:00:02 165MB | 35% done - 7 rays/pixel +00:00:02 165MB | 40% done - 12 rays/pixel +00:00:02 165MB | 45% done - 12 rays/pixel +00:00:02 165MB | 50% done - 12 rays/pixel +00:00:02 165MB | 55% done - 1 rays/pixel +00:00:02 165MB | 60% done - 0 rays/pixel +00:00:02 165MB | 65% done - 0 rays/pixel +00:00:02 165MB | 70% done - 0 rays/pixel +00:00:02 165MB | 75% done - 0 rays/pixel +00:00:02 165MB | 80% done - 0 rays/pixel +00:00:02 165MB | 85% done - 0 rays/pixel +00:00:02 165MB | 90% done - 0 rays/pixel +00:00:02 165MB | 95% done - 0 rays/pixel +00:00:02 165MB | 100% done - 0 rays/pixel +00:00:02 165MB | render done in 0:00.028 +00:00:02 165MB | [driver_tiff] writing file `testrender.tif' +00:00:02 166MB | render done +00:00:02 166MB | +00:00:02 166MB | ----------------------------------------------------------------------------------- +00:00:02 166MB | scene creation time 0:00.07 machine utilization (0.18%) +00:00:02 166MB | unaccounted 0:00.06 +00:00:02 166MB | ----------------------------------------------------------------------------------- +00:00:02 166MB | frame time 0:01.96 machine utilization (1.79%) +00:00:02 166MB | node init 0:00.08 +00:00:02 166MB | rendering 0:00.02 +00:00:02 166MB | pixel rendering 0:00.02 +00:00:02 166MB | unaccounted 0:01.84 +00:00:02 166MB | ----------------------------------------------------------------------------------- +00:00:02 166MB | top session self-times by category +00:00:02 166MB | InitializeNodes 0:00.07 (48.04%) +00:00:02 166MB | worker waiting 0:00.04 (27.32%) +00:00:02 166MB | thread blocked 0:00.00 ( 4.79%) +00:00:02 166MB | RenderBucket 0:00.00 ( 4.74%) +00:00:02 166MB | node_init 0:00.00 ( 4.20%) +00:00:02 166MB | aiUsdShape5 0:00.00 ( 0.85%) +00:00:02 166MB | aiUsdShape1 0:00.00 ( 0.85%) +00:00:02 166MB | aiUsdShape3 0:00.00 ( 0.85%) +00:00:02 166MB | aiUsdShape4 0:00.00 ( 0.85%) +00:00:02 166MB | aiUsdShape2 0:00.00 ( 0.81%) +00:00:02 166MB | sampleNextBatch 0:00.00 ( 3.46%) +00:00:02 166MB | accumulateBucketSamples 0:00.00 ( 2.78%) +00:00:02 166MB | ----------------------------------------------------------------------------------- +00:00:02 166MB | top session self-times by node +00:00:02 166MB | InitializeNodes 0:00.07 (48.04%) +00:00:02 166MB | worker waiting 0:00.04 (27.32%) +00:00:02 166MB | RenderBucket 0:00.00 ( 4.74%) +00:00:02 166MB | sampleNextBatch 0:00.00 ( 3.46%) +00:00:02 166MB | list_aggregate:root 0:00.00 ( 3.45%) +00:00:02 166MB | thread blocked 0:00.00 ( 3.13%) +00:00:02 166MB | accumulateBucketSamples 0:00.00 ( 2.78%) +00:00:02 166MB | ----------------------------------------------------------------------------------- +00:00:02 166MB | peak CPU memory used 166.06MB +00:00:02 166MB | at startup 82.40MB +00:00:02 166MB | plugins 0.17MB +00:00:02 166MB | AOV samples 3.02MB +00:00:02 166MB | output buffers 0.39MB +00:00:02 166MB | framebuffers 0.39MB +00:00:02 166MB | node overhead 0.02MB +00:00:02 166MB | message passing 0.13MB +00:00:02 166MB | memory pools 42.05MB +00:00:02 166MB | geometry 0.00MB +00:00:02 166MB | accel structs 0.01MB +00:00:02 166MB | strings 24.25MB +00:00:02 166MB | profiler 0.03MB +00:00:02 166MB | unaccounted 13.21MB +00:00:02 166MB | ----------------------------------------------------------------------------------- +00:00:02 166MB | ray counts ( /pixel, /sample) (% total) (avg. hits) (max hits) +00:00:02 166MB | camera 192800 ( 10.04, 1.00) (100.00%) ( 0.11) ( 1) +00:00:02 166MB | total 192800 ( 10.04, 1.00) (100.00%) ( 0.11) ( 1) +00:00:02 166MB | by ray depth: 0 +00:00:02 166MB | total 100.0% +00:00:02 166MB | ----------------------------------------------------------------------------------- +00:00:02 166MB | shader calls ( /pixel, /sample) (% total) +00:00:02 166MB | primary 20327 ( 1.06, 0.11) (100.00%) +00:00:02 166MB | total 20327 ( 1.06, 0.11) (100.00%) +00:00:02 166MB | by ray depth: 0 +00:00:02 166MB | total 100.0% +00:00:02 166MB | ----------------------------------------------------------------------------------- +00:00:02 166MB | geometry (% hit ) (instances) ( init mem, final mem) +00:00:02 166MB | lists 1 (100.0%) ( 0) ( 0.00, 0.00) +00:00:02 166MB | procs 5 (100.0%) ( 0) ( 0.00, 0.00) +00:00:02 166MB | simple 5 (100.0%) ( 0) ( 0.00, 0.00) +00:00:02 166MB | ----------------------------------------------------------------------------------- +00:00:02 166MB | geometric elements ( min) ( avg.) ( max) +00:00:02 166MB | objects (procs) 5 ( 1) ( 1.0) ( 1) +00:00:02 166MB | ----------------------------------------------------------------------------------- +00:00:02 166MB | acceleration structures: (% total) +00:00:02 166MB | list 5 ( 83.33%) +00:00:02 166MB | bvh 1 ( 16.67%) +00:00:02 166MB | total 6 (100.00%) +00:00:02 166MB | ----------------------------------------------------------------------------------- +00:00:02 166MB | performance warnings: +00:00:02 166MB WARNING | Rendering CPU utilization was only 2%. Your render may be bound by a single threaded process or I/O. +00:00:02 166MB | ----------------------------------------------------------------------------------- +00:00:02 166MB | +00:00:02 166MB | releasing resources +00:00:02 168MB | unloading 3 plugins +00:00:02 168MB | closing usd_proc.so ... +00:00:02 168MB | closing alembic_proc.so ... +00:00:02 168MB | closing cryptomatte.so ... +00:00:02 168MB | unloading plugins done +00:00:02 168MB | Arnold shutdown diff --git a/testsuite/test_0176/ref/reference.tif b/testsuite/test_0176/ref/reference.tif new file mode 100644 index 0000000000..e0a80a6c00 Binary files /dev/null and b/testsuite/test_0176/ref/reference.tif differ diff --git a/translator/reader/reader.cpp b/translator/reader/reader.cpp index 0e3c99aebb..7eb1136601 100644 --- a/translator/reader/reader.cpp +++ b/translator/reader/reader.cpp @@ -715,6 +715,10 @@ void UsdArnoldReaderThreadContext::SetDispatcher(WorkDispatcher *dispatcher) AtNode *UsdArnoldReaderThreadContext::CreateArnoldNode(const char *type, const char *name) { AtNode *node = AiNode(_reader->GetUniverse(), type, name, _reader->GetProceduralParent()); + // All shape nodes should have an id parameter. + if (AiNodeEntryGetType(AiNodeGetNodeEntry(node)) == AI_NODE_SHAPE) { + AiNodeSetUInt(node, str::id, _reader->GetId()); + } if (_createNodeLock) AiCritSecEnter(&_createNodeLock); diff --git a/translator/reader/reader.h b/translator/reader/reader.h index efd00c0ce0..09d97a0675 100644 --- a/translator/reader/reader.h +++ b/translator/reader/reader.h @@ -71,6 +71,7 @@ class UsdArnoldReader { void SetConvertPrimitives(bool b); void SetMask(int m) { _mask = m; } void SetPurpose(const std::string &p) { _purpose = TfToken(p.c_str()); } + void SetId(unsigned int id) { _id = id; } const UsdStageRefPtr &GetStage() const { return _stage; } const std::vector &GetNodes() const { return _nodes; } @@ -85,6 +86,7 @@ class UsdArnoldReader { const AtArray *GetOverrides() const { return _overrides; } unsigned int GetThreadCount() const { return _threadCount; } int GetMask() const { return _mask; } + unsigned int GetId() const { return _id;} const TfToken &GetPurpose() const {return _purpose;} static unsigned int ReaderThread(void *data); @@ -174,6 +176,8 @@ class UsdArnoldReader { ReadStep _readStep; TfToken _purpose; WorkDispatcher *_dispatcher; + + unsigned int _id = 0; ///< Arnold shape ID for the procedural. }; class UsdArnoldReaderThreadContext {