kensonuken Posted January 11, 2009 Share Posted January 11, 2009 (edited) Im trying to insert multiple illumination models in this illum loop but its not working and showing some error.. Im trying to debug it but couldnt solve it... pls help me.. PerlightIllumLoop.hipnc Edited January 11, 2009 by kensonuken Quote Link to comment Share on other sites More sharing options...
vmuriel Posted January 11, 2009 Share Posted January 11, 2009 (edited) You have connected a 3 vector data (Specular.clr) to simple float inputs (floattovec.fval1, 2, 3). You can connect Specular.clr to exp_perlight_spec.input directly. Edited January 11, 2009 by vmuriel Quote Link to comment Share on other sites More sharing options...
kensonuken Posted January 12, 2009 Author Share Posted January 12, 2009 I tried connecting directly... Its not working.. can u edit and upload the file ? Quote Link to comment Share on other sites More sharing options...
Jason Posted January 12, 2009 Share Posted January 12, 2009 I tried connecting directly... Its not working.. can u edit and upload the file ? Once you fix the datatype issue vmuriel mentioned, you see an "Illuminance clauses cannot be nested" error. So, looking further I see you have put a Specular VOP inside of the illuminance loop - and that itself uses an illuminance loop (ie, it's designed to loop through lights itself to calculate total specular). I think you're trying to use the PBJ Specular VOP instead, no? Quote Link to comment Share on other sites More sharing options...
kensonuken Posted January 13, 2009 Author Share Posted January 13, 2009 yeah PBJ has only Phong function in It but Im trying to work on multiple spec models like gloss, Blinn etc.. Quote Link to comment Share on other sites More sharing options...
Jason Posted January 13, 2009 Share Posted January 13, 2009 yeah PBJ has only Phong function in It but Im trying to work on multiple spec models like gloss, Blinn etc.. You're going to have use VEX functions which don't explicitly (like vop_specular() from the Specular VOP) or implicitly (like specular(), blinn(), etc) use illuminance() loops. You'll have to use the *BRDF functions, like specularBRDF(), blinnBRDF(), phongBRDF(), diffuseBRDF(), or do your own math for the BRDF you're after. You can easily extract that math from illuminance loops from the multitudes of blinn, glossy, cook, etc functions out there. Take a look in the Advanced Renderman Companion, for instance. Does that make sense? Jason. PS. Something you may not know: if you have unconnected VOPs in your VOP networks, the code for those function still gets output into the shader source-code. So you may not be using it but it still is causing compilation failures because it appears in the source code anyway. Quote Link to comment Share on other sites More sharing options...
kensonuken Posted January 18, 2009 Author Share Posted January 18, 2009 (edited) yeah now i got this code.. color vop_glossy(normal nn; vector V; float rough, sharp) { float w = sharp/2.0; float NdotL, spec; float NdotI = vop_dot(nn, V); color illum = 0; if (NdotI > 0.0 && w < 0.5) { illuminance(P, nn, PI/2) { vector nL = normalize(L); NdotL = vop_dot(nn, nL); if (NdotL > 0.0) { float nonspec = 0; lightsource("__nonspecular", nonspec); spec = (1-nonspec)*comp(specularbrdf(nL, nn, V, rough), 0); if (w <= 0) illum += Cl * spec; else { float tmp_w = 1-w; illum += Cl * (float vop_smooth(w, tmp_w, spec, 1)); } } } } return illum; } so now which part should I use ? I believe this part.. vector nL = normalize(L); NdotL = vop_dot(nn, nL); if (NdotL > 0.0) { float nonspec = 0; lightsource("__nonspecular", nonspec); spec = (1-nonspec)*comp(specularbrdf(nL, nn, V, rough), 0); if (w <= 0) illum += Cl * spec; else { float tmp_w = 1-w; illum += Cl * (float vop_smooth(w, tmp_w, spec, 1)); } } Edited January 18, 2009 by kensonuken Quote Link to comment Share on other sites More sharing options...
Jason Posted January 19, 2009 Share Posted January 19, 2009 Yeah, you're on the right track there Quote Link to comment Share on other sites More sharing options...
kensonuken Posted March 10, 2009 Author Share Posted March 10, 2009 (edited) I tried with the illum loops in the voplib files but getting errors.. PerlightIllumLoop_v0001.hipnc Edited March 10, 2009 by kensonuken Quote Link to comment Share on other sites More sharing options...
kensonuken Posted March 10, 2009 Author Share Posted March 10, 2009 (edited) I tried to add the shader into the inner and outer code but im getting the errors stating that some color variable is not right... there is some error at the following code... color vop_glossy(normal nn; vector V; float rough, sharp) { float w = sharp/2.0; float NdotL, spec; float NdotI = vop_dot(nn, V); color illum = 0; } I couldnt understand where the prob is.. Edited March 10, 2009 by kensonuken Quote Link to comment Share on other sites More sharing options...
Jason Posted March 10, 2009 Share Posted March 10, 2009 I tried to add the shader into the inner and outer code but im getting the errors stating that some color variable is not right... there is some error at the following code... color vop_glossy(normal nn; vector V; float rough, sharp) { float w = sharp/2.0; float NdotL, spec; float NdotI = vop_dot(nn, V); color illum = 0; } I couldnt understand where the prob is.. There is no type called "color" in VEX. Colors are represented by "vector" types. Same with "normal" types. Quote Link to comment Share on other sites More sharing options...
kensonuken Posted March 10, 2009 Author Share Posted March 10, 2009 (edited) edited with color changed to vector Outer code vector vop_glossy(normal nn; vector V; float rough, sharp) { float w = sharp/2.0; float spec; float NdotI = vop_dot(nn, V); color illum = 0; } Inner Code vector nL = normalize(L); NdotL = vop_dot(nn, nL); if (NdotL > 0.0) { float nonspec = 0; lightsource("__nonspecular", nonspec); spec = (1-nonspec)*comp(specularbrdf(nL, nn, V, rough), 0); if (w <= 0) illum += Cl * spec; else { float tmp_w = 1-w; illum += Cl * (float vop_smooth(w, tmp_w, spec, 1)); } } Still getting errors stating that color Illum = 0; and couple of multiple declarations like w , spec but i have declared spec only once.. Edited March 10, 2009 by kensonuken Quote Link to comment Share on other sites More sharing options...
kensonuken Posted March 14, 2009 Author Share Posted March 14, 2009 pls help me.. Quote Link to comment Share on other sites More sharing options...
Alanw Posted March 16, 2009 Share Posted March 16, 2009 (edited) This code still has color and normal types from RSL. As mentioned before you should make these vector. Outer code vector vop_glossy([b]normal[/b] nn; vector V; float rough, sharp) { float w = sharp/2.0; float spec; float NdotI = vop_dot(nn, V); [b]color[/b] illum = 0; } like this. Outer code vector vop_glossy(vector nn; vector V; float rough, sharp) { float w = sharp/2.0; float spec; float NdotI = vop_dot(nn, V); vector illum = 0; } Edited March 16, 2009 by Alanw Quote Link to comment Share on other sites More sharing options...
kensonuken Posted May 22, 2009 Author Share Posted May 22, 2009 (edited) The code is changed the type from color to vector but its not working pls help me... Im just getting confused with these illum loops.. In rsl i could do it quickly but i dont know where things are messing up... Gloss__PerlightIllumLoop_v0001.hipnc Edited May 23, 2009 by kensonuken Quote Link to comment Share on other sites More sharing options...
kensonuken Posted May 23, 2009 Author Share Posted May 23, 2009 (edited) its stating that multiple declarations have been done... Edited May 23, 2009 by kensonuken Quote Link to comment Share on other sites More sharing options...
Jason Posted May 24, 2009 Share Posted May 24, 2009 its stating that multiple declarations have been done... If you have multiple instances of the same node that defines the same function declaration in the OuterCode, (take a look by doing a "View vfl Code") you will have a naming conflict. There are 3 ways to make this work: If you use a $ sign in front of the function name, VOPs will dynamically change that function name to make it unique at vfl generation time. So basically you end up with many functions inside your vfl which do the same thing, but named differently. You may have noticed that the $ sign works with variable names throughout VOPs; it works with function names too. This is a legal approach, is the easiest solution and should work for you just fine. However it might affect your compile-time performance if there are too many of them (there would have to be a *lot*) or just plain bug you, conceptually Extract the function into an external #include file. You will have use "guards" - those #ifdef/#define/#endif blocks that shield functions from being included more than once. Look at voplib.h, or any of those *.h files in the distribution for how to do that. The problem which this approach is that the .h file is external to the .otl file and so it becomes a bit more of a management issue. It also can be a very useful way for many VEX shaders to use the same library function. Use a "guard" directly in your OuterCode section - guard your function right there. If you do this, please try name your OuterCode functions something as unique as possible to make sure you don't clash with OuterCode functions of the same name from other vops. eg, if you have two different VOP types which define makebrighter() - there is nothing to say that these functions do the same thing at all - they just have the same name. If you name them more uniquely, you'll have a lower chance of a clash. 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.