7

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.

Ascalon
  • 6,579
  • 8
  • 55
  • 121
  • 2
    Is there a reason to use cycles for this? It's not a very suitable render engine for the style you want to achieve. In Blender Internal this should be way easier. – Jaroslav Jerryno Novotny Jan 27 '17 at 21:05
  • @Jerryno I'm not using this for the whole shader. It's a small part of a larger setup. Everything else needs Cycles. I'm not sure it's possible to make this in BI either. I'm mostly curious about if this sort of thing would be possible. – Ascalon Jan 27 '17 at 22:01
  • 1
    It's possible using internal and compositor. You will need a shadeless pass, a toon pass (for lit areas) and shadow pass. In compositor you need to combine the toon with shadows and multiply that over the shadeless pass. In internal you will get much nicer toon pass, in cycles you will get nicer shadow pass and in both you can obtain the same shadeless pass. You can also use multiple renderers in single project if you duplicate the whole scene (make it linked) and include it in compositor of the first scene. – Jaroslav Jerryno Novotny Jan 28 '17 at 10:24
  • 2
    Isn't it physically impossible to let a surface with no form of shading/reflection react with its surroundings? Isn't the reason to want something shadeless, because it should have no shades? Could you tell what this should be used for? Maybe we can find another approach? – Reaper Jan 31 '17 at 09:14
  • 1
    @Reaper yeah it is physically impossible true, but there are non-physically correct ways how to shade a surface. With compositor is should be doable. The only problem is I don't know exactly what the outcome should be. – Jaroslav Jerryno Novotny Jan 31 '17 at 21:17
  • 1
    @Drudge can you post an example picture what you are after? Can be painted. How the shading should look. There is a text description in your question but it can lead to different looks. Are there only 2 shades (lit and unlit) or do you want shaded gradients etc. – Jaroslav Jerryno Novotny Jan 31 '17 at 21:19
  • Possible duplicate of http://blender.stackexchange.com/questions/64599/shadeless-mesh-thats-being-affected-by-lighting – Duarte Farrajota Ramos Feb 01 '17 at 00:25

2 Answers2

7

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:

Passes

Shadow layer:

another

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.

shadows

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.

highlights

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

Omar Emara
  • 22,639
  • 5
  • 55
  • 103
6

If I understand what you want correctly, you want something the responds to light like a normal diffuse shader, except that it ignores the angle the surface is from the observer. Have you tried simply using a diffuse shader, with the roughness set all the way up, and the surface normal tied to the "Incoming" output from the Geometry node. I may have misunderstood what you want, but it sounds like something close to what you're asking for.

I hope this helps.

UPDATED:

Drudge mentioned that when he tried this technique, he seemingly got it to mostly work, but that the shadows were too harsh for his(/her?) needs. As I replied in my comments, the harshness of the shadow should be directly related to the size of the light source. To demonstrate this, I rendered each of the sample images below twice: Once with a light source similar in size to the sun (as viewed from the Earth). The second image with a light source radius 7 times bigger (I reduced the Strength by a factor of 49 to maintain the lighting intensity. You can actually see the enlarged sun in the reflection on the mirror ball I threw in the background.)

The images rendered below show (on the blue Suzanne):

  • A typical real world diffuse surface shader that should be close to PBR.
  • A raw Diffuse shader with no additional tweaking
  • A raw Diffuse shader with the Roughness set to 100%
  • The setup I suggested above, with a raw Diffuse shader, with the surface normal fed from Geometry: Incoming, and the Roughness set to 100%

If you can point out where these images differ from your expectations, I'm happy to attempt to correct the problem.

Comparison of different permutations of this technique

