Size to viewport on static mesh through material

Not a question but an answer. For ages, I’ve been looking how to do a size to viewport option but on a static mesh instead of a billboard as it’s for torches in a crowd, for a fan spawner I’m making. After looking around for ages I couldn’t find anything but managed to form this together.

It consists of a way to size the object based on the camera distance between the object the material is placed on and the camera itself. I have also added a clamp to max out how big my mesh can go as in my case I don’t want my torch to exceed bigger than my fans. Also where it says divide by 500 you can manipulate this to set the scale overall, 500 just works best for me.

Hope this helps somebody as the community has given me so much over the last 4 years:)

1 Like