Jump to content

Getting Some Randomness Into The Colour In Vop Network


mark

Recommended Posts

why wouldnt this work? :(

i want the shader to randomly assign either color1 or color2 to an object

color1 ->

switch inputs

color2 ->

nrandom -> fit (to 0,1) -> float to int -> switch index

Edited by mark
Link to comment
Share on other sites

well at one stage i did get a sort of speckled pattern and actually wondered that! but then i didnt give it another thought at the time.

so i guess the question is how to apply it at an object level? :)

i think i need to have multiple lighting solution vops connected to the output shader via a switch with nrandom as the seed index

Link to comment
Share on other sites

  • 1 month later...
I'm sure there's an object id number that you can use in a shader, but I forget at the moment the actual name of the variable. Maybe someone else can remember.

I think you should make the "switch" possible at geometry level.

So I think this should work if I did not get you wrong:

- Create your shader in VOPs

- Keep the switch inside

- But export the switch to the interface of the shader so you can change it from there.

- Then you can assign the shader at geometry level... and read the "opdigit" thing of the object level... then feed this number into the switch control with a rand func.

- But then you have to copy paste your objects at object level.

- Each shop network with the shader should be included inside each geometry container.

- As you copy paste them around the scene... it should produce different textures for each copy

(obj1, obj2, obj3 etc.)

- Each object will have its own shader network inside as it gets copied. Each shader will read the 1,2,3 etc. from the object level and generate different result.

Sorry, it is a primitive solution but this is how i did it a few months ago. You guys are talking about VOP stuff, nrandom etc. and I am talking about copy pasting...

:)

EDIT:

I really would like to know if there are solution that work for the "point instancing" or the "Copy / Stamping" techniques.

Thanks.

Edited by Symbolic
Link to comment
Share on other sites

If you aren't aware of it, there is a VEX function called renderstate() which can return information to the shader about the object it's rendering - its name, for instance.

In the Houdini Help Browser:

http://localhost:48626/vex/functions/rende...e?q=renderstate

string objname = "";
renderstate("object:name", objname );

... which might get you part of the way, because now you'd want it to be a unique number instead of the string so you can use it with random(seed).

I've often wished for Houdini to have a string hashing function exposed (which generates a unique numeric for a unique string) since there have umpteen times I've wanted to produce a unique number from an object path. Also it would be nicer is you could get object:id (in a way similar to opid() in Houdini), but unfortunately you cannot. I can't even remember if I've RFE'd any of these with SESI...

Also, I don't believe there is a VOP equivalent - so you have to use an Inline Code VOP.

Link to comment
Share on other sites

If you aren't aware of it, there is a VEX function called renderstate() which can return information to the shader about the object it's rendering - its name, for instance.

I believe you can query the object's ID as well. According to the docs (H9.1.133), the property is int object:id (though I haven't tested it). So, presumably, you could:

int oid = 0;
renderstate("object:id",oid);
int switcher = (random(oid)>0.5);
//etc...

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