New LayeredBSDF and glossycoating material

Discussion related to the LuxRender Material system, programming API and Scene file format.

Moderators: jromang, tomb, zcott, coordinators

New LayeredBSDF and glossycoating material

Postby Lord Crc » Sat Oct 15, 2011 7:15 pm

edit: I split this into it's own thread, the old discussion is here: viewtopic.php?f=8&t=6961

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 :shock: :? :D
May contain traces of nuts.
User avatar
Lord Crc
Developer
 
Posts: 4455
Joined: Sat Nov 17, 2007 2:10 pm

Re: Small SchlickBRDF::SampleF question

Postby Lord Crc » Sat Oct 15, 2011 7:31 pm

I'm not sure how to properly handle specular base materials, for example mirror material.

I guess we could always sample the base, and if the sampled type was specular, use that direction. However I'm not sure how to take this into account in the Pdf function.

Alternatively I guess we could simple check NumComponents of the base, and always sample the base if there's a specular component there.

Thoughts? Perhaps tackle this later?
May contain traces of nuts.
User avatar
Lord Crc
Developer
 
Posts: 4455
Joined: Sat Nov 17, 2007 2:10 pm

Re: Small SchlickBRDF::SampleF question

Postby Lord Crc » Sat Oct 15, 2011 8:21 pm

Just a bit more complex setup, to illustrate possibilities as well as fun :)

edit: oh and thanks JtheNinja for the luxblend25 support.

Code: Select all
Texture "metalior" "fresnel" "preset"
   "string name" ["amorphous carbon"]

MakeNamedMaterial "metalbase"
   "string type" ["metal2"]
   "float uroughness" [0.012] "float vroughness" [0.012]
   "texture fresnel" ["metalior"]

MakeNamedMaterial "diffbase"
   "string type" ["matte"]
   "color Kd" [0.75000000 0.05000000 0.00500000]

TransformBegin
Scale 200 200 200
Texture "mixamount" "float" "checkerboard"
   "integer dimension" [3]   
TransformEnd

MakeNamedMaterial "mixbase"
   "string type" ["mix"]
   "texture amount" ["mixamount"]
   "string namedmaterial1" ["metalbase"]
   "string namedmaterial2" ["diffbase"]

MakeNamedMaterial "luxball"
   "string type" ["glossycoating"]
   "string basematerial" ["mixbase"]
   "color Ks" [0.1 0.1 0.1]
   "float uroughness" [0.015] "float vroughness" [0.015]
Attachments
layeredbsdf6.jpg
Glossy coating over a mix of amorpheous carbon and matte red material. 15 min, 85 S/p.
May contain traces of nuts.
User avatar
Lord Crc
Developer
 
Posts: 4455
Joined: Sat Nov 17, 2007 2:10 pm

Re: Small SchlickBRDF::SampleF question

Postby B.Y.O.B. » Sun Oct 16, 2011 12:20 am

Wow, that offers many new possibilities! Seems that this will be an alternative to the layered material, just for the cases when you only need a glossy coating (which are most of the cases I think, e.g. ceramics).
User avatar
B.Y.O.B.
 
Posts: 1882
Joined: Wed Nov 10, 2010 4:10 pm
Location: Germany

Re: Small SchlickBRDF::SampleF question

Postby Lord Crc » Sun Oct 16, 2011 1:37 am

B.Y.O.B. wrote:Wow, that offers many new possibilities! Seems that this will be an alternative to the layered material, just for the cases when you only need a glossy coating (which are most of the cases I think, e.g. ceramics).


Yes, indeed it's a much simplified version of that. However I think it will be useful for a lot of cases, especially since it's quite a lot faster. Here's another quick render (10 mins), this time two coating layers with bump map on the middle one only. The base layer is a fairly dark blue mattetranslucent. The material definition:
Code: Select all
MakeNamedMaterial "transbase"
   "color Kr" [0.0005000000 0.01500000 0.0500000]
   "color Kt" [0.005000000 0.01000000 0.02500000]
   "bool energyconserving" ["true"]
   "string type" ["mattetranslucent"]


TransformBegin
   Scale 100.0 100.0 100.0
   Texture "bumps.src" "float" "wrinkled"
TransformEnd
Texture "bumps" "float" "scale"
   "texture tex1" ["bumps.src"]
   "float tex2" [0.001]

MakeNamedMaterial "lowerlayer"
   "texture bumpmap" ["bumps"]
   "string basematerial" ["transbase"]
   "color Ks" [0.01 0.15 0.05]
   "float uroughness" [0.15] "float vroughness" [0.15]
   "string type" ["glossycoating"]

MakeNamedMaterial "luxball"
   "string basematerial" ["lowerlayer"]
   "color Ks" [0.02 0.02 0.02]
   "float uroughness" [0.015] "float vroughness" [0.015]
   "string type" ["glossycoating"]
Attachments
layeredbsdf10.jpg
Smooth non-colored coating over a green colored, wrinkled rough coating over a dark blue matte translucent base. 10 mins, 55 spp.
May contain traces of nuts.
User avatar
Lord Crc
Developer
 
Posts: 4455
Joined: Sat Nov 17, 2007 2:10 pm

Re: Small SchlickBRDF::SampleF question

Postby moure » Sun Oct 16, 2011 1:42 am

That looks great LordCrc :)
User avatar
moure
Developer
 
Posts: 411
Joined: Sun Sep 26, 2010 4:32 am
Location: Greece

Re: Small SchlickBRDF::SampleF question

Postby SATtva » Sun Oct 16, 2011 5:24 am

Lord Crc wrote:Here's another quick render (10 mins), this time two coating layers with bump map on the middle one only.

Awesome! :o
Linux builds packager
聞くのは一時の恥、聞かぬのは一生の恥
User avatar
SATtva
Developer
 
Posts: 5496
Joined: Tue Apr 07, 2009 12:19 pm
Location: from Siberia with love

Re: Small SchlickBRDF::SampleF question

Postby jeanphi » Sun Oct 16, 2011 7:43 am

Hi,

I can only repeat SATtva comment: awesome! Thanks a lot.
Let the fun begin :)

I think we should eventually ditch the old glossy materials and just translate them to the new infrastructure for compatibility.

I'll try to have a look at it next week.

Jeanphi
jeanphi
Developer
 
Posts: 6577
Joined: Mon Jan 14, 2008 7:21 am

Re: Small SchlickBRDF::SampleF question

Postby Lord Crc » Sun Oct 16, 2011 8:34 am

Thanks guys :)

jeanphi wrote:I'll try to have a look at it next week.


Great :)

I almost expect to have screwed up something related to the "reverse" and BxDF type flags. And then there's the case of specular base materials...
May contain traces of nuts.
User avatar
Lord Crc
Developer
 
Posts: 4455
Joined: Sat Nov 17, 2007 2:10 pm

Re: New LayeredBSDF and glossycoating material

Postby LadeHeria » Sun Oct 16, 2011 12:10 pm

Sorry for this question, but i don't understand, is this feature now in Luxrender ?


LadeHeria
LadeHeria
 
Posts: 129
Joined: Fri Aug 27, 2010 8:59 am

Next

Return to Materials, API & Scene file format

Who is online

Users browsing this forum: No registered users and 0 guests