Jump to content

Cook-Torrance Model in Mantra Shader ?


Recommended Posts

The only BRDF available in mantra shader are Phong / Blinn / Cone . All those model sound pretty old school now. So i was wondering if what SESI call Phong and Blinn are really the old implementation ?

 

Or maybe they are using the more recent Energy-conserving Blinn-Phong model. But anyway i would like to use Cook-Torrance as my only Specular model for isotropic surface to simplify the shader. So as i am pretty new to mantra rendering and shading i would like to know if it looks possible to dive in the mantra shader and replace the Physically-Based-Specular node by my own vex node ? From a performance pov does it looks possible to you , or does it looks stupid or awkwards to modify something that already exist ...  :)

 

I've see that SYmek has already give a VEX code for this

http://forums.odforce.net/topic/6763-cook-torrance-shader-code-help-pls/?hl=%2Bcook+%2Btorrance

 

Maybe somebody has already done this in the mantra shader ? ... it would be wonderful if he can share it with me :)

 

Thanks in advance for any advise or any help!

 

Cheers

 

E

Edited by sebkaine
Link to comment
Share on other sites

Are you sure that bsdf specular phong () isn't some sort of micro-faced model? Because VEX's vector specular() is SESI's version of such (with some fixes).

 

Generally, albeit I might be completely wrong here as I've never seriously looked into physically plausible BRDFs (Mantra allows you to actually create one just recently), I think the problem is that not every old school phenomenological model is appropriate for PBR. First it needs to come with an importance sampling method and even though they provide a means to compute pdf/cdf, it might be impractical, expensive or they are not enough physically correct to justify those efforts. Here a hint for Cook-Torrence (page 18) which is also valid for Ward, which accidentally seems to be also widely adopted in PBR world.

 

For some reasons, probably because there are more plausible, people stick to Ward or BBX . If I'm correct, Cook-Torrence doesn't have to be the best option for micro-faced, nor VEX's is the worst.

Edited by symek
Link to comment
Share on other sites

Thanks for your answer SYmek !

 

Well honestly i am not sure of anything with VEX/Mantra , cause i am really starting to figure how things work in H for a good PBR workflow !

My concern is the Mantra Shader which i don't like so i try to modify it with my limited shading knowledge.

 

So my concern for the moment is to find a cool specular BRDF.

- I don't like the Phong model it really look Fake to me so no way to use this one :) !

- Blinn would be good enough but as i really want to lock the specular and reflection roughness together in my shader , i have problem when i go beyond a roughness of 30 it gives this black hemisphere behind the lighted area. So beetween 0-30 result are cool but beetween 30-90 i have the problem.

- Cone is not an option ...

 

so as none of these model looks to meet my goal i was trying to find a better model. Arnold use cook-torrance and it is quite popular model in the prman community. so i was thinking about this one... with no particular objective reason.

 

But after some research i find this :

http://forums.odforce.net/topic/11110-mia-material-vop-op/?hl=lafortune#entry72943

and a link to this

http://people.csail.mit.edu/wojciech/BRDFValidation/index.html

 

It's extremely interesting as it shows that Ashikhmin and Cook-Torrance are the 2 most accurate BRDF.

Moreover it looks that Ashikhmin is faster to compute than Cook-Torrance ...

Moreover Ashikimin can work in Isotropic and Anisotropic Mode ...

And the good news is that hidden in the abyss of the vex doc, we have this Ashikhmin model in Houdini !

 

The Ashikhmin is the most recent of all (2000). So it could be even better than Cook-T for speed/realism ratio.

So i'm gonna dig this way cause this Ashikhmin stuff look to be the answer to what i am searching for. The image in the docs looks really great ...

 

Question is , why do they use Phong and Blinn in the Mantra Shader , instead of this really cool model ? it's a mystery to me !  :)

Edited by sebkaine
Link to comment
Share on other sites

Ok, so, this is a nomenclature problem. Mantra Surface does use Ashikmin, and Phong and Blinn and pure specular, which in terms of PBR is hard reflection. Take a look into Physically Based Specular VOP - what code it generates. Basically, I think SESI tried to simplify names based on a behavior of a particular model, not its origin.

 

ps also I wouldn't be surprised if "phong" in VEX's phonglobe() was refering to Phong distribution and wasn't Phong reflectance model per se.

Edited by symek
Link to comment
Share on other sites

Thanks for precision SYmek you are right ! Ashikmin is use if you check the VEX code behind PBR specular node.

 

Anyway i still have weird behavior with specular. Again as i am very new to Mantra , i could be the source of the problem :).

I try to illustrate what i am expecting and what are the issue i have with the Specular BRDF in Mantra Shader.

 

I have take a simple sphere radius 5 and a point light with physicall attenuation

i have a shader that has only specular with a roughness at 90 and weight at 0.5.

i have compare Maxwell/Arnold/Mantra to illustrate the difference

 

The nicest behavior is with Maxwell. Arnold looks smooth.

But with mantra i have this sharp edges in the dark area.

 

I also try to test pure reflection without specular , with an emissive sphere.

i get nice smooth transition like in maxwell, but i can see clearly a sharp reflection of my sphere , which is really weird for a roughness 90 reflection ?

 

