Hey All,
There are no resources for making light shaders anywhere, either as code or in a VOP.
I'd like to make an area light that has directionality control, similar to Vray and 3Delight.
So rays are not just cast in an increasing hemisphere from the center of the area light.
This can pull those rays more parallel, a very handy feature.
I've checked the math, it's entirely possible, but there seems to be nothing other than the actual
vfl files to go off from existing lights.
Does anyone has some knowledge they'd like to share?
Cheers
Lewie
Mantra Light Shaders
12257 29 2- lewis_T
- Member
- 246 posts
- Joined: March 2013
- Offline
- symek
- Member
- 1390 posts
- Joined: July 2005
- Offline
- jsmack
- Member
- 8035 posts
- Joined: Sept. 2011
- Online
I made a light shader with directionality before, but it's useless as the sampler has no idea about the light shader's bias. The more you increase directionality the noisier the image gets, until you get a black image with one or two hot pixels. If anyone knows how to teach the sampler about your light shader's importance distribution, it would make it far more viable.
- lewis_T
- Member
- 246 posts
- Joined: March 2013
- Offline
- jon3de
- Member
- 22 posts
- Joined: March 2014
- Offline
- YasinH
- Member
- 55 posts
- Joined: April 2019
- Offline
- jsmack
- Member
- 8035 posts
- Joined: Sept. 2011
- Online
- YasinH
- Member
- 55 posts
- Joined: April 2019
- Offline
jsmackThat's a bummer. Regardless of the noise issue, how would one implement its light material for Mantra?
Karma lights now include ‘focus’ or directionality controls. Sample distribution is still naive AFAIK though, so you can't make a laser, or even remotely approach laser-focus.
Edited by YasinH - Aug. 14, 2020 20:38:13
- jsmack
- Member
- 8035 posts
- Joined: Sept. 2011
- Online
YasinHjsmackThat's a bummer. Regardless of the noise issue, how would one implement its light material for Mantra?
Karma lights now include ‘focus’ or directionality controls. Sample distribution is still naive AFAIK though, so you can't make a laser, or even remotely approach laser-focus.
I don't know the math for the pdf of ‘directionality’ used by vray and the like, but the pdf for ggx is a nice gaussian distribution. And there's built in functions for getting the weight in a direction with a given focus exponent, as well as the integral over the pdf so you can normalize the power over the hemisphere. That's all I did when I added it lazily.
- YasinH
- Member
- 55 posts
- Joined: April 2019
- Offline
jsmackThanks for the explanation. I'm quite new to the VEX part of light materials. The built-in function you are referring to isYasinHjsmackThat's a bummer. Regardless of the noise issue, how would one implement its light material for Mantra?
Karma lights now include ‘focus’ or directionality controls. Sample distribution is still naive AFAIK though, so you can't make a laser, or even remotely approach laser-focus.
I don't know the math for the pdf of ‘directionality’ used by vray and the like, but the pdf for ggx is a nice gaussian distribution. And there's built in functions for getting the weight in a direction with a given focus exponent, as well as the integral over the pdf so you can normalize the power over the hemisphere. That's all I did when I added it lazily.
sample_hemisphere
and create_pdf
?
- YasinH
- Member
- 55 posts
- Joined: April 2019
- Offline
- jsmack
- Member
- 8035 posts
- Joined: Sept. 2011
- Online
YasinH
The built-in function you are referring to issample_hemisphere
andcreate_pdf
?
I think everything I needed was from the evalbsdf function. Sample functions are only needed for discreet samples (ray tracing). Since light shaders are continuous function, we only care about power scale in a given direction which is what the ‘eval’ argument of the evalbsdf function is. It may to be scaled by the pdf though, which is another argument of the same function.
YasinH
Also, would you recommend using VEX code(similar to Asad light) or just VOP nodes for the light material?
This is down to preference.
- YasinH
- Member
- 55 posts
- Joined: April 2019
- Offline
jsmackThis is super helpful! Thank you. Something I'm trying to figure out eval_bsdf requires a bsdf as its first argument, while a light shader doesn't inherently have a bsdf, does it? Or should I build a custom bsdf in the light shader?YasinH
The built-in function you are referring to issample_hemisphere
andcreate_pdf
?
I think everything I needed was from the evalbsdf function. Sample functions are only needed for discreet samples (ray tracing). Since light shaders are continuous function, we only care about power scale in a given direction which is what the ‘eval’ argument of the evalbsdf function is. It may to be scaled by the pdf though, which is another argument of the same function.YasinH
Also, would you recommend using VEX code(similar to Asad light) or just VOP nodes for the light material?
This is down to preference.
- jsmack
- Member
- 8035 posts
- Joined: Sept. 2011
- Online
YasinHjsmackThis is super helpful! Thank you. Something I'm trying to figure out eval_bsdf requires a bsdf as its first argument, while a light shader doesn't inherently have a bsdf, does it? Or should I build a custom bsdf in the light shader?YasinH
The built-in function you are referring to issample_hemisphere
andcreate_pdf
?
I think everything I needed was from the evalbsdf function. Sample functions are only needed for discreet samples (ray tracing). Since light shaders are continuous function, we only care about power scale in a given direction which is what the ‘eval’ argument of the evalbsdf function is. It may to be scaled by the pdf though, which is another argument of the same function.YasinH
Also, would you recommend using VEX code(similar to Asad light) or just VOP nodes for the light material?
This is down to preference.
Yeah, light shaders don't have their own bsdf normally. I'm abusing the ‘bsdf’ a generic function to get the mapping from angle to power. If you're using 18+ the ggx function can be used to create a ggx bsdf. Otherwise in pre-18 you'll have to use a cvex bsdf function.
- YasinH
- Member
- 55 posts
- Joined: April 2019
- Offline
jsmackInteresting. Here's part of what I have so far. But not getting anything meaningful out of it… I'm sure I'm missing couple things hereYasinHjsmackThis is super helpful! Thank you. Something I'm trying to figure out eval_bsdf requires a bsdf as its first argument, while a light shader doesn't inherently have a bsdf, does it? Or should I build a custom bsdf in the light shader?YasinH
The built-in function you are referring to issample_hemisphere
andcreate_pdf
?
I think everything I needed was from the evalbsdf function. Sample functions are only needed for discreet samples (ray tracing). Since light shaders are continuous function, we only care about power scale in a given direction which is what the ‘eval’ argument of the evalbsdf function is. It may to be scaled by the pdf though, which is another argument of the same function.YasinH
Also, would you recommend using VEX code(similar to Asad light) or just VOP nodes for the light material?
This is down to preference.
Yeah, light shaders don't have their own bsdf normally. I'm abusing the ‘bsdf’ a generic function to get the mapping from angle to power. If you're using 18+ the ggx function can be used to create a ggx bsdf. Otherwise in pre-18 you'll have to use a cvex bsdf function.
vector b; bsdf f = cvex_bsdf("diffuse_eval", "diffuse_sample", "label", "diffuse", "N", N); b = eval_bsdf(f, -I, normalize(L), pow(cos(radians(90)), 3), bouncemask("all")); L = normalize(b);
I'm just using “diffuse_eval” and “diffuse_sample” from here [www.sidefx.com].
- YasinH
- Member
- 55 posts
- Joined: April 2019
- Offline
- YasinH
- Member
- 55 posts
- Joined: April 2019
- Offline
Another question! (Sorry for the spam…)
I'm now trying to use the ggx bsdf for simplicity sake, but still not having much luck. That makes me wonder if I'm using the eval_bsdf output correctly. By altering the pdf in eval_bsdf coming from ggx, shouldn't it have some effect after multiplying to L? All I'm getting are mainly changes in light intensity, not its focus…
I'm now trying to use the ggx bsdf for simplicity sake, but still not having much luck. That makes me wonder if I'm using the eval_bsdf output correctly. By altering the pdf in eval_bsdf coming from ggx, shouldn't it have some effect after multiplying to L? All I'm getting are mainly changes in light intensity, not its focus…
- jsmack
- Member
- 8035 posts
- Joined: Sept. 2011
- Online
- YasinH
- Member
- 55 posts
- Joined: April 2019
- Offline
- jsmack
- Member
- 8035 posts
- Joined: Sept. 2011
- Online
singhharry12
I think everything I needed was from the evalbsdf function. Sample functions are only needed for discreet samples (ray tracing). Since light shaders are continuous function, we only care about power scale in a given direction which is what the ‘eval’ argument of the evalbsdf function is. It may to be scaled by the pdf though, which is another argument of the same function.
This was my theory, and I remember getting it to work before, but for some reason the light output seems uniform in all directions even when passing ‘L’ and ‘Lz’ to the eval bsdf function. I must be doing something wrong.
-
- Quick Links