TheFoundryVisionmongers / KatanaUsdPlugins

Katana USD Plugins Repo
Other
48 stars 20 forks source link

usdPointInstancer scope problem #33

Open JobssSoong opened 6 months ago

JobssSoong commented 6 months ago

Hi, there's a problem i run into that USD pointInstancer imported via "usdIn" node always set arbitrary attributes' scope to "primitive", and i looked up the code, it's indeed hard-coded setting to "primitive". Is there considerations setting the scope always "primitive"? Arnold renderer(or say ktoa) apparently doesn't support "primitive" in scope, i have to manually set the scope to "point" so that Arnold can read and expand it to each instance

// line start from 686 in KatanaUsdPlugins/lib/usdKatana/readPointINstancer.cpp // // Transfer primvars. //

FnKat::GroupBuilder instancerPrimvarsBldr;
FnKat::GroupBuilder instancesPrimvarsBldr;
for (int64_t i = 0; i < primvarAttrs.getNumberOfChildren(); ++i)
{
    const std::string primvarName = primvarAttrs.getChildName(i);
    FnKat::GroupAttribute primvarAttr = primvarAttrs.getChildByIndex(i);

    if (FnKat::StringAttribute(primvarAttr.getChildByName("scope")
            ).getValue("", false) == "primitive")
    {
        // If this primvar is constant, leave it on the instancer.
        //
        instancerPrimvarsBldr.set(primvarName, primvarAttr);
    }
    else
    {
        // If this primvar is non-constant, move it down to the instances,
        // but make it constant so that it can be sliced and used by each
        // instance.
        //
        instancesPrimvarsBldr.set(primvarName, primvarAttr);
        instancesPrimvarsBldr.set(primvarName + ".scope",
                FnKat::StringAttribute("primitive"));
    }
}
instancerAttrMap.set("geometry.arbitrary", instancerPrimvarsBldr.build());
instancesBldr.setAttrAtLocation("instances",
        "geometry.arbitrary", instancesPrimvarsBldr.build());