well again i could do something wrong so i have attach a scene just in case !

 

I will have to dive further into this specular model inside Mantra, to get what i expect ...

 

Thanks again for your time !

 

Cheers

 

E

post-6698-0-70151000-1388961842_thumb.jp

specular.hip

Link to comment
Share on other sites

I'm sure there is an explanation to this ;), which I'm clearly not aware of now (and can't fiddle with it atm). You may start with changing light type, because point light is really something that doesn't exist in nature and I hardly believe Maxwell bothers with it. I think it always uses some sort of of area light.

 

 

edit: attached image I got with changed light type to a grid. I also set angle to 30, and turned on fresnel. Interesting picture from Arnold though, as it shows as I presume physical implausibility of its model. See how the light leaks at glazing angles.

 

post-744-0-45322100-1388964077_thumb.jpg

Edited by symek
Link to comment
Share on other sites

I have come to the same conclusion at the moment ! :) to get this nice soft specular for rough surface, you can't exceed a roughness of 30. After that you will get this weird sharp transition.

 

My goal is to really have the surface roughness for specular and reflection to be the same value. and to not have 2 parameters for this (like SESI did ... by locking the 2 value by default ).

User shouldn't be able to modify something that wouldn't be possible in reality. But as the specular model look to only work from 0 to 30 , it won't do the job for the 30-90 range. so i see 2 possibility ...

- we are doing something wrong :)

- the physically-based-specular node is doing something wrong

 

Again if you look at this :

http://www.sidefx.com/docs/houdini9.5/vex/functions/ashikhmin

 

i'm quite sure that this can be the answer, cause this model look really smooth , so i'm gonna try to play with this now.

 

For the Arnold test, well my test is really quick and i'm no Arnold expert so i wouldn't take all this as valuable test ... I don't want any trouble with Arnold Fanboy here :)

 

But Arnold is using cook-torrance , if you check this you can read that :

http://renderman.pixar.com/view/cook-torrance-shader

http://renderman.pixar.com/view/brdf-comparision-movie

 

"Notice how the Cook-Torrance specular accurately models Fresnel reflectance at grazing angles, increasing the specular reflectance and distorting the highlight."

 

So in fact we can see this behavior at the grazing angles in my test, i don't have the scientific knowledge to say if it's good or not. But i agree my favorite behavior is the maxwell one , with this very subtle transition.

 

Cheers

 

E

Edited by sebkaine
Link to comment
Share on other sites

I've try to use directly ashikimin, it does have a very nice smooth transition with high roughness, but i still have this sharp edge problem. I've attach a scene to describe this. But with low roughness the specular stay very diffuse which is not coherent if i want to link it with my reflections. so Blinn is still the closer model to what i am trying to achieve.

 

i could use a blinn and remap his roughness with a fit(roughness,0,30,0,90). Thus i could have

- sharp specular + reflection at roughness 0

- very soft specular + reflection at roughness 90

But it will be a hack , and i would really like to understand why mantra behave like this before going the dirty way ...

 

i've attach the ashikimin test ! just in case !

ashikhmin.hip

Edited by sebkaine
Link to comment
Share on other sites

Again, this is highly speculative, as my knowledge isn't up-to-date, but differences with roughness may come from nomenclature. Isn't highlight angle in Houdini maximum incident angle of reflected light, while in Maxwell it's an apex of the solid angle, which is x2 bigger?

 

Secondly, yes Cook-Torrence has built-in fresnel term (another source of troubles with it), but Fresnel term doesn't increase intensity at glazing angle, it attenuates (down-size) intensity close to normals. So it shouldn't be brighter at glazing angles than in a specular model without fresnel applied. On the other hand, geometry term in micro-faced model should mask out specular intensity at glazing angles exactly how this is seen in Maxwell example. What you like in Maxwell example, according to that speculation, is shadowing of geometry term due to micro faces killing light reflected towards horizon (tangent).

 

ps cute site: http://simonstechblog.blogspot.com/2011/12/microfacet-brdf.html

Link to comment
Share on other sites

Thanks for this great link SYmek i'm actually looking at webGL and three.js at the moment looks really promising !

 

For cook-torrance you have a point , in fact i find clever to compute specular and reflection together and then apply the same fresnel function to both ( or not apply it ). So this is an argument for ashikimin and blinn-phong model ...

 

I'm quite sure houdini has all i need to make a nice shader , thing is you have to dive into the beast to get what you want.

I will post a scene as soon as i have find a solution that i find good enough .

 

I've attach a photo of what i am trying to achieve :

reflection + specular behave in a coherent way together when you modify the roughness of the surface from 0-90

( maxwell like quality ... :) )

 

Thanks again for your time SYmek !

post-6698-0-88740000-1389016772_thumb.jp

Edited by sebkaine
Link to comment
Share on other sites

Well after some extensive test , it looks that problem are more coming from behind the keyboard than from houdini ... :)

As you mention i compare light that are converted to area light in maxwell / arnold against a dirty old 90's era point light !

 

i've retry all with a square area light in physicall mode and i get very coherent result. so in my case the hard shape problem is coming from the point light.

