Alembic workflow

Forums: Alembic workflow
Forum for OctaneRender Lua scripting examples, discussion and support.

Alembic workflow

Postby palhano » Thu Apr 10, 2014 3:27 pm

palhano Thu Apr 10, 2014 3:27 pm
Need to export abc files from max2014 to Octane 1.52 standalone. Tried 2 ways first sending scene to Maya 2014 and exporting abc file to Octane, second using Exocortex plugin from 3dsmax 2014.

When importing abc files from Maya 2014 the camera pins are correct but geometry show up with only one material pin for the entire scene.

When importing abc files generated from exocortex plugin for 3dsmax the camera pins are correct but there are multiple material pins for each mesch , for instance 6 pins for a single box an 1 for a sphere, assigning a material named red to the box on 3dsmax produces pins red_1, red_2...red_6 in Octane.

Now, importing the same scene as Obj file from 3dsMax 2014 produces a single pin named red for the box with the correct diffuse material type and also a single pin named blue for the sphere with the correct specular material type associated.

Anybody as an idea how to copy the parameters from every pin of an obj node and assign them to the corresponding pins of abc scenegraph? In the exemple above it would be red material from obj file to red01,red02,red03...red06 of the abc file and so on?
palhano
Licensed Customer
Licensed Customer
 
Posts: 21
Joined: Sat Apr 10, 2010 7:24 pm

Re: Alembic workflow

Postby stratified » Fri Apr 11, 2014 8:35 pm

stratified Fri Apr 11, 2014 8:35 pm
Hi there,

It seems that both Alembic exporters are stuffed. What you could do is "hack" the alembic graph a bit in the node editor via a Lua script. You could wrap this into an extra graph and group all materials with the same name (e.g. red_0, red_1, ...).

If you provide me with a simple abc file from the Exocortex plugin (e.g. the cube) I could show you how to do this in Lua.

cheers,
Thomas
User avatar
stratified
OctaneRender Team
OctaneRender Team
 
Posts: 945
Joined: Wed Aug 15, 2012 6:32 am
Location: Auckland, New Zealand

Re: Alembic workflow

Postby kavorka » Fri Apr 11, 2014 9:46 pm

kavorka Fri Apr 11, 2014 9:46 pm
I get the same thing from Blender.

A lua script to fix the alembic file would be awesome
Intel quad core i5 @ 4.0 ghz | 8 gigs of Ram | Geforce GTX 470 - 1.25 gigs of Ram
kavorka
Licensed Customer
Licensed Customer
 
Posts: 1351
Joined: Sat Feb 04, 2012 6:40 am

Re: Alembic workflow

Postby palhano » Sat Apr 12, 2014 12:13 am

palhano Sat Apr 12, 2014 12:13 am
Thank you Thomas for your help.

Here is the scene.
From 3dsmax I exported both obj and alembic files.
On Octane notice that I've duplicated the render target just to show that the camera and objects transformation coming from the alembic file are OK and that the materials coming from the obj node are correct. Once the obj materials are mapped to the multiple material pins duplicated by the exporter on the abc file the entire scene would be have the right materials and even uvs applied because Exocortex plugin sends uvs too. At the end we would get rid of the obj node before rendering the final scene.

Cheers,

Sergio
Attachments
cube.rar
(47.75 KiB) Downloaded 773 times
palhano
Licensed Customer
Licensed Customer
 
Posts: 21
Joined: Sat Apr 10, 2010 7:24 pm

Re: Alembic workflow

Postby stratified » Sat Apr 12, 2014 5:57 am

stratified Sat Apr 12, 2014 5:57 am
Hey guys,

Here's a script I hacked together. It tries to group the materials of an abc archive that match the material names of a "guidance" obj mesh (e.g. RED_1, RED_2 & RED_3 would match RED and are grouped together "RED"). If the "guidance" obj mesh is bogus then you would get an abc mesh that's the same as the original.

