Friday, April 12, 2013

Non-Photo realistic shading

Non-Photo realistic shading
There are different ways of shading a scene in a game. The scene does not always have to be realistic. Toon shading give a great effect if used properly. Toon shading is a post process that makes the colours have a ranges of large jumps and through another pass adds in a black border line around edges. The final result of the toon shader looks like a toon like image with outlines.

http://en.wikipedia.org/wiki/Cel_shading

On the first pass the we add in the toon shading part. This is done easily by sending in the fragments colour to a texture look up which will map that value to another. An easy but slow way to remap the frag colour is to send each component r,g,b floats in to the texture1D look-up.

Texture look up

On the second pass we want to add in the black borders. This is done by using any edge detection algorithm like the Sobel algorithm. You want to run this algorithm on both your normals and depth of the original scene to catch all of the edges. We use the normals and depth because large changes in their colour actually means an edge while using original images colour makes edges where colour change is present so not all the edges picked up would actually be an edge.


http://marctenbosch.com/npr_shading/

No comments:

Post a Comment