Justin42
Hello,

I'm currently exploring Voxel Farm for integration into a UE4 project. I've been looking through the API for both the UE4 plugin and the SDK to determine how I can leverage it for my project. Most things are pretty clear and overall I've found everything quite intuitive, however, it's still a very robust and complex system.

First, I'd like to list some things that I've found clear so far. Please correct me if I'm wrong about any of this.

- We can modify individual voxel layers, and optionally persist individual layers.

- We can use this in a multiplayer environment by implementing 'CClipmapView::IRemoteView'. This seems very flexible. For example, the clients could be allowed to generate only certain voxel layers locally, while others are streamed from the server.

- The prefab system can be leveraged to create any kind of procedural structures, using a set of rules to define how mesh instances are placed, which can then be voxelized.

- Planting rules can be used to place mesh instances or voxel instances, either on individual voxel layers, or onto specific materials.


Now, I'm trying to grasp how all of this might fit together to achieve a few specific goals. For the sake of this discussion, I'd like to imagine a simple scene with a log cabin and some trees.

In this example, we have 3 main areas of focus:

1. The log cabin itself.
- This seems to be a job for prefabs and overall seems relatively simple. If this was a player construction, I may opt for using instanced static meshes from within UE4 rather than using voxels. Otherwise, it seems the best way to handle this is simply using a prefab and having it voxelized.

From what I understand, I can use the API to create any number of these prefab instances with different scopes anywhere I want. Though, I'm unsure what my options are for determining which areas to spawn these prefabs at runtime. Can I use biomes? Masks? Voxel layers? Or, maybe just volumes inside UE4?

2. The trees outside the cabin
- These should really be harvestable. I experimented briefly with using planting rules for mesh instances, in that case they seem to be treated as foliage and make use of UEs 'FoliageInstancedStaticMeshComponent'. That's neat, and very optimized, but it's not really ideal for interacting with them. In my quick test I also noticed that if the instance is removed from the 'FoliageInstancedStaticMeshComponent' then Voxel Farm just readds them the next time the cell is recalculated. In either case, mesh instances don't seem to be the best way to handle this. But if I went this route, how would I stop voxel farm from immediately recreating the instance? Can I register some callback to handle the instance creation / removal myself? I see the 'VoxelFarmWorldActor' holds a pointer to a 'CInstanceManager', which has a virtual function 'generateInstances'. Though, it's difficult to tell if this is actually related to mesh instances at all, or how it should be implemented.

A better option seems to be to use planting rules to plant them as voxel instances in their own voxel layer. If I do this, I'm sure it's just a matter of doing a hit test and checking the material ID to see if it is a tree material. Simple. What confuses me here is how I would go about removing the entire tree voxel instance at once without affecting the surrounding terrain. Since it would be on its own voxel layer, could I just set the material within the tree bounds to 0? Is there even a way to get the voxel layer from the hit test?

I watched some videos of gameplay from Landmark, and the way trees are harvested is pretty close to what I'd like. Were they using voxels, or mesh instances?

3. Objects inside the cabin
- I'm not really sure where to start here. These are small objects that would simply be picked up by the player. I wouldn't use voxels for something like this. If the cabin itself is a prefab that is placed at runtime, then it seems I should be able to calculate some complex rules for placing objects within it, using the center point of the scope. Would that work?


Also, I'm happy to hear any suggestions as to how exactly to go about implementing Voxel Farm in a multiplayer environment. While 'CClipmapView::IRemoteView' is the obvious entry point, some of the finer details of actually implementing those functions and efficiently replicating the voxel data isn't so clear. I also vaguely recall reading something about multiple clipmap views, though I'm not sure if that is necessary or a possible solution.

Sorry for the ridiculously long post and all the questions, but at the very least I feel a lot of people could benefit from the answers to these kinds of questions.
0 0
voxelfarmtorres
I believe you got everything right with one minor exception:

Quote:
place mesh instances or voxel instances, either on individual voxel layers, or onto specific materials


Your can place mesh instances on both voxel layers and materials. Voxel instances, on the other hand, can only be placed on voxel layers, not on materials.

About your questions:

There is no callback for instance management at the moment. We are still collecting information from users to determine the best approach. This is high on our priority list. 

We do not recommend you make trees as voxel instances. The voxel resolution may not be enough for branches.

In general, you will have to decide which assets will be represented as voxel and which ones as meshes. Mineral resources do well with voxel instances. Trees and plant, are better represented with meshes.

Landmark used a custom instance system. Instances were precomputed and stored in the server. This was because it was necessary to account for all resources.

If you are designing a custom instance system, it is best if you do it in a top-down fashion. You would have something at a higher level that determines where instances will appear. Ray testing for a particular material after the world is generated is possible, but not practical. This comment in a different post shows how this user implemented a custom instance system: https://forums.voxelfarm.com/post/several-questions-about-accessing-voxel-data-8504419?highlight=instance?pid=1295705728

If your application has knowledge of where a particular prefab should be voxelized, you can use the SDK to run the prefab in that location. We can provide you pointers on how to do this. There is also a Voxel Architecture layer which evaluates and voxelizes prefabs on the fly, as the user approaches them. Since it is realtime, this works better with simpler prefabs.

You can look in the SDK at the Server and ThinClient examples. They show how the IRemoteView is used.




0 0
Justin42
Thanks Torres,

That was quite helpful. It looks like using the SDK to get enough information for handling my own instance placement would be pretty easy. Ideally I'd like to make use of the planting rules from voxel farm, but I can see how that could be problematic.

Consider this a +1 for some kind of instance management API. Even A simple interface with callbacks to notify where instances should be placed would mostly do the trick, then it would be up to the application to spawn and manage them from there. Then we could leverage planting rules while still handling the actual instance management ourselves. If the changes for this aren't too involved, I may be able to handle it myself if directed towards some entry point. Barring that, I'll handle my own placement as well.

I'm a little unclear on the prefabs. My application will have knowledge of where prefabs should be voxelized. You say that I can use the SDK to spawn prefabs in a location, but how does that differ from using the Voxel Architecture layer? If I understand correctly, the first method would be more or less static, not depend on the users location, and could be voxelized anywhere at any time. I think this is what I need.

For my use, the server will handle the actual placement and voxelizing of the prefabs, and then they are only sent to the client as voxel data when those cells are requested. I also need the flexibility of easily removing them, which seems trivial if they are on their own voxel layer. If I understood, this use case seems to fit the first method you mentioned "use the SDK to run the prefab in that location". Any direction towards the SDK functions to handle this would be great.

Thanks again!
0 0