PDA

View Full Version : So what's up with the Cook Torrance shader?



Captain Obvious
03-05-2009, 10:04 AM
I've noticed that the Cook Torrance specular shader in Lightwave's node system, isn't actually a Cook Torrance shader. One of the neat things about the real CT shading method is that it produces really bright hotspots, as if it were an actual reflection of the light source. Lightwave's does not. Lightwave's CT shader seems to be clamped at 1.0 intensity, and then further modulated by the light's intensity and falloff. Compare this with a real Cook Torrance, where the middle of the hotspot can be in the 10-20 even when it's fairly soft, and higher still for small sharp highlights.

The same applies to certain materials, too. Delta, Conductor and Dielectric all use the same clamped Cook Torrance function.

I was wondering why I couldn't get as good specular highlights in Lightwave's materials as I could using my custom shaders or using other renderers, but I guess this would explain it.

Or have I just missed a setting? Is there a checkbox for "make specular highlights good"?

dwburman
03-11-2009, 12:17 PM
Is it clamped at 1.0 or is it a display limitation? What happens when you adjust the exposure in the image viewer after the render?

Captain Obvious
03-11-2009, 06:30 PM
It's clamped INSIDE the shader, oddly enough. Cook Torrance shaders should give outputs MUCH greater than 1.0, before being modulated by light intensity and color and stuff. However, Lightwave clamps the value and THEN it applies the light intensity, color, falloff, channel value, etc.

Simple test: Take a sphere or something with a CT shader on it. Make the highlight nice and wide, but so it still produces an area of complete white in the middle. Now reduce the intensity of the light. With real CT shaders, the white burnout in the middle should get smaller. In LW, it stays the same size, and just gets dimmer.

That is completely WRONG.

Lewis
03-11-2009, 06:34 PM
Do you maybe have Limit Dynamic Range ON ??

Captain Obvious
03-11-2009, 06:35 PM
Limit dynamic range takes place during the primary ray, not inside the CT shader.

Lewis
03-11-2009, 06:44 PM
Then how did you see it's clamped at 1.0? It has 3 options from what i see (Specularity, Glossyness, Bump Drop off) and each one can go upper than 100%.

Maybe "Ray cutoff" settings 0.01 has something to do with it also (dunno really I'm just trying to see if maybe you missed some function until Antti comes :))

Tobian
03-11-2009, 06:52 PM
Was just thinking about this earlier.. How about if you try and bypass the clamping issue my multiplying the value with 0.25 - then adding the results x4 together.. That way it shouldn't be operating in the clamping range till the lights get very bright (over 400%)... I think...? :) Worth a try!?

Captain Obvious
03-11-2009, 07:41 PM
No, that doesn't work either, because the clamping takes place inside the specular shader, before the final result is evaluated. Suppose that the CT shader is supposed to generate a specular gradient going from zero at the edges of the highlight to, say, 50 in the middle. Then you add texturing, light intensities and color, etc, to this thing, bringing the value down again. Now, the problem is that Lightwave doesn't give you a gradient from zero to 50 *it gives you the same gradient, clamped at 1.0, and THEN you can add all the texturing. Regardless of what you do, you still end up with a bit area in the middle where the value is the same throughout the whole "plateau."

Here are some examples. Lightwave gives you the bottom example, ALWAYS, regardless of what you do. And keep in mind that this clamping takes place BEFORE LW evaluates the color of the light, the falloff of the light, the texturing, etc. This means that a light that's far away and has a falloff actually produces a faint gray round blob.

Tobian
03-11-2009, 07:51 PM
OHH I get what you mean, and yeah I have noticed that, the hotspot has a plateau, and it shouldn't do, yeah can't say I like it either!

Tobian
03-11-2009, 08:03 PM
Yeah If you feed a gain node into a Blinn shader, to get a similar tight hotspot, and then fiddle with the exposure, the highlight extends into the high dynamic range, as it's (rightly) meant to be simulating something super bright! It's as if the Cook-torrence shader is built with it's own 'limit dynamic range' function! Bleh, i think Ill stick with Blinn! Interestingly enough, after trying Anisotropic, that work as expected too, so it's just cook torrence, which is annoying!

Captain Obvious
03-12-2009, 11:16 AM
The annoying thing is that all the Materials use Cook Torrance, and they all have the same problem. This basically means you can't get nice specular highlights on Materials, unless you use Michael Wolf's advanced material mixer to replace the specular with something else...

Lightwolf
03-12-2009, 11:30 AM
...unless you use Michael Wolf's advanced material mixer ...
Blender, not Mixer ;)

