Topic was automatically imported from the old Question2Answer platform.
Asked By
vctr
Old Version
Published before Godot 3 was released.
I’m trying to create a beam (laser) between two blocks.
It must looks like this (found in Internet):
At now I have a long scaled block in the center. I’m trying to write a shader for it. I’m using a texture and trying mix it with colour to get right result. But it’s not working.
where are you using the shader in?
it seems you didn’t connect the UV input to the UV of the texture, so it wont work
also, you dont need to use a texture for that, you can generate that pattern in a colorramp
Thank you for your response!
I’ve made a few steps to get desired result.
Fix a shader. Connect it to UV.
Use 2 crossed cubes with Z scale equal 0.00001 to build a beam
Apply that shader to cubes
Now it looks like this:
vctr | 2017-03-28 11:12
you can use the colorramp for the diffuse alpha too. in fact, I think your diffuse socket is useless, the colorramp can specify the color and feed the emission output directly, no need for diffuse in this case
anyway, is it what you want or is there still something wrong?
Nuno Donato | 2017-03-28 13:18
Seems it’s OK for me.
Do you know how I can connect ColorRamp to UV?. If I just replace TexUniform with ColorRamp it doesn’t work.
vctr | 2017-03-29 13:42
your texture is basically 1px width and many pixels height, which means X is always the same, it is the Y coordinate that changes the color. so your UV must be split into X, Y, and Z(vector to scalar node), and you feed the Y into the colorramp
Nuno Donato | 2017-03-29 18:21
Now it’s look great! Thanks a lot!
The final shader:
vctr | 2017-03-30 08:24
you could still optimize those nodes a bit but its good!