Flat material that isn't shadeless It is standard to create shadeless materials by using the emission shader, often with a Lightpath Is Camera Ray to prevent it from casting light on other objects. This creates a flat color regardless of lighting. It does not get any shadows cast on it, and doesn't have any shading on it.

I want to create a material that will not allow any shading on it (so no shadow terminator, same flat color) but WILL allow for shadows to be cast upon it, and most importantly, somehow responds to the overall light level in the scene. In other words, it can change in brightness when in well lit areas, but remains flat.

The purpose of this is to allow for flat shading, but also allow for low light and high key scenes. Currently, the emission based shadeless material will give the same color in a dark room as on a sunny day.

For a full example, consider this material on a character's face:
1)If the light was striking it directly, the whole face would be the same color, which should be the brightness you would have in the brightest area if using a regular diffuse shader.

2) If the character's face wasn't in direct light, it should all be the brightness of the darkest area if it was a regular diffuse shader.

3) If the character's face was strongly lit on one side but not the other (hatchet lighting), it should be fully bright on the bright area, and fully dark in the dark area, which could probably be achieved with some sort of color ramp or have it based on normal.

4) If another object casts a shadow on the object, it should only darken in the area the shadow is cast on, like a regular diffuse. The cast shadow shouldn't be factored into it's shading.

Ideally this would be solved within the material, but compositor options could also work.
We can use compositor tricks as you proposed.

Scene

I am going to set the scene such that the shadless objects are in one layer and the others in another.

Add another render layers to catch shading information:

I am going to create a new render layer with exactly the same layers but I am going to set the Material override to a material which is just a diffuse shader. And another one which with the same setting but with excluding the layer with the non shadless objects.

Shading layer:



Shadow layer:



Matrials

The material for the object should be as you described, an emission shader with camera ray as input.

Compositing setup

Since we enabled all passes, we cal selectively apply the only shading we want.

Example 1: Shadows that other object casted:

By subtracting the shadow if the shading layer from the shadow if the shadow layer and then inverting it, I get the shadows that were only casted from other objects and not the object itself.



Example 2: Adding highlights:

I can add the diffuse direct of the shadow layer to the result to get highlights and I can use Indirect lighting.



And you can play with passes to get exactly what you want.