0
$\begingroup$

I have encountered this weird issue: When not using a BDSF in Cycles, the shadows of my mesh are not rendered properly. How can I have my mesh have uniform color, without any variations in shading, only the shadows? When I connect the RGB socket to the material output, the shadows disappear. Is this a bug, or am I missing something? IMO, the mesh should still cast shadows as Cycles is a path tracer, and some paths would necessarily get blocked by the mesh geometry.

This should be easy to replicate - Blender 2.93 with standard settings. I have changed nothing other than setting the renderer to Cycles and subdivided and extruded the plane a few times.

enter image description here

$\endgroup$
2
  • 5
    $\begingroup$ This is not a bug but expected behaviour. The setting on the right part just tells Blender to set uniform color on the object, as it's not using a shader. What do you want to do exactly? $\endgroup$
    – lemon
    Commented Jun 28, 2021 at 7:53
  • $\begingroup$ Hi, thanks for your comment. I want the material to cast shadows that are caused by the geometry, when a color / vector - node (from a custom shader I created) is plugged into the material output! $\endgroup$
    – i2n
    Commented Jun 28, 2021 at 10:56

2 Answers 2

1
$\begingroup$

When you plug Color or Vector information straight into the Material Output Blender will display it as though it were passing through an Emission node with a Strength of 1. As such it will have no surface response because that shader just tells it to output light and says nothing of the surface.

enter image description here

enter image description here

You must use a BSDF to get the surface response you want.

enter image description here

$\endgroup$
2
  • $\begingroup$ Hey, thanks for your answer. So is there no option to map a RGB vector to a shader/BSDF node? I would need something like an "identity shader", that takes as input the RGB color and casts it into a node that cycles would render shadows for. In my concrete case, I am calculating Phong shading (i.e., dot product btwn viewDir, light, normal, etc...), and this inevitably will leave me with an RGB vector. Plugging this vector into a BSDF node (e.g., diffuse bsdf) would result in "shading twice", 1x with the phong calculations, and 1x with the diffuse shading model the bsdf node applies. $\endgroup$
    – i2n
    Commented Jun 30, 2021 at 16:17
  • $\begingroup$ You might be looking at building your own node with OSL, but that's not my area. $\endgroup$ Commented Jun 30, 2021 at 18:17
1
$\begingroup$

So, thanks for the comments and answers. Answering my own question for future readers that may end up here. I was looking through the OSL spec, and there actually is a phong-reflection function, but when using it in a OSL script node with cycles, I get a this function is not implemented by the current renderer error. Unfortunately, one cannot declare new OSL closures, hence, this was a dead end.

It turns out that what I was trying to do actually can be done with the Diffuse BSDF node, which uses the Oren-Nayar shading model. When setting the roughness to 0.0, Oren-Nayar decays to the lambertian model, normalized by a factor of 1/pi. So, to get an "identity shader" node that simply passes the color through and enables cycles to calculate shadows, one must scale the incoming color values by the inverse terms used in the Oren-Nayar model.

For the simple case of no roughness, this amounts to simple multiplication with the (clamped) inverse dot product between light vector and surface normal and pi, and looks as follows:

enter image description here

As one can see, the extruded plane now casts shadows without having shading applied to its color (at least where the dot product is not clamped, but that's sufficient).

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .