What!? NPR again? Hehe...but this time is more challenging~ The main focus of this demo is color distortion effect. The rendering result is quiet attracting(to me =P ).
This is another post-processing demo so as usual we will output the scene color to a texture. But for new edge detection effect, we will need the scene normal and depth as well. So we output the normal as "rgb" and depth as "a" into another texture. And after that we will use these textures to do the post-processing part.
Use this method to distort the color and make the output look like hand drawing. Steps are:
1. Downsample color texture into a smaller texture.
2. Convert from RGB to HSV color space and quantize color values. This color space conversion is done via a dependent lookup into a volume texture.
3. Sample the same image at 2 displaced positions; using 2 2D offset textures.
4. Compare the samples; if the samples are different enough, we output the average of them in S and V channels, keeping hue from the original center sample. This will effectively displaces image saturation and value at color boundaries.
5. Convert back from HSV to RGB using another volume texture lookup.
Before and after~
Differ from my old HLSL posts, this time we use pixel's normal and depth to find the edge; if the angle between the normals is big enough(45degree to me), we count it as the edge. Also we compare the difference of the pixel's depth; if the depth difference is big enough, we count it as an edge too. Below is the result i got. It got both silhouette and edge~cool!^_^)b
Result of edge detection~
Finally we combine all the results together and here we have~
Color Distortion + Edge Detection + Hatching~
The most ineteresting part of this demo is the color distortion. I was wondering if I modify the sampling textures, will I get any remarkable change from the result?^^ Oh, one funny part I found out was that I tried rendering the toon effect by first converting the RGB to HSV and adjusted the S and V channels. Because the H was not changed so the result will keep the same color but different saturation and value. The result color was alot softer than the older methods; no those dark and dirty colors~ take a look^_^
Top is old RGB method, Bottom one is the HSV result. What do you think?^^