Loren Osborn
  • 373
  • 1
  • 7
  • Can you explain a little more about what this is actually doing and why? Thanks. – Ascalon Jan 31 '17 at 19:59
  • 1
    Usually several things contribute to the color of a surface. For a surface to respond to the light around it, while being mostly a flat color, you would use a diffuse shader. You wanted your surface to accept shadows, and pick up the lighting conditions it's in. The only thing a diffuse shader does besides that, is vary the color intensity by viewing angle, which you said you didn't want. By tying the normal to the Incoming output, the surface renders as if it is always facing the camera, so it no longer changes with angle. Increasing the roughness adds to the surface flatness too. – Loren Osborn Feb 01 '17 at 04:21
  • Here's a related question about how roughness affects the diffuse shader: http://blender.stackexchange.com/questions/5167/what-does-the-roughness-setting-on-a-diffuse-shader-do – Loren Osborn Feb 01 '17 at 13:33
  • Incoming output into normal shader input does not work. Have you tried it? – Jaroslav Jerryno Novotny Feb 01 '17 at 19:25
  • Sry, i tried this and it doesn't work. It looks weird if you use the normal – Reaper Feb 02 '17 at 08:02
  • I've tested it, and it does technically work. However, it creates a very choppy terminator between lit and unlit areas, so it's not really useable. – Ascalon Feb 02 '17 at 08:12
  • At the time I suggested it I hadn't tested this, but I've been playing with it since seeing your comment and need help understanding what issues you're finding. The softness of your shadows, which I think you are describing, should be related to the arc length of your light source. I've been testing with a simulated sun that has an arc length of 0°32'02" but I will be experimenting with other size light sources. My simulated sun is also part of the background. I will experiment with practical light objects too. – Loren Osborn Feb 03 '17 at 02:51
  • The incoming vector output cannot be plugged directly into normal input. The math is wrong, it does not work. It also ruins smooth shading. https://i.stack.imgur.com/FEKDN.gif. IMHO forcing Cycles to do what you want is harder then to use compositor or internal. – Jaroslav Jerryno Novotny Feb 05 '17 at 20:26
  • Jerryno: I'm not sure if the incoming vector is in the same coordinate space as the surface normal space, so you may be right that the math may be wrong, but disabling the correlation between surface normal direction and shading brightness was the entire point. I adapted this from a few tutorials I've seen that use the Incoming vector to get F0 from the Fresnel node. Do you happen to know what coordinate space" Incoming" is in? – Loren Osborn Feb 05 '17 at 20:38
  • My intent, if it was unclear, was to do the equivalent of video game "billboarding" the surface so it always drew as if it were facing the camera square on. If, for instance "Incoming" is in global coordinate space, and the normal input is in a surface-centric coordinate system, then I agree with you that the math is wrong. If you happen to know what coordinate system "incoming" is in, I can transform it into the proper coordinate space. (Is it possible that The Fresnel node expects normals in a different coordinate space than surface shaders?) – Loren Osborn Feb 06 '17 at 02:20
  • I just realized that all my testing had been with subdivision surface modified meshes in OpenSubDiv mode. If the artifacting you saw is an issue, removing the modifier should make it more obvious. I will investigate. – Loren Osborn Feb 06 '17 at 02:25
  • Ah, I was testing with a very small lamp, so that was part of the issue. Thanks! – Ascalon Feb 06 '17 at 07:16
  • As I stated above, Jerryno may have a good point about the math being wrong. I have to test it further (without an subdivision surface modifier). – Loren Osborn Feb 06 '17 at 07:20
  • Two additional questions come to mind: Is self-shadowing a concern? (Do you want shadows cast by the object geometry to cast shadows on the material?) and... You asked this question saying that this was part of something else. Could you give us a bit more context as to what you're using this for? – Loren Osborn Feb 06 '17 at 07:24
  • @Jerryno was definitely correct that the math of plugging the Incoming output into the Normal input makes no sense as Incoming is in World space and Normal expects coordinates in Tangent space. I am still investigating a good fix for this but haven't resolved this yet. – Loren Osborn Feb 08 '17 at 05:07
  • @Jerryno, @Drudge, I'm sorry I haven't followed up on this sooner. I'm still trying to verify my findings, but it appears that while normal maps are primarily stored in Tangent coordinates, all the BDSF nodes take World coordinates as Normal inputs. (I suspect some built in auto conversion that changes coordinate systems kicks in when plugging a color into a normal vector.) Becausebof this I'm somewhat confident that plugging Geometry:Incoming into normal works as intended. – Loren Osborn Feb 15 '17 at 03:31
  • @LorenOsborn I am afraid I did not realize you had still been looking at this. I am still having the problem shown in Jerryno's gif above where the terminator becomes very jagged. Large amounts of subsurf help but do not solve the problem. – Ascalon Jun 01 '17 at 05:06
  • @Drudge, I haven't been tracking this lately, but why don't you catch me up on where you are with it, and I can share anything relevant I've learned. – Loren Osborn Jun 01 '17 at 16:27