I figured i would give crosshatching a shot, since it seems to be semi-important. A lot of games with a non-photo-real art style use this to varying degrees but it is often done directly on the texture. This means that it will not actually react to the light at all. This paper presented a technique that is reactive to light, by using varying amounts of hatching and blending between them.For simplicity’s sake i only used 3 textures instead of 6, since i hatching on light areas is confusing. Instead I just use a pure white for the brightest 2 areas and begin hatching in the midtones using the heaviest hatching on the darkest 2 areas, where its hard to notice the difference. This allows me to cram everything into the RGB channels of a single texture before splitting them out and recombining them in the shader. I used the blending technique found here to calculate the hatching level.

It also includes a offset and intensity modifier to let you control the shadow level where hatching starts and the intensity of the hatching respectively. Here it is pushed back into only the deepest shadows with the original hatching texture and an alternate I made (I found you could use it for more types of tone mapping than hatching). I like this because i think it helps the shapes in the deeper shadows read a bit better.
I did have to rip out multiple lights from the shader to keep it the same between Maya and Unity, as there is no way to make this work that i know of with multiple lights in Unity. I may try some fakery later to get them back, but i wasn’t totally happy with them anyway – Ramped lighting doesn’t seem to blend additively very well, but that may just be my ramps.

Maya CGFX File:

crosshatch.cgfx
File Size: 11 kb
File Type: cgfx

Download File


Unity SHADER File:

crosshatch.shader
File Size: 11 kb
File Type: shader

Download File


3 Responses

  1. Hello, you seem really talented. I experimented a bit with your shader and found one thing that i did not get (not really informed about shaders) the materials dont recieve or cast shadow when using this shader code 🙂

    1. Yes that’s true. The shaders posted are leave out several things like cast/receiving shadows for simplification. I didn’t want to confuse the subject of a particular shader by including a bunch of code relating to other things. I should probably do an example in the future tho.

Leave a Reply

Your email address will not be published. Required fields are marked *