SteamVR

SteamVR

SteamVR Workshop
Customize your SteamVR experience by finding new backgrounds, 3D environments, controllers and base station models.
Learn More
soontekk 1 21 Feb, 2019 @ 7:24am
Hammer prefabs
As it is now i am creating a model (like a rock) and then dropping,rotating and scaling it into my map. Should i be creating it as a prefab first ? Will that make any difference in performance, file size etc ?
< >
Showing 1-11 of 11 comments
Rectus 13 21 Feb, 2019 @ 11:55am 
Prefabs are just an editor tool that lets you place sets of objects on the map. It made more sense in the HL1 engine when things like furniture were made up of BSP brushes.
Last edited by Rectus; 21 Feb, 2019 @ 11:56am
soontekk 1 21 Feb, 2019 @ 3:04pm 
Ah i see so it could be usefull to create like a tree with some rocks and grass from separate models and make that a prefab ?
Rectus 13 21 Feb, 2019 @ 11:04pm 
Maybe, if you need to paste those props in a lot.
soontekk 1 24 Feb, 2019 @ 2:58am 
Now that i'm starting to fill in the environment of my map i'm starting to see the use of this.
I build small assets like grass, rocks, treetrunks, branches and i can make various prefabs without having to import them as (expensive) models on their own. Live/learn :)
Cargo Cult  [developer] 10 25 Feb, 2019 @ 3:46pm 
Prefabs are also useful for containing reusable entity setups - you might have an animated prop with a trigger around it to start the animation, and having all that in a prefab will let you place it in multiple locations with only one 'master' version to make changes to.
soontekk 1 26 Feb, 2019 @ 4:38am 
Hi Cargo, i didn't think of that and it makes a lot of sense.
Cheers for the help.
glottis 1 18 Mar, 2020 @ 4:59pm 
Originally posted by Cargo Cult:
and having all that in a prefab will let you place it in multiple locations with only one 'master' version to make changes to.

This is exactly what I discovered, I love it. While making repetitive models like windows, which I want certain to remain consistant, so I love being able to just double click, make the change, and it applies it to all of them. So it's a reall cool feature.

Is there a reason not to use prefabs, and to use models instead? After modelling something I have tried right-clicking and Create Model From Selection, but I can't really use them, I have to to admit I don't really know how to even import a model. So everything is just prefabs, I am just using them like models. And if I need a customize it, I just collapse it, make the changes, then re-save it as a new prefab and keep going.

The only thing I don't really understand is the Maintain World Offset or Center On Origin options, which I'm not sure what really does what. Though sometimes I have noticed that I'll place a model (prefab) where I want it, but when I see go in VR it's in a completely different location floating in the air.

Sorry to be a bit off topic, but also why doesn't the location of prefabs "hold" during the map building process?
Rectus 13 18 Mar, 2020 @ 5:32pm 
For static meshes, there doesn't seem to be that much differentce in making it a model. It's mainly if you want to make physics props, or use features like LOD meshes or customize collision. Models get rendered a bit differently than Hammer meshes by default as well, and if I remember right, there are some pros and cons to both.

There are also instances availalbe. They work like prefabs, but don't get saved as separate map files, so they are limited to your current map. They apparently get batched together when rendering, so there may be some performance benefit.

Prefabs get saved as separate maps, so those two choises determine if it saves the prefab content in the same location inside the prefab map as it is in your main map, or if it centers it in the prefab map and adds the offset to the position of the prefab in your main map.

Haven't seen prefabs being in different places in-game. Maybe the view didn't update if you resaved the prefab. I'd imagine reloading the map in Hammer would fix that though.
Last edited by Rectus; 18 Mar, 2020 @ 5:33pm
glottis 1 18 Mar, 2020 @ 7:09pm 
Originally posted by Rectus:
For static meshes, there doesn't seem to be that much differentce in making it a model. It's mainly if you want to make physics props, or use features like LOD meshes or customize collision. Models get rendered a bit differently than Hammer meshes by default as well, and if I remember right, there are some pros and cons to both.

Thank you for taking the time to share your knowledge. In general, is it better to make models in an external program or can I get away with making them just in Hammer, but save them as a model and not a prefab? I will learn a program like Blender if it is recommended but I have no experience with it so it would take a bit of time to actually be productive with it so if I can still make what I want within Hammer I will just stick to it.

There are also instances availalbe. They work like prefabs, but don't get saved as separate map files, so they are limited to your current map. They apparently get batched together when rendering, so there may be some performance benefit.

This is interesting, I will look into Instances... The way you explain them, I think this is what I want... I only use them in a single map anyways, plus nice if there's a performance improvement.

In your opinion, would it be worth it for me to convert all of my prefabs into Instances? It seems to me like it would be.... heavy?.. to have other "maps" loaded in one map, instead of just a mesh?

Prefabs get saved as separate maps, so those two choises determine if it saves the prefab content in the same location inside the prefab map as it is in your main map, or if it centers it in the prefab map and adds the offset to the position of the prefab in your main map.

Ah, I think what I was doing, I was probably saving the mesh as a prefab but setting the origin as it's own world origin instead of where it was in my map, so when it loaded into VR it was 'snapped back' to it's home map origin location?
Rectus 13 19 Mar, 2020 @ 1:16am 
It depens a lot on what kind of models you want to make, but for things like buildings or large simple props like doors, you can definitely get away with using Hammer. For more detailed things, and things with uniquely UV mapped textures, a proper modeling tool like Blender is much better. The model importing workflow to Source 2 is still pretty tricky too.

By default, prefabs get merged into you main map when you compile it, so there shouldn't be any performance loss. I wouldn't bother converting them to instances if you already have them made. The benfits from batched renering of instances probably won't have any noticeable impact unless you have a very complex map.
glottis 1 19 Mar, 2020 @ 4:23pm 
Ok, I'll probably just leave the prefabs I got but I'll be using instances a lot now moving forward.

Thank you!
< >
Showing 1-11 of 11 comments
Per page: 1530 50