Does it blend? Yes! :D

Cheers,
Mike

Scazzino
03-12-2009, 12:45 PM
The annoying thing is that all the Materials use Cook Torrance, and they all have the same problem. This basically means you can't get nice specular highlights on Materials, unless you use Michael Wolf's advanced material mixer to replace the specular with something else...

Ever since first introduced I've had similar issues with specular highlights on the material nodes. I pretty much just stick to using the shader nodes instead. That way I have more control of the specular highlights when using non-GI lighting from standard LW lights.

Tobian
03-12-2009, 06:43 PM
Or there's the Material Blixer, not quite as uber as Mike's but it has efficiencies in it's design! :) It's very annoying they haven't broken out the tools inside the material nodes, such as a spec based on 'roughness', interpolated reflection, or an absorbtion node, as i would prefer to avoid materials, except they can be quite useful for some stuff, like the above tools!

toby
03-14-2009, 02:32 AM
I was just noticing another shader, Oren Nayer, seems to be backwards - a higher Roughness value makes it *less* rough, more like a pool que and less like the chalk.

Tobian
03-14-2009, 04:55 AM
I remember shaving off about 6 hours from a render because I switched out from Oren Nayer.. I couldn't actually see what it was doing! :D

toby
03-14-2009, 04:06 PM
That must've been a long freakin render!
Oren nayer is like, more diffuse than diffuse.
Almost makes lambert (right) look silvery

Tobian
03-14-2009, 04:35 PM
Haha all my renders take forever these days, since I use radiosity and reflection/refraction blur in all of them :D Yeah you can see the difference there, but sometimes it's really hard to see the difference if you add in ambient occlusion and environmental radiosity to the mix.

toby
03-14-2009, 06:29 PM
It's only good for a few things, and the difference is probably even less noticeable with gi since it's a difference in falloff; soft light sources won't really show it.

Captain Obvious
03-14-2009, 09:02 PM
Actually, it makes no difference at all. None of the diffuse shaders in Lightwave respect GI. Unless you have normal lights in your scene, all the diffuse shaders will look exactly the same.

toby
03-14-2009, 09:10 PM
I was hoping that wasn't the case, but after finding out that bump doesn't show up either... come on NT... why would they leave that out??

gerardstrada
07-14-2009, 12:23 PM
I've noticed that the Cook Torrance specular shader in Lightwave's node system, isn't actually a Cook Torrance shader. One of the neat things about the real CT shading method is that it produces really bright hotspots, as if it were an actual reflection of the light source. Lightwave's does not. Lightwave's CT shader seems to be clamped at 1.0 intensity, and then further modulated by the light's intensity and falloff. Compare this with a real Cook Torrance, where the middle of the hotspot can be in the 10-20 even when it's fairly soft, and higher still for small sharp highlights.

The same applies to certain materials, too. Delta, Conductor and Dielectric all use the same clamped Cook Torrance function.

I was wondering why I couldn't get as good specular highlights in Lightwave's materials as I could using my custom shaders or using other renderers, but I guess this would explain it.

Or have I just missed a setting? Is there a checkbox for "make specular highlights good"?

http://imagic.ddgenvivo.tv/forums/ESC/CTfix.png



Gerardo

Chuck
07-15-2009, 01:51 PM
Folks, if you have entered a Fogbugz report for any of the problems described, please post the bug number - not the link version please, just the case number itself.

If you have not entered a report, please do so, and post back the case number. We'll review the issues.