I have test 3 things.

- pure reflection of a square with a constant shader that has exact same transform and scale than my area

- pure specular in phong + area light

- pure specular in blinn  + area light

 

I get the following result (cf attach).

 

It looks that Phong and Pure reflection behave in a very similar way at various roughness 0-90.

Blinn has a pretty different behavior and is not matching true reflection.

So Phong look to be the most physicall specular model by default ...

 

So Combining Phong + Reflection with exact same roughness is gonna be good enough for me . the thing is that to get coherent result we must stay with Physicall light and stay away of point and spot light i guess ... it's pretty normal after all ...

post-6698-0-84399700-1389022130_thumb.jp

Edited by sebkaine
Link to comment
Share on other sites

  • 2 weeks later...
  • 6 months later...

Hey guys, I have been fighting a lot with this very issue recently.

I was shading a characters skin lit by a sun light in reverse key (glancing), but because skin needs a wide faint lobe the result with Blinn is truly horrible. It looks like cell shading at glancing angles, but since roughness was set correctly for facing angle  I was kind of stuck between a rock and a hard place... In the end I had to rush a funky mix of Blinn and Phong, wasnt very happy with it at the time, but I have since done more work on it because its very very annoying.

 

The problem with Phong is that we know its a very wrong representation of rough surfaces in reality. The most obvious flaw is that it does not stretch highlights at glancing angle at all, unlike every rough surface in the real world. Blinn on the other hand does stretch highlights correctly so we know there is something fundamentally more right about it than Phong. This is great on flat surfaces, but in curved surfaces the stretched highlight is abruptly cut off at the terminator. I guess it follows that the artefact is due to inadequate shadowing/visibility/geometry term on the bsdf? Phong ironically does not have the same issue, although the highlight is warped this is far less objectionable than the cell shading look.

 

I made a shader that tries to combine Blinn and Phong such that I get what I like about each one where I think is more appropriate, see attached.

Basically I'm using view angle and curvature to blend between Phong and Blinn. 

Blurred reflections become glossier at glancing angle, so there is something in the shader to deal with that as the shading models appear to ignore this effect.

The roughness angle used ranges from 70 for the teapot through 40, 20, 0.

 

The hip

BlinnPhong.hip

 

Blinn is just horrible..

post-1495-0-66439900-1405870146_thumb.jp

 

Phong, no asthetic objections on curved surfaces, but the flat surface missing the all important stretched reflections.

post-1495-0-60280500-1405870717_thumb.jp

 

BlinnPhong Mishmash hack

post-1495-0-56190700-1405870749_thumb.jp

Link to comment
Share on other sites

Was messing around with Disney's brdf explorer, selected BlinnPhong and bingo, same as in mantra, but it comes with a toggle to "Divide by NdotL" if this is Off the sharp edge goes away. 

Mantra should really come standard with something better, like GGX. I'm in the process of figuring out how to process all the information and make my own GGX cvex bsdf... but it could be a while...

 

Ewww :(

post-1495-0-32893400-1405885039_thumb.jp

 

Ahhhh :)

post-1495-0-06788500-1405885073_thumb.jp

Link to comment
Share on other sites

Mantra should really come standard with something better, like GGX. I'm in the process of figuring out how to process all the information and make my own GGX cvex bsdf... but it could be a while...

 

 

Hi!

 

I have implemented GGX, not as a bsdf, but just a dumb old illuminance loop shader. It was for a client, though, so can't share without permission. It wasn't meant for production, mainly for material verification for realtime use.

Because of no bsdf smarts the noise properties were quite bad, so, as you said, it really should be a bsdf. Figuring out the correct sampling will take some doing, so, as you said, could be a while.. :)

 

Hopefully sesi beats us to the punch..

Link to comment
Share on other sites

yeah it would be great, I think I'll submit a RFE for GGx

 

Jason, have you tried the one I sent you yet?  I'm looking for a little bit of feedback before I upload it to the masses.  Less concerned about the GGX one than I am the Disney BSDF.  We've been using it in production for a while now but could always use another pair of eyes on it.

Link to comment
Share on other sites

 

The problem with Phong is that we know its a very wrong representation of rough surfaces in reality. The most obvious flaw is that it does not stretch highlights at glancing angle at all, unlike every rough surface in the real world. Blinn on the other hand does stretch highlights correctly so we know there is something fundamentally more right about it than Phong. This is great on flat surfaces, but in curved surfaces the stretched highlight is abruptly cut off at the terminator. I guess it follows that the artefact is due to inadequate shadowing/visibility/geometry term on the bsdf? Phong ironically does not have the same issue, although the highlight is warped this is far less objectionable than the cell shading look.

 

 

 

The fundamental difference between Houdini's Phong and Blinn is that Blinn's lobe is based around  the half vector (microfacet normal) where as Phong is just the light reflected across the surface normal (or whatever direction vector you passed in).  So the lobes themselves point in different directions while is why in your sample images you can see Blinn being cutoff at the terminator.  Also, the Blinn model is just a distribution, not a full microfacet model.  It lacks a builtin fresnel/shadow masking term.   :(

Edited by Wolfwood
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...