Hello, has anyone ever had some experiences with crosshatching shaders ?
I have tried everything to make this shader and actually managed to do something but with a lot of problems, if you have any kind of an example it would be nice.
If anyone notices this post il reply with a photo and shader code
It’s hard to help without more specific details about the nature of the problems you’ve faced, but the general approach I’ve followed is based on the Microsoft Research article published here: http://hhoppe.com/hatching.pdf
- First, create a “tonal art map” - an array of textures representing increasing density of hatching, as follows:
(The process for creating these is described at Hand-Drawn Shaders and creating Tonal Art Maps | Alastair Aitchison )
-
In the fragment function of your shader, perform any lighting calculations and texture lookups as usual, just as you would do for a regular shader. However, instead of simply returning the colour, you calculate the brightness of the final pixel value (by taking the dot product with the vector half3(0.3, 0.59, 0.11) to allow for eye sensitivity for RGB). Use that brightness value as a lookup into your tonal art map to sample the appropriate hatching texture. There’s a few tricks you can do here to cross-blend between neighbouring textures in the map to achieve a smooth transition.
-
Finally, since hatching is generally done with ink or pencil on a light surface, you’ll generally want to use a multiply blend mode , i.e. Blend DstColor Zero
The results look like this: