Jump to content

Assigning Random Solid Color


zoki

Recommended Posts

hi

I have alpha mask/channel

and in it of course I have areas of white on black background

what would be easiest way to color each area with random flat color?

I thought puting alpha in cops >find edges>trace sop>randomize primitive color>render again

There must be some other solution without going to sops?

z

Link to comment
Share on other sites

hi

I have alpha mask/channel

and in it of course I have areas of white on black background

what would be easiest way to color each area with random flat color?

I thought puting alpha in cops >find edges>trace sop>randomize primitive color>render again

There must be some other solution without going to sops?

z

Use your alpha as a mask in VOPs maybe?

Link to comment
Share on other sites

Hi, just off the top of my mind I think you could assign the alpha to texture in a shop, and then use the tex, pic or picni function inside a color or a property or attribute node to select only the point or primitives that fall inside the alpha, group the points by proximity (or by some other clever expression), and then assign a random color to each group. I don't have houdini right now so I can't say specifically how, but I think it could be possible.

Link to comment
Share on other sites

yes this would be possible in "generic" case

except that my mask is defined/painted layer and I want to randomize its patches!

I cant change patches shape in fact I must stay as true as possible to their size /outline

thanks

z

Link to comment
Share on other sites

except that my mask is defined/painted layer and I want to randomize its patches!

It would seem that flowerdealer's approach would be your best bet, then. Have you tried it?

I may be misunderstanding, but since you know that the data needs to become little islands of random solid colors, *and* you're "painting" or generating the alpha mask yourself, then it would seem that you have complete control: that you could generate the random colors from the start and bypass the "map-greyscale-to-colors" stage, no?

Link to comment
Share on other sites

I have matte painting and I painted mask for windows because some windows are in actual geometry and some are just painted and reprojected to low poly geom.

so from this painted frame which represents all glass surfaces in city I need to randomly colorize them for tweaking reflection pass in comp

before I painted them manualy and it takes hours

I am sure there must be elegant procedural way of doing this

so far I traced my mask with trace sop and using point sop I rand$PR color so each primitive is different

I forgot how do I pass color from point sop/add color to render? :blush:

I didnt use it for a while and I know I saw this somewhere?

so this is one solution

and this being houdini there must be another also, right?

thanks

z

Link to comment
Share on other sites

it looks ok

but how do I make this color cels conform to my drawing /layout

to get rid of this celular look and make them color each area

each area must have just one color not be split into two or more though

z

Edited by zoki
Link to comment
Share on other sites

it looks ok

but how do I make this color cels conform to my drawing /layout

to get rid of this celular look and make them color each area

each area must have just one color not be split into two or more though

z

Please look at the hip file.

If the areas are continuous, they'll be assigned the same random color (as per connectivity).

I had to use *something* since I don't have your image, so I chose the cellular noise for demonstration purposes... I realize that's not what your image looks like. :rolleyes:

Link to comment
Share on other sites

I forgot how do I pass color from point sop/add color to render? :blush:

Just make the name of your attribute the same as the colour parameter for your shader.

So in this case use an attribute sop to rename your point (or primitive) Cd colour to diff (or whatever your shader uses to define the colour of the windows)

Link to comment
Share on other sites

Hi

I tried both versions and one with trace and geometry is faster and more accurate!

In Mario's version bottleneck is grid resolution because if you have some areas with just few pixels in your map you need to hace grid with over 1000 columns to get detail out

But other problem I have is how to match render view so it aligns excactly with source image in cops?

Traced geometry gets placed into origin so if I set my resolution in camera to fit resolution of image being traced it is still in center.

I need to match my camera or traced geometry to fit precisely back onto traced plate?

z

Link to comment
Share on other sites

I need to match my camera or traced geometry to fit precisely back onto traced plate?

Set your camera to "Orthographic", with "Translate" = {0,0,1} and all other transformations at default. Then set its "Ortho Width" to 1 and its resolution to match your image's resolution.

If you render your traced geometry from this camera (and assuming you don't do any weird transformations in SOPs), then it should match your original "Alpha" image... at least in theory... :)

Also note that if you move the final multiplication in my example (the last point SOP in the chain) to the shader (i.e: multiply by the alpha image in the shader, not in SOPs), then you can probably get away with having a lot less points. In any case, this is a one-time expense, right?

Additionally, the trace sop works with a threshold... meaning that it will likely miss antialiased edges in the source image (or eat into them a bit), so if you're using the trace method, it would probably be wise to trace against an un-premultiplied version of your alpha image, and then re-multiply either in the shader or in COPs.

Good luck!

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...