Guest Swann Posted May 11, 2008 Share Posted May 11, 2008 (edited) Hello everybody I'm trying to recreate standard Houdini MetaCloud shader in VOPS and I got some questions. These are only my thoughts about what to do. * Produced by: * Side Effects Software Inc * 123 Fronst Street West, Suite 1401 * Toronto, Ontario * Canada M5J 2M2 * 416-504-9876 * * NAME: fluffy.vfl ( VEX ) * * COMMENTS: Generate a fluffy cloud using metaball geometry */ #pragma opname v_metacloud #pragma oplabel "VEX Meta Cloud" #pragma label freq "Noise Frequency" #pragma label offset "Noise Offset" #pragma label time "Cloud Time" #pragma label amp "Noise Amplitude" #pragma label rough "Noise Roughness" #pragma label turb "Turbulence" #pragma label limit "Density threshold" #pragma label perpoint "Per-point noise" #pragma label summing "Density" #pragma hint perpoint toggle #pragma range turb 0 8 #pragma choice summing "sum" "Sum metaball densities" #pragma choice summing "max" "Choose maximum density" #pragma range turb 0 10 Content of this part is pretty clear for me //// Compute noise on a per metaball basis. We take either the max or the sum of // the densities. // vector compNoise(vector p; vector freq, off, amp; float rough, now; int turb) { int i; vector scale; vector nval; vector4 pp; pp = p * freq + off; pp.w = now; nval = 0; scale = amp; for (i = turb; i-- > 0; pp *= 2, scale *= rough) nval += scale * (vector(noise(pp)) - (.5,.5,.5)); return nval; } In the gNoise.h there are couple similar noise functions, althrough not identical so I supose it will be best to go here with InlineVOP. But using oportunity that OldSchool started in his BLOG series of lessons on "Create Custom VOP" I thinking about recreating this function clearly in VOPs without InlineVOP. Question 1: 1. pp.w //does this mean "dot produkt per-point and w " ? 2. pp *=2 or nval += //what mean sign * and + before # equal ? image3dmetacloud( vector freq=3; // Noise frequency vector offset=0; // Noise offset float time=0; // Time offset vector amp=.3; // Noise amplitude float rough=.6; // Noise roughness int turb=4; // Turbulence float limit=1; // Maximum density int perpoint=0; // Do per-point noise calc string summing="sum"; // Do summing by default ) no questions here yet { vector nval; vector pp; float tmp; density = 0; if (perpoint) { forpoints(P) { // Convert to the space of the metaball. Now, P is somewhere in // the unit sphere. pp = mspace(P); 1. - starting from globalVariablesVOP - density plug to compareVop - to InlineVOP we pluging Globals "P" and output of compareVOP - output of InlineVOP will give "nval" 2. - nval, P, and compareVOP we are pluging to If-Then-BlockVOP 3. inside If-Then-BlockVOP: - P and nval plugged into pointLoopVOP 4. inside pointLoopVOP - "pp" it's P after transform to metaball space with a help of metaBallSpaceVOP // Now, if there's a rest attribute, add it onto the original // position. This gives us a per-metaball noise offset. if (isbound("rest")) pp += mattrib("rest", P); - propably we can supply "rest" attribute with parameterVOP and add it to P (Question 2: There is written original P, so does this mean big P not the "pp" after transform ?) but we cando the same with a help metaBallAttributeVOP whitch by deflaut is looking for "rest" attribute Question 3: What means pp+ ? Is it mean the same what normal "pp" and plus means that something is added (rest attribute) to it ? Question 4: beside, like below with "P+nval", maybe "pp+" should be done by adding output of metaBallAttributeVOP and metaSpaceVOP nval = compNoise(pp, freq, offset, amp, rough, time, turb); tmp = mdensity(P + nval); - we got "nval" but "tmp" hm... with this I got problem, because: Question 5: There is written "P+nval" and metaDensityVOP is not taking nval in his calculations, so what should I do ? instead metaDensityVOP make addition of big "P" and "nval" ? if (summing == "sum") { density += tmp; if (density > limit) break; } else if (tmp > density) { density = tmp; if (density > limit) break; } } } else { // Just compute noise in world space nval = compNoise(P, freq, offset, amp, rough, time, turb); density = mdensity(P + nval); } density = clamp(density, 0, limit); } - we leave this part for now, I don't have idea how to remade most of this, proplably next if-Then-BlockVOP but I completly don't know how to bite "density > limit", "break" and others here. Question 6: beside, why in the end we are calculating noise in worldSpace ( when condition is not meet) when we need it calculated in metaSpace ? Thanks Edited May 11, 2008 by SWANN Quote Link to comment Share on other sites More sharing options...
aracid Posted May 11, 2008 Share Posted May 11, 2008 Hey I'll try give it a shot, Q: 1. pp.w //does this mean "dot produkt per-point and w " ? A: normally when u define a vector 3 you have 3 floats paired to the variable, vector.x vector.y vector.z in the case of a vector4 u have an aditional float called w, which i think stands for weight, but u can store any float with. so theres nothing special involved except with a float u store 1 value, a vector - 3 val, vector4 - 4 val. Q: 2. pp *=2 or nval += //what mean sign * and + before # equal ? A: pp*= 2 actually expands to pp = pp * 2. or in the case of pp+= 2 expands to pp = pp + 2; so its just a more efficient method of coding. Q: why in the end we are calculating noise in worldSpace ( when condition is not meet) when we need it calculated in metaSpace ? A: thats purely because they haven't included a method to introduce the local translations of each metaball. I think for no reason expect as an example of a simple shader that doesn't include much. Take a look at the heavy smoke in the FX shelf, included with that is a shader that uses the local space of the metacloud as a coordinate system. hope any of this was helpful. Quote Link to comment Share on other sites More sharing options...
Guest Swann Posted May 11, 2008 Share Posted May 11, 2008 (edited) Hey I'll try give it a shot, Q: 1. pp.w //does this mean "dot produkt per-point and w " ? A: normally when u define a vector 3 you have 3 floats paired to the variable, vector.x vector.y vector.z in the case of a vector4 u have an aditional float called w, which i think stands for weight, but u can store any float with. so theres nothing special involved except with a float u store 1 value, a vector - 3 val, vector4 - 4 val. Q: 2. pp *=2 or nval += //what mean sign * and + before # equal ? A: pp*= 2 actually expands to pp = pp * 2. or in the case of pp+= 2 expands to pp = pp + 2; so its just a more efficient method of coding. Q: why in the end we are calculating noise in worldSpace ( when condition is not meet) when we need it calculated in metaSpace ? A: thats purely because they haven't included a method to introduce the local translations of each metaball. I think for no reason expect as an example of a simple shader that doesn't include much. Thanks, it clears some fog from my eyes Take a look at the heavy smoke in the FX shelf, included with that is a shader that uses the local space of the metacloud as a coordinate system.hope any of this was helpful. Yeah, thanks again, I see how break and clamp should be done Edited May 11, 2008 by SWANN Quote Link to comment Share on other sites More sharing options...
Guest Swann Posted May 11, 2008 Share Posted May 11, 2008 (edited) I forgot that this shader calculates two types of smoke, per-point and normal and this is the reason why it calculates in the end smoke in worldSpace, just to make swimming effect for the smoke-cloud type. Edited May 12, 2008 by SWANN 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.