Register Latest Topics
 
 
 


Reply
  Author   Comment  
ruchit

Cooking networks
Registered:
Posts: 156
Reply with quote  #1 
In Houdini->pointVop-> anti-aliased noise or turbulent noise returns 3d noise in given xyz position.
In Maya there is no equivalent node for this, 3d noiseTexture->textureToArray returns same value for x,y,z.

So is there any alternative way to get 3d noise in Maya??
0
ruchit

Cooking networks
Registered:
Posts: 156
Reply with quote  #2 
Here is proof

Code:

def sampleColorAtPoint(shadingNode, points):
  #these are the arguments required to sample a 3D texture:
  textureNodeAttr = shadingNode
  numSamples = len(points)
  pointArray = om.MFloatPointArray()
  pointArray.setLength(numSamples)
  
  refPoints = om.MFloatPointArray()
  refPoints.setLength(numSamples)
  
  for i in range(len(points)):
    point = points[i]
    location = om.MFloatPoint(point[0], point[1], point[2])
    pointArray.set(location, i)
    refPoints.set(location, i)
  # but we don't need these
  useShadowMap = False
  reuseMaps = False
  cameraMatrix= om.MFloatMatrix()
  uCoords= None
  vCoords= None
  normals= None
  tangentUs= None
  tangentVs= None
  filterSizes= None
  # and the return arguments are empty....
  resultColors = om.MFloatVectorArray()
  resultTransparencies = om.MFloatVectorArray()
  # this is the command wot samples
  omr.MRenderUtil.sampleShadingNetwork(textureNodeAttr, numSamples, useShadowMap, reuseMaps, cameraMatrix, pointArray, uCoords, vCoords, normals, refPoints, tangentUs, tangentVs, filterSizes, resultColors, resultTransparencies )
  # return the sampled colours
  sampledColorArray = []  
  for i in range(resultColors.length()):
    resultVector = om.MFloatVector(resultColors[i])
    rgb = [resultVector.x, resultVector.y, resultVector.z]
    sampledColorArray.append(rgb)
    
  return sampledColorArray
# end of sampleColorAtPoint



take a locator & volumeNoise texture

Code:

import maya.cmds as cmds
import maya.OpenMaya as om
import maya.OpenMayaRender as omr
pointArray = []
sampledColors=[]
pos1 = cmds.xform("locator1", query=True, ws=True, rp=True)
pointArray.append(pos1)
sampledColors = sampleColorAtPoint("volumeNoise1.outColor", pointArray)
print sampledColors

0
pshipkov

SOuP Jedi
Registered:
Posts: 4,732
Reply with quote  #3 
Every 3D procedural texture node in Maya has a vector attribute called referencePointCamera.
Set it to something and then getAttr .outColor - the result will be for the provided reference 3D point.
Two lines of MEL in a loop !
This technique works well. It is used in "overburn" to apply voxel properties from any 3d procedural texture.

The code you provided does the same, but in unnecessary complex way.

SOuP's textureToArray node has a parameter called "accurate sampling". By default i use the MDynamicUtil which is much faster than MRenderUtil::sampleShadingNetwork.
Turn this option on and everything will work as expected with 3D textures.

Hope this helps.
0
Previous Topic | Next Topic
Print
Reply

Quick Navigation:

Easily create a Forum Website with Website Toolbox.