Jump to content

is there 'random' for materialX?


pelos

Recommended Posts

i want to feed some points to a random,  so i get a random  value between 0-1 and feed that to a gradient,  that way with the gradient i can tell what percentage of certain color i want.

but i dont find anything like that.   and if i use the normal random.  the render complains =( 

random_materialx.PNG

Link to comment
Share on other sites

That's a VOP, right? Why wouldn't that work with MaterialX? Just fetch in the result of your VOP which is Cd using the mtlxGeometryColorNode.

You can always pickup a pre-randomzied attribute on the points inside using a mtlxGeometryPropertyValue. Another way is to used one of the mtlxNoise nodes with a signature of float. Read up on them. Some are in the range of 0,1 and others -1,1.

Edited by Atom
Link to comment
Share on other sites

i thought when doing materialX  you can only use mx materials   or complains, for example the node "uv cords"  and "mtlx Tex Cords"    or "constant"  and "mtlxConstant"

Edited by pelos
Link to comment
Share on other sites

Yes, but you can still read in attributes form your geometry to work with, add noise, etc.   Atom's tip on using the mtlxGeometryPropertyValue is something I use all the time in my MtlxX shaders to pass attributes from the SOP geometry into my shaders for masks, colors, etc.  Just set whatever random value you want on your geometry and then read it into your MtlX shader

randcol.jpg

Link to comment
Share on other sites

On 7/3/2023 at 2:24 PM, Atom said:

That's a VOP, right? Why wouldn't that work with MaterialX? Just fetch in the result of your VOP which is Cd using the mtlxGeometryColorNode.

You can always pickup a pre-randomzied attribute on the points inside using a mtlxGeometryPropertyValue. Another way is to used one of the mtlxNoise nodes with a signature of float. Read up on them. Some are in the range of 0,1 and others -1,1.

 

thanks, my questions was more about if there a random node in materialX or if anyone had needed to create one before.  (Thanks for the advice on how to bring geo attributes to the shader  =)  

 

if we attach that attribute into geometry adding an additional attribute is adding more disc space when is not needed, will be a lot of geometry.      yes i could add a random value to each prim.    but is smarter to just do it on the shader instead.

Link to comment
Share on other sites

2 hours ago, pelos said:

maybe this will provide an idea.

 

the front row is what i want to get,    but with materialX  i get the back row

screenshot1.PNG

materialX.hip 1.01 MB · 1 download

Mtlx doesn't have random function yet, you need to set random values on sop level or through noise as mention above, check an example.

 

materialX_v02.hip

Link to comment
Share on other sites

that i know how to do, but it adds extra attributes to the geometry. and there will be a lot of geo to save to disk,  and should be done at the shader

we don't want to add another column of attribs

image.png.8dda901923d477c0c9731c3be5930779.png

 

since can be done with normal shaders    should be able to do it with materialX

Link to comment
Share on other sites

20 minutes ago, pelos said:

magical!!!!   not sure why i was not getting that, maybe i was using the 2d noise and should needed to be 3d?      

Fencer you rock!

Probably 2d noise required uv coordinates, value 0 to 1. You have 1,2,3... in incoming attribute.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...