# Change color based on incident energy in Cycles.

**URL:** <https://blenderartists.org/t/change-color-based-on-incident-energy-in-cycles/560692>\
**Category:** Materials and Textures\
**Created:** [December 28, 2012, 7:52am UTC](https://blenderartists.org/t/change-color-based-on-incident-energy-in-cycles/560692 "2012-12-28T07:52:07Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![GodOfBigThings](https://blenderartists.org/user_avatar/blenderartists.org/godofbigthings/32/8795_2.png) [@GodOfBigThings](https://blenderartists.org/u/GodOfBigThings)\
**Post date:** [December 28, 2012, 7:52am UTC](https://blenderartists.org/t/change-color-based-on-incident-energy-in-cycles/560692/1 "2012-12-28T07:52:07Z")

</div>

It’s possible in BI to change the color of an object based on the amount of light falling on it.

Is it possible in Cycles right now?

Any hacks/complicated node setups/OSL scripts to achieve it?

---

<div class="post-metadata">

**Author:** ![gexwing](https://blenderartists.org/letter_avatar_proxy/v4/letter/g/7ab992/32.png) [@gexwing](https://blenderartists.org/u/gexwing)\
**Post date:** [December 28, 2012, 8:30am UTC](https://blenderartists.org/t/change-color-based-on-incident-energy-in-cycles/560692/2 "2012-12-28T08:30:14Z")

</div>

You can’t do it directly in Cycles, but you can do it in the compositor (assign it a simple one color material, use the ObjectID/MaterialID to separate it out in the compositor, change its color and overlay it again).

---

<div class="post-metadata">

**Author:** ![GodOfBigThings](https://blenderartists.org/user_avatar/blenderartists.org/godofbigthings/32/8795_2.png) [@GodOfBigThings](https://blenderartists.org/u/GodOfBigThings)\
**Post date:** [December 29, 2012, 1:07am UTC](https://blenderartists.org/t/change-color-based-on-incident-energy-in-cycles/560692/3 "2012-12-29T01:07:02Z")

</div>

Let me make my question more specific here. The bottom image has a paint whose intensity falls off very rapidly with the angle (it is a lot darker where it’s facing perpendicular to the light source).

The top one if a lot brighter even when it’s facing perpendicular to the light.

I could probably get close to this effect by changing the roughness values, but it gives very little control, and you cannot change the hue, which happens with a lot of car paints.

![http://thecarcarestore.com.au/ccs_shop_images/meguiars/PBC37S.png](http://thecarcarestore.com.au/ccs_shop_images/meguiars/PBC37S.png) ![http://thecarcarestore.com.au/ccs_shop_images/meguiars/KBC05S.png](http://thecarcarestore.com.au/ccs_shop_images/meguiars/KBC05S.png)

And another one where the saturation changes with the angle.

![http://thecarcarestore.com.au/ccs_shop_images/meguiars/KPF101ZS.png](http://thecarcarestore.com.au/ccs_shop_images/meguiars/KPF101ZS.png)

---

<div class="post-metadata">

**Author:** ![storm\_st](https://blenderartists.org/letter_avatar_proxy/v4/letter/s/74df32/32.png) [@storm\_st](https://blenderartists.org/u/storm_st)\
**Post date:** [December 29, 2012, 1:49am UTC](https://blenderartists.org/t/change-color-based-on-incident-energy-in-cycles/560692/4 "2012-12-29T01:49:42Z")

</div>

You need access to “throughput” and “L” integrator core variables that not exposed to node system. Node tree provide only some “weight” that will be multiplied (or added in case of last direct edge to light source) to final color.

---

<div class="post-metadata">

**Author:** ![RickyBlender](https://blenderartists.org/user_avatar/blenderartists.org/rickyblender/32/7134_2.png) [@RickyBlender](https://blenderartists.org/u/RickyBlender)\
**Post date:** [December 29, 2012, 5:12am UTC](https://blenderartists.org/t/change-color-based-on-incident-energy-in-cycles/560692/5 "2012-12-29T05:12:37Z")

</div>

you seems to be describing the effect of spec or normals behavior not energy function olf color

i’ think iv seen one function of light color but very complicated to do

are you really interested in one like that  
i can try to locate where i havee the ref for this effect!

happy cycles

---

<div class="post-metadata">

**Author:** ![GodOfBigThings](https://blenderartists.org/user_avatar/blenderartists.org/godofbigthings/32/8795_2.png) [@GodOfBigThings](https://blenderartists.org/u/GodOfBigThings)\
**Post date:** [December 29, 2012, 5:38am UTC](https://blenderartists.org/t/change-color-based-on-incident-energy-in-cycles/560692/6 "2012-12-29T05:38:15Z")

</div>

> [@RickyBlender](#):
>
> are you really interested in one like that  
> i can try to locate where i avhe teh ref for this effect!

Yes, would be appreciated.

---

<div class="post-metadata">

**Author:** ![GodOfBigThings](https://blenderartists.org/user_avatar/blenderartists.org/godofbigthings/32/8795_2.png) [@GodOfBigThings](https://blenderartists.org/u/GodOfBigThings)\
**Post date:** [December 29, 2012, 11:31pm UTC](https://blenderartists.org/t/change-color-based-on-incident-energy-in-cycles/560692/7 "2012-12-29T23:31:12Z")

</div>

Thanks for the help. RickyBlender. None of these are exactly what I’m looking for.

I’ll ask in the cycles thread.

---

<div class="post-metadata">

**Author:** ![anurag.k](https://blenderartists.org/letter_avatar_proxy/v4/letter/a/85f322/32.png) [@anurag.k](https://blenderartists.org/u/anurag.k)\
**Post date:** [December 29, 2012, 11:58pm UTC](https://blenderartists.org/t/change-color-based-on-incident-energy-in-cycles/560692/8 "2012-12-29T23:58:00Z")

</div>

I think using color ramp to control the diffuse color should do the trick. I can get similar effect using ‘facing’ input as factor to the color ramp. You can also use the angle trick that RickyBlender mentioned (the ies like lighting thread) to control the color ramp as well.

Edit: The falloff doesnt seem to depend on the light angle though even using the angle trick from the other thread… It only depends on viewing angle… I guess i posted too early 🙂

---

<div class="post-metadata">

**Author:** ![GodOfBigThings](https://blenderartists.org/user_avatar/blenderartists.org/godofbigthings/32/8795_2.png) [@GodOfBigThings](https://blenderartists.org/u/GodOfBigThings)\
**Post date:** [December 30, 2012, 12:58am UTC](https://blenderartists.org/t/change-color-based-on-incident-energy-in-cycles/560692/9 "2012-12-30T00:58:40Z")

</div>

I’ve managed to find a solution, but it only works if there’s jus one light. The position vector of the shading point, the lamp, and the surface normal are all you need to find the angle the normal makes with incident light, which you can use as input for color ramp.

But this does doesn’t work with any other light setup. Looking for a solution to that now.

---

<div class="post-metadata">

**Author:** ![anurag.k](https://blenderartists.org/letter_avatar_proxy/v4/letter/a/85f322/32.png) [@anurag.k](https://blenderartists.org/u/anurag.k)\
**Post date:** [December 30, 2012, 2:07am UTC](https://blenderartists.org/t/change-color-based-on-incident-energy-in-cycles/560692/10 "2012-12-30T02:07:07Z")

</div>

I guess the only way possible would be to get amount of light at the point like you suggested (or some OSL magic). How are you using the position of light, are you entering the values manually?

---

<div class="post-metadata">

**Author:** ![GodOfBigThings](https://blenderartists.org/user_avatar/blenderartists.org/godofbigthings/32/8795_2.png) [@GodOfBigThings](https://blenderartists.org/u/GodOfBigThings)\
**Post date:** [December 30, 2012, 3:11am UTC](https://blenderartists.org/t/change-color-based-on-incident-energy-in-cycles/560692/11 "2012-12-30T03:11:54Z")

</div>

Yeah, for now I’m entering the lamp’s position vector manually. But the wiki says it’s possible using the attribute node to get an object’s position. Even if that doesn’t work, I guess it would be possible using OSL.

Here’s a quick little example.

The question about an actual solution still stays.

### Attachments

[angle variation.blend](https://blenderartists.org/uploads/default/original/3X/b/5/b5af81e36085e783f17e40f9692736ee6723e531.blend) (582 KB) ![](https://blenderartists.org/uploads/default/original/3X/0/d/0d0a06a9d672dddd25a08958ba9f782a6165cfd1.jpg)

---

<div class="post-metadata">

**Author:** ![RickyBlender](https://blenderartists.org/user_avatar/blenderartists.org/rickyblender/32/7134_2.png) [@RickyBlender](https://blenderartists.org/u/RickyBlender)\
**Post date:** [December 30, 2012, 5:24am UTC](https://blenderartists.org/t/change-color-based-on-incident-energy-in-cycles/560692/12 "2012-12-30T05:24:36Z")

</div>

i got an example for showing the normals on faces  
but less coorfull then yours!

salutations

---

<div class="post-metadata">

**Author:** ![gexwing](https://blenderartists.org/letter_avatar_proxy/v4/letter/g/7ab992/32.png) [@gexwing](https://blenderartists.org/u/gexwing)\
**Post date:** [December 30, 2012, 6:44am UTC](https://blenderartists.org/t/change-color-based-on-incident-energy-in-cycles/560692/13 "2012-12-30T06:44:38Z")

</div>

you can make such rainbow paints by mixing different roughness glossy shaders together (that’s also how that sort of paint is made, different colored flakes with different reflective properties). It’s not necessary to trick a physicly based materialsystem where you don’t actualy need to 😉

 ![](https://blenderartists.org/uploads/default/original/3X/0/b/0b8ac16cd968a53f5a567bf0c30811916a7cbac2.png)

---

<div class="post-metadata">

**Author:** ![varkenvarken](https://blenderartists.org/user_avatar/blenderartists.org/varkenvarken/32/5299_2.png) [@varkenvarken](https://blenderartists.org/u/varkenvarken)\
**Post date:** [December 30, 2012, 6:45am UTC](https://blenderartists.org/t/change-color-based-on-incident-energy-in-cycles/560692/14 "2012-12-30T06:45:26Z")

</div>

The phong\_ramp closure is available in Blender OSL, it is just not exposed as a node.

I put a bare bones implementation together, if you’re interested you can find it here:

[http://blenderthings.blogspot.com/2012/12/a-phong-ramp-car-paint-osl-shader-for.html](http://blenderthings.blogspot.com/2012/12/a-phong-ramp-car-paint-osl-shader-for.html)

I realize that angle dependent diffuse reflection is problably not the whole story for a car paint shader but it is a start.

 ![](https://blenderartists.org/uploads/default/original/3X/a/f/afa5d19a6ce23bdac27347584468d8ba5ee655d8.png)  

cheers

---

<div class="post-metadata">

**Author:** ![RickyBlender](https://blenderartists.org/user_avatar/blenderartists.org/rickyblender/32/7134_2.png) [@RickyBlender](https://blenderartists.org/u/RickyBlender)\
**Post date:** [December 30, 2012, 7:33am UTC](https://blenderartists.org/t/change-color-based-on-incident-energy-in-cycles/560692/15 "2012-12-30T07:33:31Z")

</div>

another way woudl be to use another renderer  
like Yafaray or Luxrender!  
which have more features then cycles!  
i remember that luxrender have an option for lamps energy and spectrum!

salutations

---

<div class="post-metadata">

**Author:** ![Ace\_Dragon](https://blenderartists.org/user_avatar/blenderartists.org/ace_dragon/32/1067926_2.png) [@Ace\_Dragon](https://blenderartists.org/u/Ace_Dragon)\
**Post date:** [December 30, 2012, 11:52am UTC](https://blenderartists.org/t/change-color-based-on-incident-energy-in-cycles/560692/16 "2012-12-30T11:52:51Z")

</div>

> [@RickyBlender](#):
>
> i remember that luxrender have an option for lamps energy and spectrum!

As far as I know, the lamp energy and spectrum textures in Luxrender are textures to use with emissive materials to control the color and the behavior of the light, they do not actually allow a material to change color or do something similar based on the amount of light falling on it.

In fact, I don’t think Luxrender has any sort of option comparable to the blend weight node or the ‘incoming’ parameter available through the geometry node. Luxrender instead has a carpaint shader which more or less has a fresnal effect built into it, but I don’t think it’s quite as customizable as what you can do in Cycles with the individual shading components.

---

<div class="post-metadata">

**Author:** ![GodOfBigThings](https://blenderartists.org/user_avatar/blenderartists.org/godofbigthings/32/8795_2.png) [@GodOfBigThings](https://blenderartists.org/u/GodOfBigThings)\
**Post date:** [December 31, 2012, 2:20am UTC](https://blenderartists.org/t/change-color-based-on-incident-energy-in-cycles/560692/17 "2012-12-31T02:20:21Z")

</div>

> [@varkenvarken](#):
>
> The phong\_ramp closure is available in Blender OSL, it is just not exposed as a node.

Thanks for the post on your blog post. I didn’t know about it.

While you can’t control glossy with that approach, it’s definitely going to be useful for the diffuse component of the car paint.

---

<div class="post-metadata">

**Author:** ![RickyBlender](https://blenderartists.org/user_avatar/blenderartists.org/rickyblender/32/7134_2.png) [@RickyBlender](https://blenderartists.org/u/RickyBlender)\
**Post date:** [December 31, 2012, 4:28am UTC](https://blenderartists.org/t/change-color-based-on-incident-energy-in-cycles/560692/18 "2012-12-31T04:28:17Z")

</div>

as i said you can get a normal color for each face nodes set up !

there is no direct way to get light intensity  
but may be an indirect way!  
is not there a way to get from the normal RGB values the intensity from each face  
then you could re adjust the color function of that intensity may be ?

salutationsl

---

<div class="post-metadata">

**Author:** ![mano-wii](https://blenderartists.org/user_avatar/blenderartists.org/mano-wii/32/24350_2.png) [@mano-wii](https://blenderartists.org/u/mano-wii)\
**Post date:** [January 3, 2013, 8:04pm UTC](https://blenderartists.org/t/change-color-based-on-incident-energy-in-cycles/560692/19 "2013-01-03T20:04:51Z")

</div>

I created two materials that change color depending on the position of any point of light:  
A diffuse material (needs solidify modifier)  
A glossy material (If increasing the scale of Voronoy the surface is softer).

 ![](https://blenderartists.org/uploads/default/original/3X/0/a/0a3195a6b318d62022d689602a66bdca986a1a12.jpg)  
  
And the .blend:  
[Change-color-based-on-incident-energy.blend](https://blenderartists.org/uploads/default/original/3X/f/9/f91968c6e921bccc9f93f1af2cde91d84a29a02a.blend) (641 KB)

---

<div class="post-metadata">

**Author:** ![GodOfBigThings](https://blenderartists.org/user_avatar/blenderartists.org/godofbigthings/32/8795_2.png) [@GodOfBigThings](https://blenderartists.org/u/GodOfBigThings)\
**Post date:** [January 5, 2013, 5:13am UTC](https://blenderartists.org/t/change-color-based-on-incident-energy-in-cycles/560692/20 "2013-01-05T05:13:27Z")

</div>

That is very interesting mano-wii.

I cannot figure out how the diffuse shader works. Can you explain?

[Next page](https://blenderartists.org/t/change-color-based-on-incident-energy-in-cycles/560692.md?page=2)
