Jump to content

why this vop is not working


kensonuken

Recommended Posts

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 by kensonuken
Link to comment
Share on other sites

  • 1 month later...

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 by kensonuken
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 by kensonuken
Link to comment
Share on other sites

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 by Alanw
Link to comment
Share on other sites

  • 2 months later...
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.

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