Ok I'm gonna push what I have, since I'm not introducing any new files it's easy for us to shuffle things around as we see fit.
As mentioned the reason to accept a BRDF for the coating was so I wouldn't reimplement most of the SchlickBRDF in bxdf.cpp, and also hopefully make it general enough to make it accept some other BRDF's for the coating.
If we keep SchlickGlossyBRDF I was thinking we could refactor the three Schlick classes to reduce the amount of copypasta.
I didn't feel very confident implementing the LayeredBSDF, so it's not unlikely it's littered with mistakes. Especially handling all the flags and such made my brain hurt, as you can see from the various FIXME's.
However it does seem to reproduce the standard glossy material, and seems to work with other base materials, so something is at least not entirely wrong...
As mentioned earlier, I'm using a rather cheap heuristic for the sampling weights: I just use the specular reflection of wo as wi (ie H = n) when computing the coating BRDF weight. I then adjust the weight such that the coating is sampled between 50% and 100% of the time. This ensures the coating is not undersampled in case of a rough coating over a smooth base, and seems to work well in the tests I've used.
Anyway... how to use it. Consider the following plain glossy material:
- Code: Select all
MakeNamedMaterial "luxball"
"string type" ["glossy"]
"color Kd" [0.750 0.050 0.005]
"color Ks" [0.1 0.1 0.1]
"float uroughness" [0.015] "float vroughness" [0.015]
then this can be recreated using the new "glossycoating" material, which uses the LayeredBSDF, as follows:
- Code: Select all
MakeNamedMaterial "diffbase"
"string type" ["matte"]
"color Kd" [0.750 0.050 0.005]
MakeNamedMaterial "luxball"
"string type" ["glossycoating"]
"string basematerial" ["diffbase"]
"color Ks" [0.1 0.1 0.1]
"float uroughness" [0.015] "float vroughness" [0.015]
I intentionally left some commented code in the GlossyCoating material so you can switch between different BRDF's to experiment.
Comment or cry
