bsdf specular() question

   4281   3   0
User Avatar
Member
13 posts
Joined:
Offline
Hi all
how do you get a roughness parameter properly working in the bsdf specular() function:

the followong code is not working as expected: (result is just diffuse shaded no spec high light at all), compiles fine.

float rough =.01;
vector nml,V;
V = -normalize(I);
nml = frontface(normalize(N), I);
F = (Cd * diff) * diffuse();
bsdf carp_bsdf = specular(nml,V,rough)*basecolor;
F += refl * (clampcolor / albedo(carp_bsdf)) * carp_bsdf;

the following is looking good, but I can`t adjust roughness

vector nml,V;
V = -normalize(I);
nml = frontface(normalize(N), I);
F = (Cd * diff) * diffuse();
bsdf carp_bsdf = specular(nml)*basecolor;
F += refl * (clampcolor / albedo(carp_bsdf)) * carp_bsdf;

I might just miss something obvious here.
User Avatar
Member
941 posts
Joined: 7月 2005
Offline
The function specular(nml,v,rough) returns a vector, not a bsdf – it is the old (non-pbr) function that produced VEX's custom specular model (with an implicit illuminance loop inside it). The PBR function that emulates it is matchvex_specular(nml,rough) which returns a bsdf as you expect.
The bsdf version of plain specular(vector dir) in the second example of your code, is intended to be used for *mirror* reflections (and dir is usually the direction of perfect “specular” reflection, not the surface normal), which explains why you couldn't adjust its roughness.


HTH.
Mario Marengo
Senior Developer at Folks VFX [folksvfx.com] in Toronto, Canada.
User Avatar
Member
13 posts
Joined:
Offline
and dir is usually the direction of perfect “specular” reflection, not the surface normal), which explains why you couldn't adjust its roughness.

thanks, that helps. however, I am not sure what direction of perfect “specular” reflection means" so I shouldnt use frontface(normalize(N), I) as an input?
User Avatar
Member
941 posts
Joined: 7月 2005
Offline
AlexStephan
so I shouldnt use frontface(normalize(N), I) as an input?

No, it would normally be:
vector R = normalize(reflect(I,N));
bsdf bsdf_refl = specular(R);

Though, of course, it could be anything you want, but that would be the mirror reflection, which is the typical usage.

P.S: I can't remember if reflect() needs the arguments normalized, but I don't think so… you should check anyway.
Mario Marengo
Senior Developer at Folks VFX [folksvfx.com] in Toronto, Canada.
  • Quick Links