Edit: I did find one for the clamping in specular shaders. I've upped the priority on that and will make sure Antti looks at it for the maintenance update.

gerardstrada
07-15-2009, 02:12 PM
Excellent! Thank you!



Gerardo

P.D. Just for people whom want to try the previous workaround - the multiplicative value for the normal input in CookTorrance node should be higher than 1.0 when the specular intensity diminishes.

Captain Obvious
07-15-2009, 07:42 PM
Wait what? You're increase the amplitude of the normal of the surface? That should screw up the specular shading. Specular shaders generally require all vectors to be normalized.

gerardstrada
07-15-2009, 09:05 PM
Don't ask me why, but it works in this case. Do make a test.



Gerardo

gerardstrada
07-16-2009, 05:48 AM
Ok. Normals in CookTorrance specular model reacts in reverse way. When we multiply the normal surface we are, in fact, dividing the normals values. Intensity in other specular models increases, while in CookTorrance decreases. That's the reason why the above workaround works. Maybe the problem is an incorrect normalization (-1 to 1 instead of 0 to 1).



Gerardo

Captain Obvious
07-16-2009, 06:05 AM
Well, i'm currently lw-less, so i can't try it.

A Mejias
07-19-2009, 07:52 PM
Yes, please, report all these, bugs! I've been spending most of my time modeling and I've only used one or two of the material nodes in small areas, so I've not noticed these issues yet. But I know I'll be really frustrated when I do. :p

3dWannabe
07-23-2009, 09:32 AM
Um, stupid question above my pay grade, but ... do any of these issues change with FPrime or other renderers (Kray?).

I'm digging thru the LW v9 Lighting book, and trying to think ahead.

And will Radiosity get faster with 64 bit - or do you just have to throw more cores at it?

Captain Obvious
07-31-2009, 06:30 PM
Um, stupid question above my pay grade, but ... do any of these issues change with FPrime or other renderers (Kray?).

I'm digging thru the LW v9 Lighting book, and trying to think ahead.

And will Radiosity get faster with 64 bit - or do you just have to throw more cores at it?
Haven't tried with Kray or FPrime, but I can't imagine it would change anything. The problem lies inside the shader code, and it's the same regardless of your render engine.

It's important to note that FPrime and Kray do not try to replicate LW's node shaders — they use exactly the same code as Lightwave's renderer. Any* shader-specific bug you encounter in one renderer is likely to be present in the rest of them.

As far as 64-bit... it only matters in terms of memory usage. Buy more cores. Overclock.


* multi-threading issues aside

gerardstrada
07-31-2009, 10:35 PM
It means the workaround should work for those renderers, too :)



Gerardo

Captain Obvious
08-01-2009, 01:32 PM
It means the workaround should work for those renderers, too :)
Most likely, yes.

