Hatching (pencil drawing) shader in OGRE

A place to show off your latest screenshots and for people to comment on them. Only start a new thread here if you have some nice images to show off!
Post Reply
User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel
x 76

Hatching (pencil drawing) shader in OGRE

Post 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
Watch out for my OGRE related tweets here.
User avatar
yuriythebest
Orc
Posts: 468
Joined: Sun Jul 10, 2005 11:44 am
Location: Kiev, Ukraine
Contact:

Post by yuriythebest »

looks nice, but how is this different from a pencil texture stretched across an ogre head? this is not a cell shader
asteroidWars - an OGRE game
NOOB MAKE MMORPG- the flash movie
User avatar
Paulov
Greenskin
Posts: 126
Joined: Tue Apr 04, 2006 5:18 pm
Location: San Sebastian / Europe
Contact:

Post 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
________________________________________
pablo vidaurre sanz
www.ikernor.com
User avatar
skullfire
Gremlin
Posts: 150
Joined: Sat Mar 19, 2005 7:51 pm
Location: San Jose, Costa Rica
Contact:

Post 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
I may have alzheimer, but at least I dont have alzheimer.
User avatar
yuriythebest
Orc
Posts: 468
Joined: Sun Jul 10, 2005 11:44 am
Location: Kiev, Ukraine
Contact:

Post 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?
asteroidWars - an OGRE game
NOOB MAKE MMORPG- the flash movie
User avatar
HexiDave
OGRE Expert User
OGRE Expert User
Posts: 1538
Joined: Sat Jan 14, 2006 8:00 pm
x 1

Post 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.
User avatar
BradSmithee
Gnoblar
Posts: 14
Joined: Fri Aug 25, 2006 8:55 am

Post 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.
User avatar
HexiDave
OGRE Expert User
OGRE Expert User
Posts: 1538
Joined: Sat Jan 14, 2006 8:00 pm
x 1

Post 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.
User avatar
CaseyB
OGRE Contributor
OGRE Contributor
Posts: 1335
Joined: Sun Nov 20, 2005 2:42 pm
Location: Columbus, Ohio
x 3
Contact:

Post 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?
Image
Image
User avatar
Kentamanos
Minaton
Posts: 980
Joined: Sat Aug 07, 2004 12:08 am
Location: Dallas, TX

Post 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
User avatar
yuriythebest
Orc
Posts: 468
Joined: Sun Jul 10, 2005 11:44 am
Location: Kiev, Ukraine
Contact:

Post 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???
asteroidWars - an OGRE game
NOOB MAKE MMORPG- the flash movie
User avatar
Borundin
Platinum Sponsor
Platinum Sponsor
Posts: 243
Joined: Fri Oct 03, 2003 5:57 am
Location: Sweden
x 2
Contact:

Post 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.
Image : Image
User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel
x 76

Post 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.
Watch out for my OGRE related tweets here.
User avatar
Jerky
Orc Shaman
Posts: 791
Joined: Wed Mar 02, 2005 4:13 am
Location: Springville, Utah
Contact:

Post 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.
Erik Briggs (Jerky)
My Blog
Project Wish
Image
User avatar
Falagard
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 2060
Joined: Thu Feb 26, 2004 12:11 am
Location: Toronto, Canada
x 3
Contact:

Post by Falagard »

Yup, they never replied.
User avatar
Assaf Raman
OGRE Team Member
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

Post 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.
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.
User avatar
sinbad
OGRE Retired Team Member
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

Post 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).
User avatar
Assaf Raman
OGRE Team Member
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

Post 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.
Watch out for my OGRE related tweets here.
Post Reply