View Full Version : Toon Shading in Messiah
lafnjack 07-12-2005, 09:25 AM Hi all,
I'm looking for a good toon shader. I know Messiah has toon shading, but haven't seen any examples. Is it any good? Are there any examples online? I haven't been able to find any.
Much thanks!
lafnjack
|
|
Suricate
07-13-2005, 01:13 PM
Hi lafnjack,
at Zoogono.com in the 'Materials' section there are some toon materials. Basically you need a custum shader node with a stepped gradient for the fill colour of your surface and an camera fresnel node for the edges. The problem is that you cannot get an fixed-width-edge like that. I have been programming an edge shader plug-in that can do that, but it will take some some time until it is finished. Attached are a few images made with an early version of that plug-in.
lafnjack
07-13-2005, 07:05 PM
Thanks for the tip-off! Much appreciated... And good luck with that plug-in. Those earlier renders look pretty good!
lafnjack
ThomasHelzle
07-14-2005, 11:25 AM
Hi Suricate,
that shader looks great - are you using an image filter for the outline? :thumbsup:
Cheers,
Suricate
07-14-2005, 01:09 PM
Hi Thomas,
I knew this would catch your interest :) .
I have been doing some research on NPR recently and have been wondering on what could be achieved within messiah and the SDK. I tried different methods to get those edges and wireframes (for the wireframes, I also tried using the UV coordinates as you presumably did in your shader, but then it is difficult to achieve fixed-width-lines). The most flexible method for drawing edges would be indeed a pixel filter and an algorithm like this:
1. Scan the image and detect those pixels that are on an edge (an edge would be a pixel that borders two different polygons/surfaces/objects etc.)
Now you could simple colour these pixels as black and output them. The problem then is that the edges wouldn't be anti-aliased. Of course a solution would be to render at a higher resolution and then downsample the render. A more general way would be:
2. Construct 2D splines from the edge pixels you have detected in step 1. According to literature, you can use Catmull-Rom splines for that.
3. Use the splines to draw anti-aliased lines. You can also use the splines to achieve different effects like overshooting lines or general stylization.
I didn't go that way, since steps 2 and 3 seem to be rather complex. Besides, in the messiah SDK the function 'fxBufferSampleObject' seems to be broken (the 'surfID' and 'polyID' values always return 0).
Instead, in the examples above I used a material shader. When the shader is evaluating, it would cast some rays with a slight offset along the X- and Y-axis from the camera origin (if the camera ray is pointing along the Z-axis). If one of these sample rays hits a different polygon/surface/object, the originally sampled point is an edge point. That way the shader can use messiah's anti-aliasing. The downside of this method is that you can only draw simple edges like this, not the fancy stuff described in step 3 above. Another problem occurs if the edge width is large in comparison to the object's edges. Then some artefacts would show up, unless you use more samples (which would increase the general rendering times). I'm currently investigating this problem, but haven't found a convincing solution so far.
ThomasHelzle
07-14-2005, 02:13 PM
Hi Suricate,
very interesting indeed - this basically sums up my own findings on the matter.
But I always wanted to try an edge detection filter on the depth channel - that should give a rather smooth and natural looking line effect even as a pixel filter (but you can do that in post already).
Another way would be to test for differences of the surface normal to catch creases.
Also, if you use the geometric normal and compare it to the smoothed normal, you can get some interesting stuff.
I am not surprised that some functions of the SDK don't work for you. This is far too often the case and has taken a lot of the initial fun and stride out of the process for me.
Since pmG isn't willing to fix such stuff within short amounts of time between major releases, I basically dropped development for messiah completely for now until maybe later versions improve the SDK. I also still wait for Develop since 2002. :cry:
As for using the UVs for Wireframes: you can calculate the real size of the current subdivided polygon (point to edge-length), set it in relation to the UV values and find correct sizes that way - that is what I did in my (still unfinished) Wireframeshader. Since the UVs are the only reliable way to reconstruct the main mesh on the subdivided surface I have found, it is worth the trouble IMO.
The spline approach would be supercool. Not only could you work on those some more (wiggle them, change thickness depending on depth or surface direction) but also you would be able to export vector data... (Flash/EPS)
And another option would be to multiply the splines with different stroke attributes to move in the direction of the Tomcat shader that uses Maya Painteffects for that.
But I have never in my life worked with splines myself so this is only dreaming ;-)
Do you know Jot? They use splines and quite advanced algorithms to prevent popping in animation.
http://jot.cs.princeton.edu/
It wasn't updated for ages but it would be perfect for me - draw a line by hand in the interface and use that as lines on the object... it already works with lightwave (so you can also use it with messiah) but it is rather cumbersome. An example I did long ago:
http://www.screendream.de/stuff/MaXX_Rendered_With_JOT_NPR.gif
...and a rather stupid animation - just a test really ;-)
http://www.screendream.de/stuff/MaXX_rendered_with_jot_anim.gif
I found this site rather interesting for links about NPR:
http://www.red3d.com/cwr/npr/
Let us know about your proceedings!
Cheers,
dobermunk
07-14-2005, 02:37 PM
Lurk. Lurk.
:twisted:
ThomasHelzle
07-14-2005, 02:49 PM
http://www.xsibase.com/forum/index.php?board=6;action=display;threadid=19135
another interesting and rather simple approach for XSI to tear the edges of an object apart - later examples are much better than the first one so scroll down a bit...
Should be possible to do the same in messiah - too bad it only works well on rather "round" objects ...
Cheers,
Suricate
07-14-2005, 04:51 PM
Hi Thomas,
thanks for the tips and the links. 'Lurking' David has already pointed me to JOT, this looks like quite a complex package. The XSI method is also quite interesting.
Thanks for the idea of a Flash exporter plug-in, I will put it on my (already too long) list of plug-in ideas. Indeed, also my motivation of programming for messiah largely depends on the further development on the pmG side. pmG has been extremely quiet recently, hopefully a sign that the render module and the SDK get a major overhaul !?
Anyway, I hope I can release the simple edge shader soon. I am busy with a few other things at the moment (playing chess and stuff), so that will probably take a few weeks.
CGTalk Moderation
07-14-2005, 04:51 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.