question

Paolo Giandoso avatar image
Paolo Giandoso asked ·

Arnold for Maya, Is there a way to read imported alembic files textures?

Hi

I am exporting .abc files from the software CityEngine. They contains multiple meshes with multiple shading trees and textures.

I read that alembic contains texture information hidden inside their hierarchy. Is there any way in Maya Arnold to read those textures and shaders and render them? (I am trying to use a workflow involving .abc files instead of .FBX because their size is much smaller). Right now the assets render white.

On this page Here there is a workflow indicated for VRay, I was looking for something similar, but in Arnold, where the textures only appear at render time.

Any help will be greatly appreciated. Many thanks

Paolo

arnold5shaderalembic
10 |600 characters needed characters left characters exceeded

Up to 5 attachments (including images) can be used with a maximum of 2.0 MiB each and 9.8 MiB total.

D Flood avatar image
D Flood answered ·

Not quite what you're asking for, but this script might help:

https://docs.sharktacos.com/pipeline/abcTexPy.html

Share
10 |600 characters needed characters left characters exceeded

Up to 5 attachments (including images) can be used with a maximum of 2.0 MiB each and 9.8 MiB total.

Stephen Blair avatar image
Stephen Blair answered ·

No. It looks like ArcGIS provided a custom script for reading materials and applying to them to the vray proxy object.

1 comment Share
10 |600 characters needed characters left characters exceeded

Up to 5 attachments (including images) can be used with a maximum of 2.0 MiB each and 9.8 MiB total.

Do you mean reading them from the abc file or from where exactly? Any way to use the same workflow in Arnold (Maybe adapting the script)?

0 Likes 0 · ·
Paolo Giandoso avatar image
Paolo Giandoso answered ·

Hi @ Stephen

Correct, this is the script for VRay.

I know a bit of python, but I guess this is written in pymel right?

Do you think it would be possible to convert it to arnold for maya, or it simply can not work with mtoa?



import os, math
import maya.cmds as cmds
import vray.utils as vray
from alembic import *


def getCityEngineMaterial(abcRoot, shaderPath):
p = filter(bool, shaderPath.split('/'))
n = abcRoot
for s in p:
n = Abc.IObject(n, s)
m = AbcGeom.IPolyMesh(n, Abc.WrapExistingFlag.kWrapExisting)
# get material compound prop
abcMeshUserProps = m.getSchema().getUserProperties()
return abcMeshUserProps.getProperty('material')


def getTexBitmap(prefix, abcFileDir, texName):
bufferName = 'bitmapBuffer_' + texName
existingTexBufs = vray.findByName(bufferName)
if len(existingTexBufs) == 0:
texBuf = vray.create('BitmapBuffer', bufferName)
#print "new BitmapBuffer = ", texBuf
filePath = os.path.join(abcFileDir, texName)
texBuf.set('file', filePath)
else:
texBuf = existingTexBufs[0]
texBuf.set('color_space', 1)

uvgName = 'uvgen_' + prefix + '_' + texName
exUVGs = vray.findByName(uvgName)
if len(exUVGs) == 0:
uvg = vray.create('UVWGenChannel', uvgName)
v1 = vray.Vector(1.0, 0.0, 0.0)
v2 = vray.Vector(0.0, 1.0, 0.0)
v3 = vray.Vector(0.0, 0.0, 1.0)
t = vray.Vector(0.0, 0.0, 0.0)findByType("Node")
m = vray.Matrix(v1, v2, v3)
uvg.set('uvw_transform', vray.Transform(m, t))
# note: UVWGenMayaPlace2dTexture with mirror_v did not work (?)
uvg.set('uvw_channel', 0)
#uvg.set('duvw_scale', -1)
print uvg.params(True)
else:
uvg = exUVGs[0]

texBitmapName = 'texBitmap_' + prefix + '_' + texName
exTexBitmaps = vray.findByName(texBitmapName)
if len(exTexBitmaps) == 0:
texBitmap = vray.create('TexBitmap', texBitmapName)
#print "new TexBitmap = ", texBitmap
texBitmap.set('bitmap', texBuf)
texBitmap.set('uvwgen', uvg)
texBitmap.set('tile', 1)
#print texBitmap.params(True)
else:
texBitmap = exTexBitmaps[0]

return texBitmap


def convertMaterial(idx, mtlName, abcMatProps, abcFileDir):
vrayShdName = 'vrayShd' + str(idx)
brdf = vray.create('BRDFVRayMtl', vrayShdName)

vrayMtlName = 'vrayMtl' + str(idx)
vrayMtl = vray.create('MtlSingleBRDF', vrayMtlName)
vrayMtl.set('brdf', brdf)
diffuseColor = abcMatProps.getProperty('diffuseColor').getValue()
diffuseMaps = abcMatProps.getProperty('diffuseMap').getValue()
diffuseMap = diffuseMaps[0] # TODO: error handling

if diffuseMap == '':
brdf.set("diffuse", vray.AColor(vray.Color(diffuseColor[0], diffuseColor[1], diffuseColor[2]), 1.0))
else:
brdf.set('diffuse', getTexBitmap('diffuse', abcFileDir, diffuseMap))

opacityMap = abcMatProps.getProperty('opacityMap').getValue()
if opacityMap != '':
texBitmap = getTexBitmap('opacity', abcFileDir, opacityMap)
brdf.set('opacity', texBitmap.output('out_alpha'))

return vrayMtl


def loadMaterials():
findByType
nodes = vray.findByType("Node")
for node in nodes:
mesh = node.get('geometry')
mesh.set('use_full_names', 1)
abcFile = mesh.get('file')
abcFileDir = os.path.dirname(abcFile)
abcArchive = Abc.IArchive(abcFile)
abcRoot = abcArchive.getTop()

mtl = node.get('material')
mtlName = mtl.name()

print mtl, mtl.params(True)
mtls = mtl.get('mtls_list')
shaderCount = cmds.getAttr(mtlName + '.shaderNames', size=True)
for si in range(0,shaderCount):
sufStr = '[' + str(si) + ']'
shaderPath = str(cmds.getAttr(mtlName + '.shaderNames' + sufStr))
abcMatProps = getCityEngineMaterial(abcRoot, shaderPath)
vrayMtl = convertMaterial(si, mtlName, abcMatProps, abcFileDir)
mtls[si] = vrayMtl

mtl.set('mtls_list', mtls)

loadMaterials()
Share
10 |600 characters needed characters left characters exceeded

Up to 5 attachments (including images) can be used with a maximum of 2.0 MiB each and 9.8 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 5 attachments (including images) can be used with a maximum of 2.0 MiB each and 9.8 MiB total.

Welcome to the Arnold Answers community.

This is the place for Arnold renderer users everywhere to ask and answer rendering questions, and share knowledge about using Arnold, Arnold plugins, workflows and developing tools with Arnold.

If you are a new user to Arnold Answers, please first check out our FAQ and User Guide for more information.

When posting questions, please be sure to select the appropriate Space for your Arnold plugin and include the plugin version you are using.

Please include images, scene and log files whenever possible as this helps the community answer your questions.

Instructions for generating full verbosity log files are available for MtoA, MaxtoA, C4DtoA, HtoA, KtoA, and Kick.

If you are looking for Arnold Documentation and Support please visit the Arnold Support site.

To try Arnold please visit the Arnold Trial page.

Bottom No panel present for this section.