mark Posted December 8, 2007 Share Posted December 8, 2007 (edited) 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 December 8, 2007 by mark Quote Link to comment Share on other sites More sharing options...
sibarrick Posted December 8, 2007 Share Posted December 8, 2007 Won't the nrandom get recalculated for every point shaded not each object? Quote Link to comment Share on other sites More sharing options...
mark Posted December 8, 2007 Author Share Posted December 8, 2007 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 Quote Link to comment Share on other sites More sharing options...
sibarrick Posted December 8, 2007 Share Posted December 8, 2007 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. Quote Link to comment Share on other sites More sharing options...
Symbolic Posted January 26, 2008 Share Posted January 26, 2008 (edited) 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 January 26, 2008 by Symbolic Quote Link to comment Share on other sites More sharing options...
Jason Posted January 28, 2008 Share Posted January 28, 2008 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. Quote Link to comment Share on other sites More sharing options...
Mario Marengo Posted January 28, 2008 Share Posted January 28, 2008 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... Quote Link to comment Share on other sites More sharing options...
Jason Posted January 28, 2008 Share Posted January 28, 2008 I believe you can query the object's ID as well. According to the docs (H9.1.133), the property is int object:id ... Ah you're right! I should have followed the link to: http://localhost:48626/props/mantra9_1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.