Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  How to make a phone wire
#1
Estrella 
I have no idea how to make a phone wire. I found a SpringRod scene and I hope I can make use of it but I really have no idea to make what I wanted. To be clear I want to make wire like this [Image: depositphotos_5325441-stock-photo-phone-wire.jpg]
I want to increase the length and physics behavior just like a phone wire. I would be crazy to place the points to make spiral shape for a very long wire.
Any help will be appreciated. Thanks!
Reply
#2
Making the entire spiral shape using a rod sounds like overkill.

Instead, just use a straight rope/rod and use a texture or a shader to draw the spiral. Here's a good tutorial on it, it's for Unreal but the principles are exactly the same in any engine:
https://medium.com/xrlo-extended-reality...b47777d8ab

Obi would play the role of Unreal's builtin cable component.

It's pretty straightforward unless you're not comfortable with shaders. Let me know if you need help with it.
Reply
#3
Here you go. Find attached a Unity port of the above tutorial.

Just use the CoiledWire shader in your rope (it's a surface shader, so will work in the built-in pipeline only), and add the CoiledWireController to it.

Here's a video of the result:



cheers!


Attached Files
.shader   CoiledWire.shader (Size: 2.76 KB / Downloads: 86)
.cs   CoiledWireController.cs (Size: 516 bytes / Downloads: 77)
Reply
#4
(18-01-2021, 09:01 AM)josemendez Wrote: Making the entire spiral shape using a rod sounds like overkill.

Instead, just use a straight rope/rod and use a texture or a shader to draw the spiral. Here's a good tutorial on it, it's for Unreal but the principles are exactly the same in any engine:
https://medium.com/xrlo-extended-reality...b47777d8ab

Obi would play the role of Unreal's builtin cable component.

It's pretty straightforward unless you're not comfortable with shaders. Let me know if you need help with it.
That looks cool! I will try your suggestion and come back here if i encountered any problems. Thanks!

(18-01-2021, 10:09 AM)josemendez Wrote: Here you go. Find attached a Unity port of the above tutorial.

Just use the CoiledWire shader in your rope (it's a surface shader, so will work in the built-in pipeline only), and add the CoiledWireController to it.

Here's a video of the result:



cheers!
Wow did you just make it? That's really cool! Thank you so much!!
Reply
#5
No worries! Took about 20 minutes, so I figured out why not make it and save you the pain Sonrisa.

Note you can change the amount of spirals in the wire by changing the "Spirals" slider in the material itself. This could also be added to the CoiledWireController component for convenience (to have both spiral count and thickness in the same place), I leave it as an exercise for you.

let me know if you have any questions. cheers!
Reply
#6
(18-01-2021, 10:20 AM)josemendez Wrote: No worries! Took about 20 minutes, so I figured out why not make it and save you the pain Sonrisa.

Note you can change the amount of spirals in the wire by changing the "Spirals" slider in the material itself. This could also be added to the CoiledWireController component for convenience (to have both spiral count and thickness in the same place), I leave it as an exercise for you.

let me know if you have any questions. cheers!

Hello, is there URP version of this shader? 
Thank you
Reply
#7
(26-01-2021, 09:25 PM)yusufbesim Wrote: Hello, is there URP version of this shader? 
Thank you

Hi!

Unfortunately not Triste. URP is not compatible with surface shaders, and does not have anything equivalent to them afaik.

If you have some experience with shaders it should be possible to translate this to a Shader Graph shader easily though. Here's a link to the tutorial I followed when writing the surface shader:
https://medium.com/xrlo-extended-reality...b47777d8ab

You can also take a look at the surface shader source code for reference.

cheers!
Reply
#8
I've had my eye on this thread for a while, I'm currently making my first game in unity URP which features a telephone wire as well. It's only recently that I've started learning about shaders and challenged myself to recreate this shader both in shadergraph and coded manually. I've attached the hand made files for anyone who might want them.
(dont forget to rename the .cs file to a .hlsl file)

I haven't quite managed to recreate the "curving" effect described in the original blog post (so I didn't include it), but I might try again sometime in the future. (also trying to make them in shadergraph breaks shadows since shadergraph doesn't support multiple passes so I wouldn't recommend anyone else try)


Attached Files
.cs   CoiledWireURP.cs (Size: 3.58 KB / Downloads: 67)
.shader   CoiledWireURP.shader (Size: 2.8 KB / Downloads: 39)
Reply