Convert Shop Material attribute to CD (color) attribute?

   1195   14   1
User Avatar
Member
235 posts
Joined: Sept. 2008
Offline
Hello. Yes, I have had a license for many years but continue to learn. I am still using H13 but this may also apply to principled shaders in H18.

What I would like to do is take a Material that is rendered across thousands of frames (animated material) and convert that into Primitive Colors or Point Colors so that I can group them according to an expression, grouping only the colors of the primitives or points that I desire, deleting most of the unneeded geometry. The material is currently placed after a UV Project SOP and applied with a Material SOP.

How can I do this? I tried searching and found a post that seemed to ask for the reverse either here or on odforce though I didn't quite understand the workflow in the post.

Any help is greatly appreciated. Thanks, Rene
User Avatar
Member
182 posts
Joined: April 2009
Offline
If I understand you correctly, then you want to pre-process your geometry before it goes into rendering, based on something that the shader outputs?

I'm not sure there is a direct (or easy) way to evaluate the material in SOP context.

Some workaround ideas:

1. Pre-render the whole thing in low resolution, and low settings so it outputs the attribute you want to use as a mask.
Then project UVs from the camera back onto the geometry and use the rendering as a texture in a PointSOP / Wrangle.

2. If it's one of the basic projection methods you're using (ortho, polar, cylindrical) you could also bake the shader to a low resolution texture sequence on simple geometry, depending on the type. Orthographic -> Grid; Polar -> Sphere etc. If you then apply that texture to your geometry it should more or less look similar aside from anything related to light and shading, then mask your prims and points with the color or any AOVs.
This is also a pre-render, but if you have heavy geometry it might be faster.

3. Replicate the important parts of the shader, (noises etc) that you want to use for masking in a Point VOP and reference the animated parameters from the material. You'd need to keep it up to date though. Or wrap it in an HDA that works in the material and sop context with all the important logic inside, then reference animated parms.
There are some caveats if you're using P or N directly in the shader, because they are not in object space.
Mariusz Wesierski @ Mackevision
User Avatar
Member
235 posts
Joined: Sept. 2008
Offline
blackpixel
1. Pre-render the whole thing in low resolution, and low settings so it outputs the attribute you want to use as a mask.
Then project UVs from the camera back onto the geometry and use the rendering as a texture in a PointSOP / Wrangle.

hi and thank you for your response with some ideas. I am actually doing something like this. I am using a “tex()” expression in a Primitive SOP to read the colors of the texture directly onto the Primitives of the Grid. However the geometry of the primitive has to be so dense in order to read the colors accurately (I am using a screen recording and need to capture info from the recording/animated material as geometry based on colors, if that makes sense), but because it is so dense this method takes eons to cook. I have over 7000 frames of animated material/texture to read and process in a ROP output and it has taken over 24 hours so far and is only 60 percent done rendering. I am not even sure if the geometry in my ROP will work for what I would like. This is why I was hoping to magically convert the texture to point or prim colors easily.

Unfortunately I would also have to search deep for some tuts on how to use a Point Wrangle the way you describe with uv's. I have seen some of Rohan Dalvi's tuts and hope to be able to find more. Houdini is harder than it was before Attributes/VEX became the mainstay of workflows.
User Avatar
Member
182 posts
Joined: April 2009
Offline
Aaah, ok! If it's just a texture you need, then it's super easy and fast with VEX: Point VOP, (simple) Wrangle or Attribute from Map.
( see attached hip )

If writing code is not your thing, then you can comfortably stay node based in VOPs.

Attachments:
color_texture.hip (170.3 KB)

Mariusz Wesierski @ Mackevision
User Avatar
Member
235 posts
Joined: Sept. 2008
Offline
Hi. unfortunately this doesn't work as i cannot group the primitives after applying the attribute. the texture from the attribute wrangle is not baked in. zero primitives are grouped.


I have shown the way I use the Primitive SOP to apply the texture and the red from the Houdini logo is somewhat orange showing the yellow grouping interaction with the colors of the logo.

Attachments:
texture_attribute.jpg (368.0 KB)
primitive_tex_expression.jpg (444.8 KB)

User Avatar
Member
235 posts
Joined: Sept. 2008
Offline
but you're right i think it will cook faster if this method would work.
User Avatar
Member
182 posts
Joined: April 2009
Offline
That's because Cd is a point attribute. Promote it to Primitives with Attribute Promote or switch the Group Expression to Points.
Edited by blackpixel - May 8, 2020 03:18:24
Mariusz Wesierski @ Mackevision
User Avatar
Member
235 posts
Joined: Sept. 2008
Offline
wow! yes, it works! i will let you know how fast it is in comparison when i try to apply the 7000 animated texture frames. I was using “$F” in the name of the textures. how is this done now with the “@frame” call?
User Avatar
Member
235 posts
Joined: Sept. 2008
Offline
i see $F still works but i think it is important to know how to use “frame”
User Avatar
Member
235 posts
Joined: Sept. 2008
Offline
oddly enough i just tried using one of the methods with an attribute wrangle in H13 and it fails unless I am doing something wrong, which is also likely. the grid shows up white instead of with the texture.
User Avatar
Member
5139 posts
Joined: July 2007
Online
markerline
i see $F still works but i think it is important to know how to use “frame”
not that important as you'd never use @Frame as a filepath expression (as opposed to in VEX snippets where the syntax of @Frame came from), but if you must now it's capital F and you have to enclose it in ticks as an expression, so something simple like this: file.$F.exrwould become this: file.`@Frame`.exr, and we are not even talking about padding like $F4
Edited by tamte - May 8, 2020 03:38:09
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
235 posts
Joined: Sept. 2008
Offline
ok i got it!! i had tried to place the path string directly into the vex expression but i see you need to use “map” and place the path into the parameter interface separately. in H13 there is no quick shortcut button to create parameters based on ch strings in the expression. so i had to click the gear icon.
User Avatar
Member
182 posts
Joined: April 2009
Offline
There are some usecases where you'd want to build the string in VEX so you could go:
string map = sprintf("/foo/bar.%04d.rat", @Frame);
>>> /foo/bar.0001.rat
>>> /foo/bar.0002.rat
>>> /foo/bar.0003.rat
Mariusz Wesierski @ Mackevision
User Avatar
Member
235 posts
Joined: Sept. 2008
Offline
it is rendering at 10 frames per 39 seconds whereas before each individual frame was taking over 1 minute to render a single bgeo file. and there is more data in these new frames as well as I have selected a slightly different set of color ranges and deleted based on the new group expression. i thank you immensely for your help! blackpixel and tamte
User Avatar
Member
235 posts
Joined: Sept. 2008
Offline
and thanks for the last info on “Frame”
  • Quick Links