# A tube of light in a volume shader

As I had much fun with this (thx Chebhou) but gaussian functions are a bit too complex for me, i want my volume scatter cylinder to have simply a smaller cylinder emitting light inside it, from the same object/material. The same size all along, or why not being able to control the fading at one or both sides (why not asking :) )

It has to be done with math nodes, vectors and things like that (what I want to learn)

Something like this but in a single object

looks like a light saber :)

• – user1853 Feb 13 '15 at 17:11
• @cegaton nope, i don't want a compositing or modeling answer, it has to be shader maths. I already did (long ago) a light saber but i want to learn more about math nodes and vectors in materials. I hope this is simple enough for me to understand the why and how. – Bithur Feb 13 '15 at 17:16

use this circle equation and chose a radius "max R = 0.5" :

Coordinates node group :

and for fading on the sides i used a sin function :

render :

• seems like what i wanted, checking details :) – Bithur Feb 13 '15 at 17:28
• the sin doesn't seem to fade the light, it just stops at both ends. – Bithur Feb 13 '15 at 18:19
• it fades but in short range that it's not clearly visible because that's how a sin wave is, you can replace with other functions – Chebhou Feb 13 '15 at 18:26
• Max R=0.5 :) A max value of 1 would be for diameter. – Bithur Feb 15 '15 at 12:54
• yeah, you are right – Chebhou Feb 15 '15 at 13:23

Variation on Chebhou's answer : Origin and dimension independant :

Not sure the sine works exactly the same.

• that's brilliant ! it is dimension ,and origin dependent – Chebhou Feb 15 '15 at 16:26