I'm a complete newbie with shaders, so probably what I'm asking is not the better problem to start with. Anyway, I was looking for a shader which dithers the darker zones of an object. To better explain, what I'm looking for is something like Midwinter, an old Amiga game: Is this difficult to obtain?
It's basically a way of representing specific ranges of color values as a pattern. In the image above there are apparently: White White with small blue dots 50/50 White and blue dots Mostly blue dots Blue ... similar for blue levels In a shader one way is to have a pattern texture with one `grid` cell of pattern for each brightness level, and you can put all of the levels on one texture. Then you just need to take the fragment coordinate (relative to screen coords, not the world coordinate, otherwise the pattern will flicker and shift), use the `modulo` of those numbers to keep within 1 grid cell, then look up a pixel from the the grid cell. ... you select which cell to reference also based on the tone of the color being drawn, falling into a specific bracket. It's doable.
If you care for a commercial solution, i have an asset pack which includes this shader as well. http://forum.unity3d.com/threads/94120-Aubergines-PostPRocess-Effects-Released-in-Assetstore Its a post processing shader which requires unity pro, but you can also apply the same logic for individual objects.
You'd probably want to create an image effect for that, which creates the illusion of a lower resolution and lower number of available colors. So you'd need to use Unity Pro. For the dithering itself you can use an existing dithering technique like Floyd-Steinberg, and convert it to work on a GPU. (For example, the pseudo code you can find on Wikipedia assumes you can write to other pixels, which is not how you work in shaders) I'm not sure if it is something you'd want to do as your first shader, because it is a combination of several different disciplines, but it is certainly doable.
I'm unable to access screenPos in the finalcolor function of a surface shader: Code (csharp): Shader "dithering" { Properties { _MainTex ("Texture", 2D) = "white" {} _ColorTint ("Tint", Color) = (1.0, 0.6, 0.6, 1.0) } SubShader { Tags { "RenderType" = "Opaque" } CGPROGRAM #pragma glsl #pragma surface surf Lambert finalcolor:mycolor struct Input { float2 uv_MainTex; float4 screenPos; // x and y between 0 and 1 }; sampler2D _MainTex; void surf (Input IN, inout SurfaceOutput o) { o.Albedo = half3(1.0, 0.0, 0.0); } void mycolor (Input IN, SurfaceOutput o, inout fixed4 color) { color = fixed4(IN.screenPos.x, IN.screenPos.y, 0.0, 1.0); } ENDCG } Fallback "Diffuse" } gives: Shader error in 'dithering': D3D shader assembly failed with: (6): error X5204: Read of uninitialized components(*) in r0: *r/x/0 *g/y/1 b/z/2 a/w/3 Shader Assembly: ps_2_0 ; 3 ALU def c0, 0.00000000, 1.00000000, 0, 0 mov r0.w, c0.y mov r0.z, c0.x mov_pp oC0, r0 Any ideas?