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.
bsdf specular() question
4280 3 0- alexlstephan
- Member
- 13 posts
- Joined:
- Offline
- Mario Marengo
- 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.
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.
- alexlstephan
- 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?
- Mario Marengo
- 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.
-
- Quick Links