Problem with foreach prim and uvquickshade...

   3399   4   1
User Avatar
Member
98 posts
Joined: Sept. 2008
Offline
Dear friends,

For a project I am developing, I've been struggling with some apparently simple Houdini nodes and some straightforward Python code, but I cannot find not only what the bug is, but also how the foreach-prim works.

I want to texture a model, but using a different textures for each primitive. Each primitive carries, as attributes, the information needed to texture it. To simplify explanations, I've created a locked node that contains all information from the upstream network, which is not important for this problem. Then, as the primitives I am using are simple flat rectangles, I've decided to texture them with a uvquickshade node. It's simple, it's easy and I think it's elegant. However, I could not put my code in the Texture Map parm of the uvquickshade, so I decided to put this node inside a foreach node, with the “For” parm set to “Each Primitive/Point”. So, we have an outer foreach-primitive loop with a simple uvquickshade node inside, and the quickshade node selects the texture based on some informaton attached to the primitives as attributes. Simple, I think.

Problems are
1- I added a print statement inside the code for the uvquickshade, and the printed text only appears 3 or four times for each cook, even if I disconnect and connect the foreach node again. There are 18 input primitives, but sometimes I do not get even a single print!!!! How's that even possible? For me, it is obvious that I am not using the foreach-primitive node correctly…

2- Some stupid tests I did showed that the uvquickshade almost never loads the right texture, but sometimes it loads ONE (and the same) texture for every primitive! That means that, somehow, every primitive is “the same” and one evaluation of the uvquickshade is used for all the primitives. I guess my problem here is the same as in the previous point, but I wanted to be sure.

3- Right now, the code inside the uvquickshade appends ‘$HIP/“ to build the texture name, but in some tests I did I got nothing until I appended hou.expandString(’$HIP'), which is weird to me. Why using $HIP doesn't work, and I have to expand it? In any case, this is a minnor issue, as the foreach problem is preventing me from moving forward…

I attach a demo file, reduced to its bare minimum, plus some textures to try. By the way, some primitives do not have an associated texture, so showing them ”as is" is OK.

thank you VERY MUCH!!!!

dagush.-

Attachments:
Texture Problem.zip (45.7 KB)

————————-
* skylineEngine project coordinator
* buildingEngine module developer
http//ggg.udg.edu/skylineEngine
User Avatar
Member
7725 posts
Joined: July 2005
Offline
Sorry, didn't look at your set up but try looking into using the Material SOP to apply a SHOP (with texture map override) to each face. This requires that you first set up your uv's first. Then look at the primitive attributes that get generated as a result.

I think the override method might only work for Mantra. If you need the viewport preview, then you likely need a different SHOP per texture and then reference those from your shop_materialpath primitive attribute.
User Avatar
Member
98 posts
Joined: Sept. 2008
Offline
Hi,

Thank you very much for your answer, but I must confess I am not following your explanation. I tried to follow these steps, and create a SHOP with texture override, but I really do not know how to pass information from the primitive (remember that the name of the texture to load is built from attributes at the primitive level) to the SHOP. All I get are “nonetype has no attribute…”, that is logical as I am tying to access a node geometry, which is not available here…
The other option is not possible, as the whole idea is to avoid creating one material for each texture, as we have one texture for each primitive! The idea was to have something VERY compact, so I invented the uvquickshade-inside-foreach trick.

By the way, I also changed the foreach-prim node by a partition + foreach-group combination, with the same results. Now I am starting to think that the problem is that Houdini believes this node does not need to be recooked for each primitive, and only evaluates it once. I've checked and the textures names that get generated are different and correct, but for some weird reason they are not evaluated. for instance, I disconnect the wire from the geometry into the foreach, I wire it again, and no evaluations are performed (I have a print inside the Python code to generate the name). This means that Houdini is not evaluating the node!

Please, help me as I have no clue where to go from here…

Thanks!!!

dagush.-
————————-
* skylineEngine project coordinator
* buildingEngine module developer
http//ggg.udg.edu/skylineEngine
User Avatar
Member
8581 posts
Joined: July 2007
Offline
no Python or For Each SOP is needed for this

just 2 attributecreate SOPs
one for creating uvs (if you don't have them yet)
2nd for generating per primitive string attribute containing texture path which will automatically override parameter on your material with the same name as the attribute, so in this case I used dif_map

and of course you will see the result only in render

Attachments:
simpleBuildingTextures_fix.hipnc (191.8 KB)

Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
98 posts
Joined: Sept. 2008
Offline
Thank you VERY MUCH!
I did not know how to link with the rendering part, but this was awesome!
Thanks!!

gus.-
————————-
* skylineEngine project coordinator
* buildingEngine module developer
http//ggg.udg.edu/skylineEngine
  • Quick Links