Page MenuHome

KajiyaKay shader
Closed, ArchivedPublicPATCH


Well LetterRip asked who was willing to try to implement a KajiyaKay

so here it is...

I did some renders.. it looked fine.. (but i can't notice very much difference.. all shaders look nice according to me)

I think light is working correctly at least it produces results similar to others shaders.

Maybe the correct way would be to implement some shader that has subsurface scattering into account.. (I'll try to look onto that if i have time)

(Also I'm not sure where we need a kajiyakay diffuse part.. probably other diffuse shader has the same behaviour..)

Note: both kajiyakay shader (diff and specular) assume they get a tangent.. this means applying one of those shaders to a surface that does not produces tangents is not advised...
So having "Use tangent shading" or "Tangent" options enabled is the right way of using this shaders.

Event Timeline

Hi Brecht, maybe you can have a look at this...

attaching an example of the hair with the shader applied

Well I attached images that better demonstrate the shader
(before the hardness was near 0.. now it was rendered with hardness=30)

Also attached the blend used for rendering the images.

hardness = 30
0005_shader.png => (strand->use tangent shading)
0005_v_shader.png => (strand->use tangent shading, tangent v)

Really interesting.
I remember a thing,really odd about hair shading.
Sometimes ago(I think 2 years ago)someone was working on an anisotropic shading for blender,no uv based.At that time Ton started working at the particles,he did the basic of the new particles shading and testing particles shading combined with that anisotropic shader give good result,if I remenber well better that how work now(the specular now is really difficoult to control is always to big).
If you want work on hair shading imho you should look here:
I have used a shader derived from this paper(daniel rind hair shader for mental ray)and work really well,I think is the way to go.
Btw,I'll try to test your patch as soon as possible.

any artist testing done?

Hi,I have done some test yesterday.It seems your diffuse shader is darker than other diffuse shader,that can be useful as hair are more specular than diffuse.
The specular seems strange,Blender specular shaders are more aligned to the perperdicular direction for the hair,it appears this shader rotate a bit that direction,it looks a bit odd(maybe it's more correct,I don't know).

feedback from harkyman

I tried the KK shader patch out last night with all of the characters in my animation. My first impression is that it probably produces more natural results for hair and fur than what I'm currently using. However, the lighting schemes and other material settings I've developed for my characters were really optimized for the shortcomings of the current shaders for use with hair. That said, I didn't have time to reconstruct everything and really optimize the situation for the KK shader. It clearly produces different results than shaders I was using, and if it had been available at the start of my project I almost certainly would have used it.

Here 2 images(only specular,same camera)on your test scene to explain better what I mean

Cook/Torrance specular


Cook/Torrance seems to me better.

Also just did a test with the attached blend file, disabling shadows and making all hairs use the same material. To me the specular highlights appear to be in the wrong place for Kajiya-Kay?


I tried 2 things on the KK shader..

1) I normalized the vars I receive on KajiyaKay_Spec
(I thought the vectors were already supposed to be unit but it turned out not to be true.. I reported it as a bug here:

2) It seems blender was converting back to vertex normal after calculating the diffuse part, this means the tangent used on diffuse is diferent from tangent on specular:
(I don't understand the reason behind this and it would be nice someone to explain me.. so that i can understand what tangent i should feed to the KK shader)

vn= shi->vn; // bring back original vector, we use special specular shaders for tangent
if(ma->mode & MA_TANGENT_V)
vn= shi->tang;

Here are the outputs:

kk shader:

normalized vars and using same tangent as diffuse:

and using the tangent that other specular shaders use:

Still I don't know why specular shaders use other tangents, I'd really like to know.. to better understand if the shader is still giving wrong results :S

Closing inactive report. Andre: please re-open when there's a working patch you like to present.

Ton Roosendaal (ton) changed the task status from Unknown Status to Unknown Status.Sep 19 2008, 4:32 PM