gerardstrada
02-10-2010, 01:31 AM
A useful tip from Weepul to improve this hack here (http://www.newtek.com/forums/showpost.php?p=984250&postcount=98) :thumbsup:



Gerardo

dpont
02-26-2010, 05:56 AM
There are a few variation arount the original
Cook Torrance Algorithm but the geometric
attenuation (which is clamped to 1.0) is
always the same, differences come in
the roughness distribution,
"Beckmann 1" is almost identical to LW node,
"Beckmann 2" near the original algorithm and much brighter,
"Gaussian" is totally different.
All modes include also a simple fresnel
factor.

A standalone win32 node for testing,
http://pagesperso-orange.fr/dpont/plugins/DP_CookTorrance_x32.zip

Denis.

Tobian
02-26-2010, 08:47 AM
That's pretty sweet Denis!

here's some gamma adjusted (LCS workflow) black test spheres, at 5% glosiness. The Beckman 2 falloff looks a little weird, as it hollows out in the centre, the Gaussian model looks.. weird! :D

That said it might still be physically accurate :D

dpont
02-26-2010, 10:04 AM
The Gaussian distribution needs to be fixed this is sure,
This model is still considered as an approach,
and Cook & Torrance approach is more based on physics
than mathematics.

Denis.

dpont
02-26-2010, 03:39 PM
I fixed weird specularity on the 'dark side',
the "Gaussian" mode is also smoother,
no change in the "Beckman 2" distribution.

Denis.

Tobian
02-26-2010, 03:54 PM
Yeah that's much nicer, same settings, on the Gaussian distribution. No idea what's 'physically accurate' but it looks nicer anyway hehehe

gerardstrada
03-02-2010, 01:52 AM
It looks excellent here in LCS! http://forums.cgsociety.org/images/smilies/bouncy.gif

http://imagic.ddgenvivo.tv/forums/CT/DP_CT.gif

Thank you very much, Denis!



Gerardo

cg_mike
04-25-2010, 11:41 PM
Hi,

DP Cook-Torrance appears to render with artifacts under radiosity when raytraced reflections are involved. Here's a simple example.

This is a radiosity render with DP Cook-Torrance on the objects in the center...
http://www.dmwi.net/images/ct_only.jpg

Now with Mr. Stanford Bunny. He surfaced with standard diffuse/specular and no reflection...
http://www.dmwi.net/images/ct_w_others_no_refl.jpg

And here with the addition of a simple incidence gradient for reflection on Mr. Bunny...
http://www.dmwi.net/images/ct_w_others_refl.jpg

Rendering in FPrime doesn't show the artifacts, but the shader doesn't quite work the same, either...
http://www.dmwi.net/images/ct_w_others_refl_fp.jpg

Finally, if DP Cook-Torrance is unplugged from the center objects and replaced with the LW native Cook-Torrance node...
http://www.dmwi.net/images/lw_ct_w_others_refl.jpg

Renders (besides the Fprime sample) are shown with interpolated Final Gather, but similar artifacts also occurred with interpolated MC.

dpont
04-26-2010, 01:08 AM
DP CookTorrance was a standalone node mainly for testing,
could be limited internally with a flag, but can't be sure
with your exact settings,
But do yout get artefact with DPKit Light Group node?

Denis.

cg_mike
04-26-2010, 05:51 AM
Thanks for the reply, Denis.

I might not be setting it up correctly. Is this right?
http://www.dmwi.net/images/dpkit_node_tree.gif

It seems to fix the problem.
http://www.dmwi.net/images/ct_w_dp_light_kit.jpg

dpont
04-26-2010, 06:38 AM
Your Light Group node is an older version
it has now both Diffuse Color and Specular Color ouputs
with a choice between different algorithms,
included Cook Torrance for specularity,
it can work like a simple shader with
all lights in the scene if you don't set a prefix.

About your settings, if you input a Diffuse Color,
then the normal Color input is overwritten.

Denis.

cg_mike
04-26-2010, 07:18 PM
Well that explains a lot! :D Time to update my dpont nodes...

Thanks, Denis! :thumbsup:

gerardstrada
02-06-2011, 03:58 PM
Pitifully not. But fortunately we have DP_LightGroup.
Thank you again, Denis! :beerchug:



Gerardo

Tobian
02-07-2011, 07:16 AM
It always makes me sad when you come in to a thread to check on a long standing bug, and, of course, it hasn't been fixed :(

lardbros
02-07-2011, 08:41 AM
Hmmmmmm.... it's a sad day! :(

This is why I struggle sometimes... I try and make something with my nodes, and always put it down to user error if I can't get something to work, when you guys are different, you are so clever you know what it should be doing, and blame the software because it's at fault! :)

Shame it hasn't been fixed!! Do many shader bugs get fixed at the mo? Antti is probably hard at work on CORE's nodal stuff!!!

stiff paper
05-02-2011, 08:25 AM
Umm... has anybody ever tried the AS Shader Node Blinn/Phong/CookTorrance/OrenNayar/Lambert plugin from this page?

http://www.neko.ne.jp/~asagi/P2P/Plugins/lay.html


Or to put it another way: Hey! Try this!
.
.

robpowers3d
05-02-2011, 12:31 PM
can anyone at nt read this and please fix. rob/matt/chuck/lino?

