Cartoon shading

Blitz3D Forums/Blitz3D Programming/Cartoon shading

Jerome Squalor(Posted 2007) [#1]
How do you do cartoonish shading?


Ross C(Posted 2007) [#2]
links back to the homepage :o) Plus you should put creations in the correct forum ;O)


Ross C(Posted 2007) [#3]
Ok, it's not a creation... i'll wait for you to edit again :D


Jerome Squalor(Posted 2007) [#4]
i was trying to do an image it's good now.


Jerome Squalor(Posted 2007) [#5]
ok NOW its good..


Ross C(Posted 2007) [#6]
You can set flatshading, in the entityfx command. That should sort you out


Jerome Squalor(Posted 2007) [#7]
ok


Ross C(Posted 2007) [#8]
http://www.blitzbasic.com/b3ddocs/command.php?name=EntityFX&ref=3d_a-z


Jerome Squalor(Posted 2007) [#9]
is there any other way 'cause its looking kinda weird with the vertex shading?


Ross C(Posted 2007) [#10]
I'm afraid i don't know any other way, sorry!


Jerome Squalor(Posted 2007) [#11]
no problem, do you know how to outline a mesh?


Pongo(Posted 2007) [#12]
2 things.

1. Use a spherical reflection map made of a solid color, with a hard edge highlight area and a hard shadow area. Make it look like a cartoon shaded sphere and that is what you will get on your mesh.

2. To create the outline,...duplicate the mesh, push the faces out along their normals a bit, invert it and change that mesh to the outline color. There is a function in the code archives to do this.


JustLuke(Posted 2007) [#13]
Use a 2d cubemap, it gives the best, closest effect to real cartoon shading in Blitz3d, but the shading won't react to light sources (so you need to plan your environment lighting carefully).

As far as I know, there isn't a decent way to outline a mesh. The "colour black and flip" approach that has been mentioned by other people looks awful, quite frankly. The lines look dirty and ragged, and they are affected by perspective and their distance from the camera too. This method also doubles your polygon count. Also, the method only works semi-reasonably with very basic models (I'm talking about things like low-poly cars or tanks, or primitive shapes like spheres, cubes, etc.) the more complicated the model, the worse it looks, generally speaking.


Ross C(Posted 2007) [#14]
For an outline, you can use a spherical enviroment map, put a white circle, just NEARLY touching the edges, on a black background. If the meshes has enough polygons, it should work a treat :o)


sswift(Posted 2007) [#15]
http://shawnswift.com/blitz/dtsmashtest.zip

Download this. There's source. It's free to use.

This shows you how to take a simple gradient image and convert it at runtime to a spherical environment map which you can then apply to characters to get a cel shaded look. It also shows you how to make those black outlines.

The cel shaded "glass sphere" effect on the eyes is done with a manually created spherical environment map.


There are limitations with this method. Cubic environment maps weren't in Blitz when I wrote this, or at least weren't on all 3D cards, so it generates spherical environment maps.

The problem with using spherical environment maps for this is that it severely limits the ways in which you can move the camera, because in effect, the light source will be attached to the camera.

If you decide to have the light source directly above the characters, then you can orbit them around the Y axis, but that's the best you can do. You won't be able to move the camera up or down without the light source appearing to move with the camera.

The fix for this should be fairly easy though. I think you need to change the code so that it renders a cubic environment map from INSIDE the cel shaded sphere the program creates to render the spherical environment map. Then you would apply that cubic map to the fullbright model with the right rendering mode for the cubic map. (There are two, I don't know which is the right one.) This will then make it so the light source's direction is always where you want it to be no matter how you move the camera.

Don't email me for support please. :-)


siread(Posted 2007) [#16]
The best looking cel-shaded games don't bother with the black outline (IMO).


JustLuke(Posted 2007) [#17]
Agreed.