Author Topic: Export specific stacks from a Layered Shader using 2dView preset is broken  (Read 255 times)


This code (Assuming I copy/pasted it over right) works fine on a non layered shader.

Code: [Select]
var stackPath = alg.texturesets.getActiveTextureSet()
alg.mapexport.exportDocumentMaps(presetName, exportPath, "png", {resolution:[1024,1024]}, stackPath)

If I run it on a layered shader using 2d View as a preset it fails to resolve stackPath (fails on texture set and stack name in various silly ways).

If I omit the stackPath the results are fine but I get an output image for every stack - in this case I end up exporting 16 images which takes ages and is therefore bad

This is the case on my custom shaders and on the supplied layered shader.

I need to use the 2d View preset as it is the only one available that supports direct output from the shader. I need to bake various outputs from the shader down to flat maps. 
I should add that this all works perfectly when the steps are exectuted manually via the export textures dialog but that's not a viable option due to the volume of assets that need processing.

Any suggestions?
thanks





Material Layering shaders will produce what we call "sub-stacks", therefor your stackpath needs to reflect it.
You need to specify both the Texture Set name and the sub-stack name that you want to export, otherwise the function won't be able to know what you wish to export. You can find the stack name via the alg.mapexport.documentStructure() function. Then your StackPath variable should be something like :
Code: [Select]
var StackPath = [TextureSetName, StackName]
Don't forget your log file. It can be exported from the Help menu of the software.
-----------
Fabrice Piquet aka Froyok. Product Manager, Technical Artist and Documentation at Adobe.

Thanks for responding but that doesn't appear to work unless I'm really misunderstanding the structure of the document
Sorry -  I should have expanded on the various silly ways I mentioned in the original post..

The dump from alg.mapexport.documentStructure()   looks a bit like this...
I've changed the textureset name for secrecy purposes and trimmed out the layer stuff because there's a lot of it


Code: [Select]
  "materials": [
    {
      "name": "TextureSet_Name",
      "selected": true,
      "stacks": [
        {
          "channels": [
            "roughness",
            "diffuse"
          ],
          "layers": [
            {
             **** removed stuff*******
            }
          ],
          "name": "Base",
          "selected": false
        }  
 

if I use this form for stackPath
["TextureSet_Name", "Base"]
it fails like this (note the extra  /  on the end of the texture set name)
[Script] qrc:/js/mapexport.js:226: ExportError: Invalid data path, the stack 'TextureSet_Name/' can't be found in the document


If I use this form
["Base"]
[Script] qrc:/js/mapexport.js:226: ExportError: Invalid data path, the texture set 'Base' can't be found in the document

and this..
["Base", "TextureSet_Name"]
[Script] qrc:/js/mapexport.js:226: ExportError: Invalid data path, the texture set 'Base' can't be found in the document


The second two make sense - there is no textureSet called "Base"

The first makes no sense - why is it looking for a stack called "TextureSet_Name" when in the other examples it is looking for a textureSet name in the same space?

Am I missing something obvious here?



I made a mistake in my previous message, sorry about that.
The format is actually the following (our documentation is not super clear about that):
Code: [Select]
// Example for a Texture Set WITH material layering
var StackPath = [[TextureSetName, StackName]]; //Whole stack
var StackPathLayer = [[TextureSetName, StackName], LayerNameOrUID]; //Specific layer

// Example for a Texture Set WITHOUT material layering
var StackPath = [TextureSetName]; //Whole stack
var StackPathLayer = [TextureSetName, LayerNameOrUID]; //Specific layer
Don't forget your log file. It can be exported from the Help menu of the software.
-----------
Fabrice Piquet aka Froyok. Product Manager, Technical Artist and Documentation at Adobe.

That did it!


Thanks so much for that.  you've saved me a couple of days  there