Hatching (pencil drawing) shader in OGRE
- Assaf Raman
- OGRE Team Member
- Posts: 3092
- Joined: Tue Apr 11, 2006 3:58 pm
- Location: TLV, Israel
- x 76
Hatching (pencil drawing) shader in OGRE
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:
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:
Watch out for my OGRE related tweets here.
- yuriythebest
- Orc
- Posts: 468
- Joined: Sun Jul 10, 2005 11:44 am
- Location: Kiev, Ukraine
- Contact:
- Paulov
- Greenskin
- Posts: 126
- Joined: Tue Apr 04, 2006 5:18 pm
- Location: San Sebastian / Europe
- Contact:
- skullfire
- Gremlin
- Posts: 150
- Joined: Sat Mar 19, 2005 7:51 pm
- Location: San Jose, Costa Rica
- Contact:
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
Other than that, WOW! 5 minutes.. hehe
I may have alzheimer, but at least I dont have alzheimer.
- yuriythebest
- Orc
- Posts: 468
- Joined: Sun Jul 10, 2005 11:44 am
- Location: Kiev, Ukraine
- Contact:
- HexiDave
- OGRE Expert User
- Posts: 1538
- Joined: Sat Jan 14, 2006 8:00 pm
- x 1
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:
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.
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.
- BradSmithee
- Gnoblar
- Posts: 14
- Joined: Fri Aug 25, 2006 8:55 am
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).if the pencil strokes change dynamically depending on light position then this is something good and I'l have a looksy. anyone tried this?
From the looks of the image, it seems to be ink outlines based from the depth and normals maps.GPU Gems 2 has a pretty awesome effect sort of like this called "Blueprint rendering and 'Sketchy Drawings'"
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.
- HexiDave
- OGRE Expert User
- Posts: 1538
- Joined: Sat Jan 14, 2006 8:00 pm
- x 1
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.From the looks of the image, it seems to be ink outlines based from the depth and normals maps.GPU Gems 2 has a pretty awesome effect sort of like this called "Blueprint rendering and 'Sketchy Drawings'"
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.
- CaseyB
- OGRE Contributor
- Posts: 1335
- Joined: Sun Nov 20, 2005 2:42 pm
- Location: Columbus, Ohio
- x 3
- Contact:
- Kentamanos
- Minaton
- Posts: 980
- Joined: Sat Aug 07, 2004 12:08 am
- Location: Dallas, TX
If you're referring to what I think you are, it's been discussed before:CaseyB wrote:Has anyone else actually downloaded this and noticed a familiar character in the videos?HexiDave wrote:The download is on chapter 15; the book is really great - recommended read for any game programmers.
http://www.ogre3d.org/phpBB2/viewtopic.php?t=12463
- yuriythebest
- Orc
- Posts: 468
- Joined: Sun Jul 10, 2005 11:44 am
- Location: Kiev, Ukraine
- Contact:
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???
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???
- Borundin
- Platinum Sponsor
- Posts: 243
- Joined: Fri Oct 03, 2003 5:57 am
- Location: Sweden
- x 2
- Contact:
- Assaf Raman
- OGRE Team Member
- Posts: 3092
- Joined: Tue Apr 11, 2006 3:58 pm
- Location: TLV, Israel
- x 76
http://www.ogre3d.org/phpBB2/viewtopic. ... 0a8e683adf
sinbad:
sinbad:
The Ogre head is one of the few exceptions, it was a free, uncredited mesh I found on TurboSquid.
Watch out for my OGRE related tweets here.
- Jerky
- Orc Shaman
- Posts: 791
- Joined: Wed Mar 02, 2005 4:13 am
- Location: Springville, Utah
- Contact:
- Falagard
- OGRE Retired Moderator
- Posts: 2060
- Joined: Thu Feb 26, 2004 12:11 am
- Location: Toronto, Canada
- x 3
- Contact:
- Assaf Raman
- OGRE Team Member
- Posts: 3092
- Joined: Tue Apr 11, 2006 3:58 pm
- Location: TLV, Israel
- x 76
Now there are CG, HLSL, and GLSL hatch materials for OGRE
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.
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.
Last edited by Assaf Raman on Wed Apr 11, 2007 10:15 am, edited 2 times in total.
Watch out for my OGRE related tweets here.
- sinbad
- OGRE Retired Team Member
- Posts: 19269
- Joined: Sun Oct 06, 2002 11:19 pm
- Location: Guernsey, Channel Islands
- x 66
- Contact:
Re: Now there are CG, HLSL, and GLSL hatch materials for OGR
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).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…
- Assaf Raman
- OGRE Team Member
- Posts: 3092
- Joined: Tue Apr 11, 2006 3:58 pm
- Location: TLV, Israel
- x 76
Re: Now there are CG, HLSL, and GLSL hatch materials for OGR
Sounds good.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).
Watch out for my OGRE related tweets here.