Page 1 of 1

Hatching (pencil drawing) shader in OGRE

Posted: Sun Jan 07, 2007 9:36 pm
by Assaf Raman
I think Hugues Hoppe is one of the most talented people in the field of computer graphics.

I always loved his article about “Real-time hatching”: http://research.microsoft.com/~hoppe/hatching.pdf

When I saw that ATI has included something similar in Render Monkey – I just had to see the ogre head with that shader.

5 minutes after I have created the Hatch.material file – I had the sample working. OGRE has such a great material system.

Here is the material file if you want it: http://assaframan.googlepages.com/Hatch_material.zip

And here are the screenshots:
Image
Image
Image

Posted: Sun Jan 07, 2007 10:54 pm
by yuriythebest
looks nice, but how is this different from a pencil texture stretched across an ogre head? this is not a cell shader

Posted: Sun Jan 07, 2007 10:57 pm
by Paulov
Hi
Jeh Yuri, I wask asking myself the same.

I think it may have a denser pencil line concentration in the shadowed areas.

Bye_

PablO

Posted: Sun Jan 07, 2007 10:58 pm
by skullfire
This looks great! Nice work! The only downside I see is the fact that the Ogre head is not the best display model, mainly because the UV is not that well unwrapped. There's a lot of warping going on that surely does not contribute to the hatching technique.
Other than that, WOW! 5 minutes.. hehe

Posted: Mon Jan 08, 2007 12:04 am
by yuriythebest
Paulov wrote:Hi
Jeh Yuri, I wask asking myself the same.
I think it may have a denser pencil line concentration in the shadowed areas.
th same occured to me: if the pencil strokes change dynamically depending on light position then this is something good and I'l have a looksy. anyone tried this?

Posted: Mon Jan 08, 2007 2:33 am
by HexiDave
GPU Gems 2 has a pretty awesome effect sort of like this called "Blueprint rendering and 'Sketchy Drawings'" - here's a scan of one of the shots:

Image

The right-hand shot is the final product. Here's the link to the CD files:
http://download.nvidia.com/developer/GP ... Index.html

The download is on chapter 15; the book is really great - recommended read for any game programmers.

Posted: Mon Jan 08, 2007 2:59 am
by BradSmithee
if the pencil strokes change dynamically depending on light position then this is something good and I'l have a looksy. anyone tried this?
NPR Hatching techniques are based on the concept that one or many textures will be used as a substitution technique on less lit areas. Areas closer or more direct to the light will usually be pure white whilst areas farther away can get a user-defined amount of texture steps (typically 1-5).
GPU Gems 2 has a pretty awesome effect sort of like this called "Blueprint rendering and 'Sketchy Drawings'"
From the looks of the image, it seems to be ink outlines based from the depth and normals maps.

There are a literal TON of NPR techniques and research papers available online and a gross quantity of them has yet to be implemented. The project I'm working with now has plans to research and implement a large portion of these techniques via pixel shaders.

Posted: Mon Jan 08, 2007 3:11 am
by HexiDave
GPU Gems 2 has a pretty awesome effect sort of like this called "Blueprint rendering and 'Sketchy Drawings'"
From the looks of the image, it seems to be ink outlines based from the depth and normals maps.

There are a literal TON of NPR techniques and research papers available online and a gross quantity of them has yet to be implemented. The project I'm working with now has plans to research and implement a large portion of these techniques via pixel shaders.
Yep, that's pretty much it - basically uses depth at a few levels to build a few layers, then does edge-detection and builds from there. Doesn't look too hard to implement.

Posted: Mon Jan 08, 2007 8:01 am
by CaseyB
HexiDave wrote:The download is on chapter 15; the book is really great - recommended read for any game programmers.
Has anyone else actually downloaded this and noticed a familiar character in the videos?

Posted: Mon Jan 08, 2007 8:26 am
by Kentamanos
CaseyB wrote:
HexiDave wrote:The download is on chapter 15; the book is really great - recommended read for any game programmers.
Has anyone else actually downloaded this and noticed a familiar character in the videos?
If you're referring to what I think you are, it's been discussed before:
http://www.ogre3d.org/phpBB2/viewtopic.php?t=12463

Posted: Mon Jan 08, 2007 1:09 pm
by yuriythebest
ahah, so to recap the ogre head (dunno why everyone is afraid to speak it out loud :) ) is made by digmation and actually comes with the body and is sold for 500 something dollars.

Now I'm sorta confused, did sinbad actually buy that head for that insane amount? Was it a gift by its creators? Did someone create the head and then sell it to digmation and also give it away to sinbad? whaa???

Posted: Mon Jan 08, 2007 5:19 pm
by Borundin
I think the entire model including body, arms etc costs 500 dollars. Just the head was given away for free on TurboSquid if I remember correctly from one of Sinbads posts.

Posted: Mon Jan 08, 2007 5:43 pm
by Assaf Raman
http://www.ogre3d.org/phpBB2/viewtopic. ... 0a8e683adf

sinbad:
The Ogre head is one of the few exceptions, it was a free, uncredited mesh I found on TurboSquid.

Posted: Mon Jan 08, 2007 8:14 pm
by Jerky
Not to Hijack, but that model was of the whole body iirc, not only the head. Last I remember, Falagard contacted them regarding it. From what I remember, they never responded to his inquiries regarding that model, or where they got it.

Posted: Mon Jan 08, 2007 8:40 pm
by Falagard
Yup, they never replied.

Now there are CG, HLSL, and GLSL hatch materials for OGRE

Posted: Sun Jan 14, 2007 2:26 am
by Assaf Raman
I have converted the HLSL sample of hatching from Render Monkey to OGRE.
Then I have converted the HLSL code to CG code.

So now there are CG, HLSL, and GLSL materials for OGRE.

The hardest part of converting the code from Render Monkey to OGRE was the register mapping. It took me hours to discover that I was missing that. More over - there is no error if you don't map the register -the only thing that happens is that your sample doesn't work correctly.

Also - you can see the difference between HLSL and GLSL in the OGRE material - in GLSL you need to map the textures with "param_named" (it will not work without the "param_named") and in HLSL you will get an error if you map.

I have updated the file you can download in my first post in this thread so you can just download it.

Re: Now there are CG, HLSL, and GLSL hatch materials for OGR

Posted: Sun Jan 14, 2007 6:02 pm
by sinbad
Assaf Raman wrote:Also – you can see the difference between HLSL and GLSL in the OGRE material – in GLSL you need to map the textures with “param_named” (it will not work without the “param_named”) and in HLSL you will get an error if you map…
Yes, this is a GLSL-specific thing. You cant assign the texture samplers inside the shader like you can in Cg & HLSL so you have to do it outside. I tend to put this in the default_params in the shader definition then it doesn't clutter your actual material. Plus in Eihort you can use a 'unified' program definition combined with this so that you can use the same technique for both HLSL and GLSL (our HDR and skeletal animation shaders demonstrate this).

Re: Now there are CG, HLSL, and GLSL hatch materials for OGR

Posted: Sun Jan 14, 2007 6:20 pm
by Assaf Raman
sinbad wrote:...in Eihort you can use a 'unified' program definition combined with this so that you can use the same technique for both HLSL and GLSL (our HDR and skeletal animation shaders demonstrate this).
Sounds good.