All you have to do is select the mesh and alembic scene and run the script (currently it's bound to ctrl + m). The net result should look like this:

merge-script.png
merge materials


Here's the script for the copy/pasters:

Code: Select all
-- Merges identical materials from an alembic graph based on the material pins
-- that are encountered in the correspoding obj file.
--
-- @author   Thomas Loockx
-- @shortcut ctrl+m


-- figure out the abc archive and the obj file from the selection
local selected = octane.project.getSelection()
if #selected ~= 2 then
    error("expected a Scene and Mesh in the selection")
end
local objMesh, abcScene = nil, nil
if selected[1].type == octane.NT_GEO_MESH and selected[2].type == octane.GT_GEOMETRYARCHIVE then
    objMesh, abcScene = selected[1], selected[2]
elseif selected[2].type == octane.NT_GEO_MESH and selected[1].type == octane.GT_GEOMETRYARCHIVE then
    objMesh, abcScene = selected[2], selected[1]
else
    error("expected a Scene and Mesh in the selection")
end

-- create a new nodegraph in which we encapsulate the "complex" abc-scene
local newGraph = octane.nodegraph.create
{
    type = octane.GT_STANDARD,
    name = string.format("%s (Merged Materials)", abcScene.name)
}
-- copy the original abc-scene into the new graph
local abcSceneCopy = newGraph:copyFrom({ abcScene }, { abcScene})[1]

-- create new output linker nodes and connect them to the nested abc-scene
for _, outLinker in pairs(abcSceneCopy:getOutputNodes()) do
    local newOutLinker = octane.node.create
    {
        type       = outLinker.type,
        name       = outLinker.name,
        graphOwner = newGraph,
    }
    newOutLinker:connectTo(octane.P_INPUT, outLinker)
end

-- collect the name of each material pin on the obj-mesh in a lookup-table
local materials = {}
for ix=1,objMesh:getPinCount() do
    if objMesh:getPinInfoIx(ix).type == octane.PT_MATERIAL then
        materials[objMesh:getPinInfoIx(ix).name] =
        {
            -- material connected to the obj material pin
            ["objMaterial"] = objMesh:getInputNodeIx(ix),
            -- linker node "grouping" those abc inputs later on
            ["inputLinker"] = nil
        }
    end
end


-- connect each input linker (pin) of the abc archive with a fresh linker
--  -> if the input linker is a material, see if we can "group" this one
--     by trying to connect to an already existing input linker node
--  -> if the input linker is a non-material, just create another input linker
--     and make the connection
for _, abcInLinker in ipairs(abcSceneCopy:getInputNodes()) do
    if abcInLinker.type == octane.NT_IN_MATERIAL then
        -- see if the name matches one of the material names of the obj-mesh
        local matched = false
        for materialName, data in pairs(materials) do
            if string.find(abcInLinker.name, materialName) then
                -- if there's no such input linker yet -> create it
                if not data.inputLinker then
                    data.inputLinker = octane.node.create
                    {
                        type       = octane.NT_IN_MATERIAL,
                        name       = materialName,
                        graphOwner = newGraph,
                    }
                    -- copy the original obj material in the pin of the new linker
                    octane.node.copyFrom(data.inputLinker, octane.P_INPUT, data.objMaterial)
                end
                -- connect the abc input to this material linker
                abcInLinker:connectTo(octane.P_INPUT, data.inputLinker)
                -- we had a match so we don't need to create a node anymore
                matched = true
                break
            end
        end
        -- if we didn't have a match -> add a fresh linker node
        if not matched then
            matInLinker = octane.node.create
            {
                type       = octane.NT_IN_MATERIAL,
                name       = abcInLinker.name,
                graphOwner = newGraph,
            }
            abcInLinker:connectTo(octane.P_INPUT, matInLinker)
        end
    else
        -- for a non-material linker, just connect it through
        local nonMatInLinker = octane.node.create
        {
            type       = abcInLinker.type,
            name       = abcInLinker.name,
            graphOwner = newGraph,
        }
        abcInLinker:connectTo(octane.P_INPUT, nonMatInLinker)
    end
end


And here it is for the downloaders:

merge-abc-materials.lua
(4.11 KiB) Downloaded 1029 times


cheers,
Thomas
User avatar
stratified
OctaneRender Team
OctaneRender Team
 
Posts: 945
Joined: Wed Aug 15, 2012 6:32 am
Location: Auckland, New Zealand

Re: Alembic workflow

Postby kavorka » Sun Apr 13, 2014 1:31 am

kavorka Sun Apr 13, 2014 1:31 am
Tested it out and it works. Should help a lot.
Is this an error in the alembic exporters or the importer?

One thing I noticed, it switches the position of the camera out and mesh out. Not actually important though.
Intel quad core i5 @ 4.0 ghz | 8 gigs of Ram | Geforce GTX 470 - 1.25 gigs of Ram
kavorka
Licensed Customer
Licensed Customer
 
Posts: 1351
Joined: Sat Feb 04, 2012 6:40 am

Re: Alembic workflow

Postby stratified » Sun Apr 13, 2014 2:55 am

stratified Sun Apr 13, 2014 2:55 am
kavorka wrote:Tested it out and it works. Should help a lot.
Is this an error in the alembic exporters or the importer?

One thing I noticed, it switches the position of the camera out and mesh out. Not actually important though.


I think it's the exporter of the host app but we'll check it. If not we'll fix this because it shouldn't be like that in the first place.

cheers,
thomas
User avatar
stratified
OctaneRender Team
OctaneRender Team
 
Posts: 945
Joined: Wed Aug 15, 2012 6:32 am
Location: Auckland, New Zealand

Re: Alembic workflow

Postby kavorka » Sun Apr 13, 2014 3:07 am

kavorka Sun Apr 13, 2014 3:07 am
Thanks!
I can't speak for other people, but I am using the OR4B plugin and exporting. I noticed I get less material pins when I export my animation with moveable geometry over ride.
Intel quad core i5 @ 4.0 ghz | 8 gigs of Ram | Geforce GTX 470 - 1.25 gigs of Ram
kavorka
Licensed Customer
Licensed Customer
 
Posts: 1351
Joined: Sat Feb 04, 2012 6:40 am

Re: Alembic workflow

Postby JimStar » Mon Apr 14, 2014 1:16 am

JimStar Mon Apr 14, 2014 1:16 am
kavorka wrote:I get the same thing from Blender.

What exactly thing you have in Blender, can you please explain in detail with screenshots? As so far - I can't see here some issues, all works OK for me if I carefully set up the animated scene in Blender...

kavorka wrote:I can't speak for other people, but I am using the OR4B plugin and exporting. I noticed I get less material pins when I export my animation with moveable geometry over ride.

I will try to explain, as perhaps there is some misunderstanding...;)
Blender plugin (and Maya plugin too) have complicated animation geometry settings which purpose is to be able to "maximally minimize" the geometry export time in animations. I've already explained it somewhere in Blender threads - if you animate in "Full" animation mode - for every "Global" scene geometry you get the new different geometry object in every frame, with all its pins. So finally you get overall amount of pins of all geometry in all frames for "Full" mode. Materials are "collapsed" by their names, so even in this case, if you have carefully set all node-materials to the geometry, you will get some like this for 10 frames animation:
1.png