We are aware of this and are looking into it. :thumbsup:

lardbros
05-02-2011, 01:09 PM
We are aware of this and are looking into it. :thumbsup:

Good news... and thanks for the reassurance. Always great to hear that old issues are being looked into!

mattc
05-03-2011, 01:30 AM
Good news... and thanks for the reassurance. Always great to hear that old issues are being looked into!

Some NT folks were nice enough to take time out of their very busy schedule to look at this issue (including putting up with my very rusty matrix math skills) for a number of hours one night not too long ago.

(I wanted to give kudos to NT where it was warranted)

lardbros
05-03-2011, 06:42 AM
Some NT folks were nice enough to take time out of their very busy schedule to look at this issue (including putting up with my very rusty matrix math skills) for a number of hours one night not too long ago.

(I wanted to give kudos to NT where it was warranted)

Good stuff... and thanks to both you and Newtek for spending hours on the things like this!! It's very valuable... and shows, again and again, what a great community we have here!


Thanks!! :thumbsup:

Tobian
05-03-2011, 09:07 AM
Fantastic news Rob, glad this is being looked into. it's one of a number of niggles in the renderer which need resolving to achieve realism. Thanks to the Newtek Staff! :)

stiff paper
05-16-2011, 04:01 PM
So... nobody is actually interested enough in having working specular shaders that they've even bothered to try the node I linked to?

Huh.

mattc
05-17-2011, 04:14 AM
I think everyone is interested in getting the included nodes working....not to say a 3rd party node isn't useful or anything like that.

Captain Obvious
05-17-2011, 05:52 AM
So... nobody is actually interested enough in having working specular shaders that they've even bothered to try the node I linked to?

Huh.
Not interested enough to bother circumventing the fact that I got blocked from the website by some content filter bullmanure.

Tobian
05-17-2011, 08:46 AM
I haven't tested it, but tbh, I don't really bother much with spec as a rule these days. It has it's uses, but I got a bit sick of fighting it, so I haven't bothered for a while! :)

gerardstrada
05-17-2011, 08:56 PM
So... nobody is actually interested enough in having working specular shaders that they've even bothered to try the node I linked to?

Huh.
Don't know if you have even bothered to try the node you linked to, but at least here, the Cook-Torrance and Phong models don't provide correct results in their backlighting distribution. The effect is interesting (and might be used for some rim lighting effects) but the thing is that their highlight distribution and intensities in backlighting is not consistent with the direction of the incoming light according to the direction of the viewer.

We suppose that the farther we measure from the center of the highlight, the lesser will be the intensity of the highlight; but the Cook-Torrance node and Phong node (as well as their shader versions) don't behave as expected. There, the back highlight intensities are higher than the center of the highlight, besides, the light is reflected in angles where the surface normal is not oriented between the direction of incoming light and the direction of the viewer (specular highlight spreads in a 180 range). Both cases don't represent the specular reflection of real materials. This odd behavior can not be excused by a fresnel effect and it can't be solved with their highlight/IOR parameters (the highlight parameter is not present in the shader and none of these parameters are present in the Phong model where the situation is more acute).

Options are always welcome, but for more predictable results and more extensive usages, I prefer the LightGroup node from Denis Pontonnier :)



Gerardo

erikals
04-20-2012, 12:24 PM
evil bump, was the bug fixed?

Tobian
04-20-2012, 01:15 PM
Actually yes, well partly. the part of the bug which causes the shader to clamp has been removed, and I use this shader a lot now! :) However, the other half of the issue was matching lights/brightness etc, but that's more of an issue with LightWave's shading model for specular hotspots, so that part hasn't been fixed. That is not so much of a 'bug' though :)

No idea if the Oren-Nayer / Diffuse model bug with radiosity has been fixed? I tend not to use the diffuse shader models, as I am mostly using radiosity to light the scene :)

erikals
04-20-2012, 01:31 PM
well i'll give it 4 out of 5 then,... hehe!... \;]
that's good though :] thanks for informing.