#OnPostprocessBuild
1 messages · Page 1 of 1 (latest)
I want to create my version of "Static Batching" for ecs
I really need it for modular buildings but i also want to use 500x500 subscenes on editor for authoring and convert it to 80x80 subscenes on build for better streaming
you could look into SceneSection to maybe achieve this much easier? have your scene be 500x500 and each section be 80x80. i havent played around with sections yet but i bet you find some usecases in megacity
This looks really cool. I will look at it yeah thank you
megacity mostly uses for them for lod loading from memory
but yeah sections are still good for this
they actually generate an AABB as well
however this isn't generated from memory when subscene is open
Is there any example for it?
I don`t even need while it is open. This looks really promising
just earlier i created a thread where i use a bakingsystem to add a scenesection to an entity : https://discord.com/channels/489222168727519232/1093414039469690950
you could just hash the x,y coordinates of your section and put it into the section value for example
i'd just create gameobject sections
add the scene section component
and let the level designers break it up themselves however they want
each section will have a SceneSectionData
This is really good way of doing. I will use meters because my game is topdown
anytime you bake it's calculated
public struct SceneSectionData : IComponentData
{
/// <summary>
/// Represents the unique GUID to identify the scene where the section is.
/// </summary>
public Hash128 SceneGUID;
/// <summary>
/// Represents the scene section index inside the scene.
/// </summary>
public int SubSectionIndex;
/// <summary>
/// Represents the file size for the compressed section.
/// </summary>
public int FileSize;
/// <summary>
/// Represents the number of Unity Objects referenced in the section.
/// </summary>
public int ObjectReferenceCount;
/// <summary>
/// Represents the scene section bounding volume.
/// </summary>
public MinMaxAABB BoundingVolume;
internal Codec Codec;
internal int DecompressedFileSize;
internal RuntimeBlobHeaderRef BlobHeader;
}```
` public MinMaxAABB BoundingVolume;`
i just load/unload subscenes
as the character comes in range
unload distance being a bit larger than load
to stop flickering etc
It is really strange, i have a scene with a lot of sections but this is empty
this subscene has a lot sections. More than 400
It is not showing here too
Maybe the problem is i`m assigning sections on a baking system?
Maybe this is the problem
it is the problem but idk how to fix yet. Do i need to always use small subscenes?
I got streaming working except for physics colliders. Somehow they go to wrong scene section.
.Query<LocalToWorld>()
.WithNone<CullingGroupComponent>()
.WithEntityAccess()
.WithOptions(EntityQueryOptions.Default))
{
var section = state.EntityManager.GetSharedComponent<SceneSection>(entity);
if (StreamableScenes.Contains(section.SceneGUID))
{
int sectionIndex = MathUtils.szudzikPair((int)(math.round(ltw.Position.x / 80.0f)), (int)(math.round(ltw.Position.z / 80.0f)));
if (sectionIndex <= 0)
{
sectionIndex = sectionIndex - 1;
}
if (sectionIndex == 57)
{
}```
This is an example code of my baking system but it adds the renderer on section 3 and the physics colliders on section 57
public static int szudzikPair(int x, int y)
{
int xx = x >= 0 ? x * 2 : x * -2 - 1;
int yy = y >= 0 ? y * 2 : y * -2 - 1;
return (xx >= yy) ? (xx * xx + xx + yy) : (yy * yy + xx);
}
this is somehow on section 57
Can i filter it idk? move it to section 0 or something like this?
Or run this baking system before physics?