How could I render 3D-hair with OpenGL?

How could I render 3D-hair with OpenGL?

Please get me some Information OR some websites’address about this.

Thanks first!

NVidia’s 6800 demo has hair:

You’ll probably want to use either a bunch of polygons or a bunch of lines; to get the shading right, you’ll probably want to use a fragment program.

Yes,I just want to use the B-Spline lines to render the hair.But I don’t knowe What should I do first.

Wow, there is 19 passes for the complete rendering :eek:

GPU Gems 2 has more details on how we did the hair in Nalu. The hardware requirements are a little steeper than the paper SirKnight posted, but I think the results are better. Although there were 19 passes for the complete demo, the hair can be done in just 2 passes (one for shadow map, one for regular rendering). It’s explained in the chapter.

Huh Ok, caustics, lighting and whatever are in the 19 passes (19 passe for realistic hair-rendering, ouch…)

Alright I think it’s time to grow some hair!

I recently purchased GPU Gems 2 and have read the nalu hair chapter a few times but it seems to me that this chapter should have been about a page or two longer. What it lacks is an explanation on how to compute the two lookup maps (that store the M and N terms) and where the math on page 374 is comming from. The latter doesn’t look hard, but I’m sitting here looking at it going…WTF!?

The first part of that “math page” says this:
“Instead of passing down theta[i] and theta[o] into the first lookup, we compute the sines: sin(theta[i]) = dot( light, tangent ), sin(theta[o]) = dot( eye, tangent). blah blah blah”

I’m probably being stupid but how are those two dot products the sin of theta[i] and theta[o]? Wasn’t a dot product a cosine? |A||B|cos(theta)…

The rest of the math from that point on looks ok as long as I can get past those sin things. I looked over the paper that first describes the reflectance model used here (Light Scattering from Human Hair Fibers) and after that I’m even more confused. :slight_smile:

So after I figure all this out, RogaineGL will be born! :smiley:


Hey. Sorry you found the chapter confusing. There was a lot of material to cram in. I worry that I didn’t quite do it justice.

The reason the dot products are sines is that theta is defined such that theta=0 is perpendicular to the hair (see the diagram in the paper). This is just a matter of convention, to be consistent with the paper.

A couple more things:
I just noticed that the pseudocode says cosThetaI and cosThetaO where it should say SinThetaI and SinThetaO. I hope that wasn’t contributing to your confusion. I am now officially kicking myself for letting that slip by.

Also, there is a freely available implementation of the Marschner et al reflectance model. And even better, it’s written in Sh :wink: .
It’s in the subversion repo under shrike/trunk/src/shaders/HairShader.cpp
Of course it doesn’t use lookup tables, but it’s a start. (Using this code you could even do a version that generates the lookup tables on the GPU!)

Ah ok thanks! The article was really good, it’s just that one part got me.

I’ll also be sure to write the typo fix on that page so it doesn’t confuse me at a later date. :slight_smile:

BTW, I was poking around the Nalu folder and I could not find the look up textures that looked like the ones in the book. Are they generated by the exe at runtime then deleted when the program closes?

Thanks for your help!

The textures are automatically generated at runtime and uploaded to the gpu, but are never saved out to disk. This allowed us to tweak the parameters at runtime and regenerate the textures.

I can’t get any of the recent nvidia demos to work at all on my machine…nalu, timbury or clear sailing. They all crash (debug/send report) just after changing the resolution and showing the splash screen. I’ve got a decent setup - geforce6800GT, 1.3ghz Athlon, 1gb SDRAM.
Tried all the nvidia drivers, no joy.
They’re the only apps I have problems running.
Any idea why they crash pragma? Seeing as though you were on the nalu demo dev team?
Is there a way I can generate a log file, like any other decent application?

Ok I thought they were generated, and it makes sense to do so as you say to changed parameters at run-time.

That’s weird that the nvidia demos are crashing for you. They work fine for me on my 6800 GT with all drivers I have used since I got this card. Although I never was able to run the timbury demo when I got this card, the sound was playing but I never saw a render and my HD was going mad. The demo was over and still going mad. Nalu starts to play music for about 15 seconds I think before the render shows.


With my 6600 all of the demos run, but the timbury one is like slideshow (after 1 minute startup), one picture every 5 seconds. Nalu and sailing demos look like >=15 fps, which is enough to say it’s realtime :stuck_out_tongue: