material(texture) overrides using variable to define number of image sequence to use as texture

   4570   6   0
User Avatar
Member
125 posts
Joined: April 2014
Offline
ugh, I have spent all day on this and have nothing to show

I am simply using “copy to points” to copy an object to each of the point positions.
The object being copied has two materials, one of which I need to apply a unique texture map to for each copy.
My images are of a short numbered sequence. No zeros, just numbered 1-8. ie Map.1.jpg, map.2.jpg, etc

I am applying a local override onto a material node to the basecolor_texture parameter after I have copied the objects to the points. The only way I get the images to change is when using the $F attribute. - Map.$F.jpg

I have tried creating local attributes for the points, which are being passed correctly to the copies, promoted them to the primitives but they do not seem to work in the context of creating a string that references the needed image.

Perhaps I am using the wrong terms but I cant find any examples of this anywhere.

Can anyone offer a suggestion where I could find a sample of offer a solution to what I am doing wrong?

Kind of new to Houdini so maybe there is a better way of doing this. Was thinking this would be a simple exercise.
User Avatar
Member
125 posts
Joined: April 2014
Offline
I have come to the conclusion that I don't understand how to create an appropriate local variable that can be used in the filename #.
Picking up there tomorrow…
User Avatar
Member
125 posts
Joined: April 2014
Offline
ok, I got it somewhere along this journey my local variable name was inadvertently removed from the attribute create node.
User Avatar
Member
8539 posts
Joined: July 2007
Offline
you don't need local variable or material overrides
just name your string attribute exactly the same as is the parameter in material you want to override
Parameter VOPs behave essentially like Bind VOP so if there is an attribute on the geometry with the same name and type, its value will be used instead of parameter value
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
125 posts
Joined: April 2014
Offline
oh wow - thanks for that. A joy of Houdini moment
I was able to build the correct strings per point using ptnum as the index in an attribute vop
then promote that to the primitive on the copied objects
User Avatar
Member
258 posts
Joined: July 2006
Offline
Hi
You need a point attribute that would be your frame integer you want to load.

so for example

create frame number for points

int frametoLoad = i@offset + @Frame; //create an offset of some sort you may or not need

s@texturepath = sprintf(“texturepath.%d.jpg”,frametoLoad); // this will create a string and will replace the %d with your i@frametoLoad attribute per point.



Now in SOP level, plug a material node, assign your shader and create a local override with map selected.
It will create a material_override
in String section you can call the attribute using point vex function


Ok I read you msg again, you dont have sequences but random images
so then modify the vex like this

i@id = @ptnum; //(if you dont have id)
int mapnumber = i@id % 5; // will return you a mapnumber per point from 0 to 4 i think
s@texturepath = sprintf(“texturepath.%d.jpg”,mapnumber); // this will create a string and will replace the %d with your mapnumber attribute per point.
Edited by tricecold - June 9, 2017 15:18:40
Head of CG @ MPC
CG Supervisor/ Sr. FX TD /
https://gumroad.com/timvfx [gumroad.com]
www.timucinozger.com
User Avatar
Member
125 posts
Joined: April 2014
Offline
thanks tricecold,
these code snippets look very useful. I just got comfortable doing this in a vop so I look forward to doing this “straight” if you will in a wrangle.

I don't know why but it never really dawned on me till now how useful a concept that building and modifying strings variables can be.
  • Quick Links