7
$\begingroup$

I know how to create spherical gradient textures for objects and I also know how to assign image and radial gradient textures to spotlights. I am struggling however with the spherical gradient on spotlights.

EDIT: This is not a duplicate of the IES light question, I am specifically asking how to do this with a spot light and without an image, which proved possible (see accepted answer).

Spherical texture on object Radial picture on spotlight

I want to achieve this, but without an image.

Target effect

EDIT: this is the nodetree that worked,

thanks to Secrop's answer. Funny thing, I already had Z scaled to 0 for the image texture.

Solution

$\endgroup$
6
$\begingroup$

From your screenshot it's possible to see that you're using the normal vector unchanged. You need to scale the Z axis to 0 in the Mapping Node, so that the spherical gradient can be seen.

The spherical gradient works best with point coordinates, not with normals. It uses the origin of the coordinate system and 'draws' a sphere at that point. More precisely, it calculates the distance from the origin to any point, starting from white at the center and becoming black when the distance is 1 or above (or in a more concise form: color = clamp(1 - distance_to_origin)).

This is a problem for Normals, which are normalized (hence the name), and have always a length of 1, which returns black because it's already at the surface of the sphere gradient (color = 1-1 = 0).

Scaling the Z coordinate to 0 is the same as mapping any Z coordinate to the XY plane only. This streches the sphere to the infinity (along the Z axis), which turns the sphere into a cylinder, and this maps correctly into the color ramp.

$\endgroup$
7
$\begingroup$

I think you want to make something like fake IES lights. I don't know how to make it with spotlights, but maybe this will help you. So here we go!

Final result:

Final

Steps:

  1. Create simple Circle filled with Ngon or Triangle, or even fill it as you pleased and scale it down to 0.1.
  2. Create this node setup (I'll explain it later):

Node setup

Most interesting stuff:

Light Falloff. You can control here light strength and smoothness.

Color Ramp. This will make gradients as you like. Try adding/deleting/shifting colors and you'll see the magic.

Blackbody. Real deal here. It's simulating temperature of light. You can delete it and set any color you want.

That's it. You have now fancy fake IES lights with color temperature.

Blend file:

$\endgroup$
  • $\begingroup$ In your example image, you can see the circle meshes, especially in the foremost light. To fix this, you could first plug in a Transparent shader to the top input on the Mix node so that the backfaces disappear instead of showing up black. Also, you could add the Is Camera Ray value of the Light Path node to the Backfacing value. This way, the lights will illuminate, but not appear in the image. $\endgroup$ – Scott Milner Feb 26 '17 at 5:23
  • $\begingroup$ @scottmilner why this need any fix? I'm perfectly aware that it's visible and it's ok. Probably in 100% situation when I'm using fake IES lights they have physical source. Your advice could be an option but not a fix. $\endgroup$ – cgslav Feb 26 '17 at 5:29
  • $\begingroup$ Yes, I understand that. I wanted to put the information out there, though, since a completely physically accurate result isn't always wanted, and it is an easy modification. $\endgroup$ – Scott Milner Feb 26 '17 at 5:32
5
$\begingroup$

The easiest way is to make Area light behave like a spot lamp and give it the appearance you want:

  1. Make the area light tiny. We want a small (ideally size 0) light so when an obstacle is close the light does not produce a square pattern (but circular like a spot lamp). However when the light is too small, Cycles has problems sampling it and this makes noisy renders. Size of 0.01 worked for me well:

    enter image description here

  2. This is the node network:

    enter image description here

    • First we get a cosinus of light angle from the normal and incoming ray.
    • Then we get the actual angle of emitted light with Arccosine math node.
    • The first blue ColorRamp is there to influence the cone of the light with that black slider (this is giving the area light spot light controls).
    • The second yellow ColorRamp sets the profile of the light. Keep the interpolation Bspline or Ease, do not leave it linear. There are measured files of real lights on the internet, they represent luminous values per angles and they look like this (there are 3 different lights marked):

    enter image description here

    • This gets multiplied with the light's strength. If you need to, you can also feed there custom falloff values from optional Light Falloff node (if you really need different than the default Quadratic falloff behaviour).
    • The color of the light is determined by the light's temperature. White point is exactly at 6500°K for sRGB's 2.2 gamma (D65 white).

This was the manual way. There is also an addon to import IES light profiles. The created light is Point type and does not react to rotation (it only shines down). But there is an option to create also a rig for the light, which drives mapping nodes so you can change the direction of light

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.