# Is there a way to get the sample number as an input for Cycles shaders?

**URL:** <https://blenderartists.org/t/is-there-a-way-to-get-the-sample-number-as-an-input-for-cycles-shaders/558199>\
**Category:** Materials and Textures\
**Created:** [November 29, 2012, 2:43pm UTC](https://blenderartists.org/t/is-there-a-way-to-get-the-sample-number-as-an-input-for-cycles-shaders/558199 "2012-11-29T14:43:27Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![TiagoTiago](https://blenderartists.org/letter_avatar_proxy/v4/letter/t/8dc957/32.png) [@TiagoTiago](https://blenderartists.org/u/TiagoTiago)\
**Post date:** [November 29, 2012, 2:43pm UTC](https://blenderartists.org/t/is-there-a-way-to-get-the-sample-number-as-an-input-for-cycles-shaders/558199/1 "2012-11-29T14:43:27Z")

</div>

Without having to learn to code it myself, is there a way to have the sample number (or how many samples have been rendered for that pixel for the current frame so far) as an input for shaders on Cycles, so that on each sample the shader will have different parameters?

---

<div class="post-metadata">

**Author:** ![m9105826](https://blenderartists.org/user_avatar/blenderartists.org/m9105826/32/6760_2.png) [@m9105826](https://blenderartists.org/u/m9105826)\
**Post date:** [November 29, 2012, 7:23pm UTC](https://blenderartists.org/t/is-there-a-way-to-get-the-sample-number-as-an-input-for-cycles-shaders/558199/2 "2012-11-29T19:23:35Z")

</div>

Rendering a different value for each sample of a single frame would absolutely destroy any kind of coherency in the picture. Path tracers work by averaging together many values to “find” the correct light interaction for that pixel. If the value of a given pixel changed in every sample, there would never be a “correct” answer to solve for and rendering would never finish.

---

<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:** [November 30, 2012, 11:33am UTC](https://blenderartists.org/t/is-there-a-way-to-get-the-sample-number-as-an-input-for-cycles-shaders/558199/3 "2012-11-30T11:33:55Z")

</div>

might be possible with OSL nodes

check thread on irridescence mat text forum  
which simulate mulit color function of distance!

salutations

---

<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:** [November 30, 2012, 2:20pm UTC](https://blenderartists.org/t/is-there-a-way-to-get-the-sample-number-as-an-input-for-cycles-shaders/558199/4 "2012-11-30T14:20:31Z")

</div>

sorry still learning about this new OSL thing

but if possible with one might be possible with more then one source  
but you’ll have to learn how to do it in OSL!

salutations
