Cel-Shading in Blitz3D

Blitz3D Forums/Blitz3D Programming/Cel-Shading in Blitz3D

Cube mapping, unlike sphere mapping is a mapping which depends on world space, rather than camera space. So as the camera moves around you view the cube mapping form different angles, whereas you do not view a sphere map from different angles. The sphere map thus appears to move with the camera.

As the sphere map contains your light source, whose direction is implicitly encoded into the texture, if it moves with the camera, then the light source appears to move with the camera.

Cube mapping does not have this problem. If the left face of the cube map has the light source, then when the camera moves around, the light source will always appear to come from the west, regardless of which direction the camera looks at the object from.

You can generate a cube map by making a vertical 1D texture of light from light to dark, with different bands of color rather than a smooth gradient and then applying this to a sphere mesh rotated so that it's north pole points down the negative Z axis. Then you flip it inside out, and make it fullbright. Then you rotate the entity to aim your light source, just as you would a directional light, scale it up, and place your camera inside the sphere facing down positive Z, and render a cube map from inside.

That cube map now will look like cel shading when applied to an object, with a light source coming a directional light.

Making point light sources is more diffiuclt and requires re-rendering the map for every object as it changes position relative to the light.