3.png

4.png

As all this big amount of pins will be connected to the the same materials in different frames.

But if you have some material not properly set as named node-material - Octane will give it the automatic name which contains the mesh name in it to be unique. The doubled in every frame global meshes have different names, so these materials will get different names too. So finally - you will get different materials for different frames.
7.png

6.png


Anyway - using the "Full" animation mode together wit "Global" meshes - is bad idea from the point of view of performance. "Global" meshes are very good for some static complicated images renderings, as interiors - as in this case the geometry export time does not matter in comparison to the render time, but the render time will be faster in the case of entire scene as "Global" mesh...
But for animation - you can dramatically improve the geometry export time for the entire animation if you will carefully tune all the scene geometry. So, in this case, some rules:
- Set the animation mode to "Movable proxy"
- Set all the geometry objects which are static between frames as "Scatter". In this case this geometry will be exported and evaluated only once, in the first frame of animation.
- Set all the geometry objects which move between frames (but not deform) to "Movable proxy" type. In this case this geometry will be exported and evaluated only once, in the first frame, but the transform will be reloaded every frame. This is fast operation.
- Set all the geometry objects which deform between frames to "Reshapable proxy" type. In this case only this geometry will be reloaded and reevaluated every frame.
- Check that all the geometry have properly set material nodes which are properly named.
Something like this...;)
User avatar
JimStar
OctaneRender Team
OctaneRender Team
 
Posts: 3780
Joined: Thu Jul 28, 2011 8:19 pm
Location: Auckland, New Zealand

Re: Alembic workflow

Postby PolderAnimation » Mon Sep 05, 2016 12:41 pm

PolderAnimation Mon Sep 05, 2016 12:41 pm
stratified wrote:
kavorka wrote:Tested it out and it works. Should help a lot.
Is this an error in the alembic exporters or the importer?

One thing I noticed, it switches the position of the camera out and mesh out. Not actually important though.


I think it's the exporter of the host app but we'll check it. If not we'll fix this because it shouldn't be like that in the first place.

cheers,
thomas


Since the introduction of alembic in Octane I have this issue. I cant get my material pin working in octane with an alembic cache, and everything I can find about this doesn't address this issue. At the moment Alembic is useless without having the ability to get shader pins from our third party program (maya). Is there any news, when this is going to be fixed?
Because this would be such a handy feature.
Win 10 64bit | RTX 3090 | i9 7960X | 64GB
User avatar
PolderAnimation
Licensed Customer
Licensed Customer
 
Posts: 371
Joined: Mon Oct 10, 2011 10:23 am
Location: Netherlands

Return to Lua Scripting


Who is online

Users browsing this forum: No registered users and 3 guests

Fri Mar 29, 2024 2:14 pm [ UTC ]