stamping question...

   8497   10   2
User Avatar
Member
527 posts
Joined: July 2005
Offline
I am distributing a library of objects which are the same but with variations in their texture over a surface. Currently it stamps objects with unique shaders to source in their unique texture. Is it possible to do the stamping within the file input of the shader, so that if it stamps input 11 it will source texture 11?

Its just that I have so many obj/textures/ shaders that it would be sweet if it was possible to stream line from one node and one shader.
soho vfx
User Avatar
Member
1390 posts
Joined: July 2005
Offline
sure you can!

Simply way out:
create a geometry attribute to store texture specific number or whole texture name.
Than force shader to use this attribute as texture name or construct such from that.
Like here:
(I got these screens on my disk but no H. right now so it's hard to show hip, sorry)
[img363.imageshack.us]
[img184.imageshack.us]
[img178.imageshack.us]
[img400.imageshack.us]

Does it help?
cheers,
SY.
User Avatar
Member
527 posts
Joined: July 2005
Offline
That is good but it does not work in my situation.

The problem is that I have about 100 unique textures and there will be more than 1000 points to distribute the objects onto. There fore the $PT into the file name wont work unless I have 1000 textures.
soho vfx
User Avatar
Staff
2591 posts
Joined: July 2005
Offline
Wren
That is good but it does not work in my situation.

The problem is that I have about 100 unique textures and there will be more than 1000 points to distribute the objects onto. There fore the $PT into the file name wont work unless I have 1000 textures.

There's a wonderful operator called modulo, often represented by the % operator. It gives you the remainder when dividing by the number.

14 divided by 10 is 1 with a remainder of 4. So, 14%10 would give you 4, 391381%10 would give you 1.

Further examples, 23%4 == 3, 16%8 == 0.

If you use the technique above, but set CopyNum to ($PT % 100)+1, then even if you have 1000 points, you'll only reference textures 1 to 100.

I think this is what you were looking for. I hope it helps.

Edit:
Alternatively, you could go for a more random approach. rand($PT) will generate a number between 0 and 1. So “floor(rand($PT)*100)” will generate a number between 0 and 99 (which is the same as the modulo operator above.

I'm sure there are other approaches too.
User Avatar
Member
1390 posts
Joined: July 2005
Offline
thanks mark!

That's a point: expression generator is a different story and you can work on it or ask here. mark gave you just two examples of it.

The main idea really matters: piping in texture info to shader via geometry attribute.

There are number of ways to manage Copy-Number <–> Texture-Number issue. Write something more, so one can help!

cheers,
SY.
User Avatar
Member
527 posts
Joined: July 2005
Offline
I am attempting to use this method. However it seems as though I am missing something.

1.geo with uv's inputing 100 times into switch with select input set to

stamp(“../copy1”,“number”,100)

2. point cloud into an attribcreate with Name set to “CopyNum” , Class as point, Type as string set to
/rat/bKc.(rand($PT)*100).rat

3. switch and attribcreate piped into copy node with stamp variable set to
fit01(rand($PT*ch(“/obj/geo1/copy1/val2”)),0,100)

4. copy1 into attribpromote1 with original name set to “CopyNum”, original class set to point, new class as Primitive and promotion Method average.

The attribpromote1 gives me an error
attribute CopyNumb either not used or unrecognized


ps. I am confused at how you apply the shader. Is it at sop level or obj level? If at sop level what part of the network do you put it?

pps.Is there no way to have the mesh piping into a shop sop piping into a switch to use the stamp command within the shaders texture input? ie.
/rat/bKc.stamp(“../copy1”,“number”,100).rat
soho vfx
User Avatar
Member
1390 posts
Joined: July 2005
Offline
gosh, I don't really have H. after crash and reinstall and I don't exactly get what's going on in you description. My scenes looked like this (although there is no STAMP involved in it!):



I can't prepare scene now but I found my or ptakun similar example(?) on disk (not sure what it is actually, sorry )
Try it. Maybe it will help!

Attachments:
stamps.zip (10.0 KB)

User Avatar
Staff
2591 posts
Joined: July 2005
Offline
Try the attached .hip file (you'll need to uncompress it first). In the viewport you'll see just one texturemap. However, if you render with mantra, the attribute “map” will override the texture map specified in the decal shader.

Hope this helps.

Attachments:
stamp.hip.gz (12.9 KB)

User Avatar
Member
527 posts
Joined: July 2005
Offline
Thanks for all the help guys. The syntax involved is making more sense after looking at the posted examples and the idea of dealing with the primitives instead of the points simplifies things.

Mark your solution is an eloquent and look forward to trying at work tomorrow.

Cheers,
soho vfx
User Avatar
Member
527 posts
Joined: July 2005
Offline
Everything is working great!
Though I don't fully understand how the vdecal shader is sourcing in the map attribute. If a shader has a param that matches the name of an attrib on a primitive it will source it automagically?

The last thing I need to solve is how to make this expression return whole numbers.
fit01(rand($PT*ch(“/obj/layer/copy1/val2”)),0,95)

Cheers,
soho vfx
User Avatar
Member
527 posts
Joined: July 2005
Offline
never mind …. round()
soho vfx
  • Quick Links