#archived-dots
1 messages Β· Page 120 of 1
@odd cipher You can just use an int or enum for ID purposes
yeah I do but they have names too
like in minecraft, you wouldnt see Dirt named 1 would you
you can have table with id and names
I suppose that will do yes
Pretty sure that's also how Minecraft works
:p
you can store it in human readable format and it will be pretty easy to modify π
you wouldn't see 1 at all
its a binary format with at least RLE typically in voxel chunks
okay so
var threatTables = entityManager.CreateEntity(typeof(ThreatAllyMasterTable), typeof(ThreatEnemyMasterTable));
var allythreatTable = entityManager.GetBuffer<ThreatAllyMasterTable>(threatTables);
var enemythreatTable = entityManager.GetBuffer<ThreatEnemyMasterTable>(threatTables);
foreach (var item in AllyEntities)
{
Debug.Log("Adding to Ally");
allythreatTable.Add(new ThreatAllyMasterTable { entity = item, threat = 0});
}
foreach (var item in EnemyEntities)
{
Debug.Log("Adding to Enemy");
enemythreatTable.Add(new ThreatEnemyMasterTable { entity = item, threat = 0 });
}
I am doing this in a MB, that is being called from a system that is run with WithStructralChanges and Run
the moment i am trying to add to those buffers it says NativeArray has been deallocated, it is not allowed to access it
i also tried to do add to list first, then clear buffer and do AddRange, but the moment i do Clear it gives the error
so i have no idea what is going on here
Okay nvm, i just read the documentation and it says dynamic buffers get invalidated if a structral change happens, which i was doing after i get those dynamic buffers
soo.. a NativeArray cant contain a struct that has a NativeArray in it?
I'm soo close to getting it to work with Burst but aghh
there is FixedList
@warped trail Burst error BC1020: Boxing a valuetype `int` to a managed object is not supported
nevermind
well, I got burst fully working! aside from the fact that there doesnt seem to be a big difference
and I think its because I'm using a NativeMultiHashMap
there is specific job for NativeMultiHashMap π€
I think its this loop part that is slow ```public NativeArray<Color32> GetSprite(TerrainSprite name) {
NativeArray<Color32> colors = new NativeArray<Color32>(terrainSpriteSize * terrainSpriteSize, Allocator.Temp);
var valueEnumarator = colorTerrainTiles.GetValuesForKey(name);
int i = colors.Length - 1;
while(valueEnumarator.MoveNext()) {
colors[i] = valueEnumarator.Current;
i--;
}
return colors;
}```
Have you checked the profiler?
1 sec
I mean, you can't really tell whether that part is the one being the problem if you haven't profiled it
not really sure what to be looking at
but with all the jobs together it took 900ms to generate the map
I'm sure there is some better way or something else to use other than NativeMultiHashMap
if its taking 900ms either you are not using burst or you are creating lots of stuff from managed world
well it has now π
can you profile how much ms each job takes ?
~150
all that yep
hmm, you are not using ECS right ? you are doing this all in MB ?
MB
are jobs dependent on each other or do they can run in parallel ?
how many jobs you have ?
how do you know
idk, its your code π
what i am trying to make sure is, if these job can run in paralel you should do JobHandle.CombineDependincies
and how many tiles do you have?
40,000
then you are probably doing something not good enough π
what is your batch size that you provide to parallel job ?
had it at 5000, but I got more performance at 1
yeah, the more expensive the job is the less batch size should be used.
hmm what else π€
well, i guess its all about algorithm then, burst already halved your execution time so thats good
yeah im like 90% sure its because of that NativeMultiHashMap loop
70 to 900 not quite halved π
which gets done 4 times per tile
well before Burst and all that it was 70
70 ms ?
why do you use HashMap?
so wait, you init 40k tiles in MB in 70 ms ?
I render 40K tiles in 70 ms
i mean thats already pretty good performance
yeah and I guess I could just revert to that and discard my 32 hours of time spent refactoring :>
but yeah should I send the Job in hastebin?
i think there is something going wrong here, idk
even if job were to take longer it shouldnt be that drastic
yeah please
heres the Job https://pastebin.com/3j9umAJ4
so, you said you render 40k tiles in 70 ms, but how much does it take to create those tiles ?
you do create those tiles inside a job right ?
no they are created outside but thats how it was before too
wait crap I cut some code out of that
π
so you store your tile table in hashmap?
Just saw the ping from you, not sure if you still need the new tile stuff.
i think you can make colorTerrainTiles ReadOnly
no sorry, I figured that out Burrito
no
Because if you only make changes to them sparingly, there's no point in recalculate texture for all of them every frame.
If you change one tile, you only need to recalculate that tile and the surrounding neighbours.
yes I know
is GPU instancing for your material enabled ?
i think CodeMonkey had something about that
I dont know what GPU instancing for my material has anything to do with this but no
GPU can draw all of your tiles in one call, if enabled.
didnt change anything though so
is it unlit
I think you should profile it and see where the bottleneck is, before making changes.
CodeMonkey mentioned that (because of a bug) it only worked with certain shader, i forgot the name now
I suspect your bottleneck is simply your job recalculating 40k tiles every time
but anyway, i think i cant help you, hopefully more experienced people can
It doesn't scale well.
@lusty otter right yeah but I used to do that at 70ms before so
thought changing to burst would make it quicker
70 to 900 tho π
i was in your situation as well, some calculations i was doing was taking 50-60 ms, i wanted to use job and burst compile but it didnt work because i had to read from dict to create structs, send them to job so it can calculate then i set the dictionary from the values job created, but this made it happen to 100 ms since i was accessing dictionary twice
it was a big dictionary π
I see.
but 70 to 900 seems pretty extreme
yeah actually more like 70 to 150
I can't help much without diving deep into your project and even then there are people much better than me at this, sorry π
i mean burst is pretty good at calculating stuff, not sure about rendering
I'm fine with 150ms but I thought there would be more than that
I have 10k cubes which move up and down
is this a decent fps count for that? i never tried 10k cubes without ECS π€
I imagine doing the same with monobehaviours would be... stuttery. Don't get too stuck on the specific numbers - they're kinda useless unless you have a way to compare them (ie. have run two different versions of some code, and measured both)
I was just wondering if I am doing it right
Have you checked the entity debugger to see what takes the most time?
That would be useful info for optimizing, should you need that.
I'd say you aren't doing it wrong as long as it runs fine
The profiler is also great
Not sure. Either the time to draw or the time for it to read the positions and all that to send it to the GPU
The profiler lets you see system vs draw time
i apparently have spikes where its 15 fps
When that happens, pause the sim and click the spike to see the details of what happened
Mind you, it could well be because you're profiling or something else
oh
Especially if it's when you swap to it at that moment
by default JobDebugger and LeakDetection is On
you can disable them to see real performanceπ
You can also 'zoom' in the profiler to see more details, including how long each system and system group takes
and it is better to test performance in builds π€
That would be the editor
oh i see
And it has.... some overhead
Anybody managed to use the Build Configuration stuff to build a headless server? Just the Net Code Conversion Settings alone don't seem to do the trick.
Zoom in and see what takes time compared to other stuff. My guess would be that something runs only every few frames
Since you're storing colors of a bunch of tile varisnts it could end up being a very large array but the math to get the proper index is pretty straightforward
Tiletype * (TileSize * NumVariants) + (Tilesize * Variant)
@zenith wyvern when you get back online, do you think you can elaborate on this? I think it could save some frames, also I did get Burst working but the result was... underwhelming so trying this.
I don't see anything under the editorloop. I am building the game now with a fps counter
do i have to pay attention to something when building it?
you can attach profiler to build
@odd cipher Do you have collection checks disabled when profiling?
Jobs->Burst->Safety Checks
both those are off
Is there any performance benefit of using JobComponentSystem vs ComponentSystem ?
I don't understand the difference
@gusty comet use SystemBase
π€
JobComponentSystem and ComponentSystem are doomed to be deprecated
and read Entities documentationπ
Right, so I've just got to make custom build player step for the pipeline.
How can i access this field in runtime on instantiated entity
I set it to 0.34 there
But i can't see any 0.34 in entity debugger when i look at that entity
did u get the Physics shape component?
it seems friction is indented a bit more than material so it is probably under physshape.material.friction
@round summit
@gusty comet Is there a physics shape component?
I see only a PhysicsCollider component but it doesn't seem to include matial field
There is no PhysicsShape component
@round summit cs var colliderPtr = (SphereCollider*)collider.Value.GetUnsafePtr(); var material = colliderPtr->Material; material.Friction = 0; colliderPtr->Material = material; something like this i guessπ€
collider is PhysicsCollider
but be careful, instantiated entity has copy of collider pointer
Collider doesn't seem to have a material field π€
public struct MassProperties
{
public static readonly MassProperties UnitSphere;
public MassDistribution MassDistribution;
public float Volume;
public float AngularExpansionFactor;
}
Not here neither
look at other colliders
like SphereCollider, BoxCollider etc
they all implement IConvexCollider
Is unity.physics for ecs ?
Oh i see thanks @warped trail
Yes this is ecs
I don't know why they didn't port it to monobehaviour, that's what i've been trying to do in last weeks
so how can you do something like this (IConvexCollider*) ?π
why do they need to port it to monobehaviour?π€
How do you get the Physics?
@warped trail Am i the only one who wants to have stateless physics in monobehaviour?
public class MoverSystem : SystemBase
{
protected override void OnUpdate()
{
// Local variable captured in ForEach
float dT = Time.DeltaTime;
Entities.ForEach((ref Translation translation, ref SpeedComponent speedComponent) =>
{
translation.Value.y += speedComponent.speed * dT;
if(translation.Value.y > 10)
{
speedComponent.speed = -math.abs(speedComponent.speed);
}
if(translation.Value.y < -10)
{
speedComponent.speed = +math.abs(speedComponent.speed);
}
}).ScheduleParallel();
}
}
is this good?
i think yes
Changed to SystemBase
Am i the only one who wants to have stateless physics in monobehaviour?
Out of the ones that want the stateless physics
π€·ββοΈ
wow SystemBase is so much better
#define USE_SYSTEM_BASE
using System.Collections;
using System.Collections.Generic;
using Unity.Entities;
using UnityEngine;
using Unity.Transforms;
using Unity.Mathematics;
#if USE_SYSTEM_BASE
public class MoverSystem : SystemBase
{
protected override void OnUpdate()
{
// Local variable captured in ForEach
float dT = Time.DeltaTime;
Entities.ForEach((ref Translation translation, ref SpeedComponent speedComponent) =>
{
translation.Value.y += speedComponent.speed * dT;
if(translation.Value.y > 10)
{
speedComponent.speed = -math.abs(speedComponent.speed);
}
if(translation.Value.y < -10)
{
speedComponent.speed = +math.abs(speedComponent.speed);
}
}).ScheduleParallel();
}
}
#else
public class MoverSystem : ComponentSystem
{
protected override void OnUpdate()
{
float dT = Time.DeltaTime;
Entities.ForEach((ref Translation translation, ref SpeedComponent speedComponent) =>
{
translation.Value.y += speedComponent.speed * dT;
if(translation.Value.y > 10)
{
speedComponent.speed = -math.abs(speedComponent.speed);
}
if(translation.Value.y < -10)
{
speedComponent.speed = +math.abs(speedComponent.speed);
}
});
}
}
#endif
100k cubes
ComponentSystem is around 13 fps and Systembase is around 50 fps
(in the editor)
now i am impressed
Thanks @warped trail
this is old rendererπ
What do you mean? :o
And where do I get ECS physics? I don't see it in the package manager :c
look for Unity Physics
no it is 2020+ only
and you have to download specific project from github
Do these things also work on all platforms btw?
(or eventually will when they are out of dev)
π€·ββοΈ
probably don't bother with new renderer until they release it properlyπ€
So this version is using V1 of Hybrid Renderer I guess?
An error occurred while resolving packages:
Package com.unity.jobs@0.2.7-preview.11 has invalid dependencies:
com.unity.collections: Resolved version [0.5.2-preview.8] does not satisfy requested version [0.7.0-preview.2]
Tried to install Unity Physics >_<
update or downgrade required packagesπ
How do I add this ? https://github.com/Unity-Technologies/ScriptableRenderPipeline/tree/hybrid/hybrid-instancing2
imo, just wait for proper release π
i want it now >:c
π
no idea
its just that i got weird errors in 2020.1 for some reason so i downgraded
:c
i managed to run it, but there there was no support for any lights except 1 directional light in URP π
i hope it is just a bugπ
this is what i imported, don't if it is correct, but i managed to launch project π
well now it wants shadergraph
do I understand it right that the jobs I start in InitializationGroup can also still run in SimulationGroup?
because I specifically need to pass in the jobhandle if I want the job to finish before the EndInitializationECB
there is AddJobHandleForProducer(JobHandle) in EntityCommandBufferSystem
Can you point me to where the sample projects are?
just wait for proper release, your disappointment will be immeasurable and your day will be ruined
exactly
In the dots physics when i create an entity in code do i add a component of type PhysicsShape to it ?
is there a github to previews of com.unity.entities as well like there is for that renderer?
thx xzjv
@zenith wyvern @amber flicker i found out why Transform System was taking 20 ms, because it was fairing for my raycast system which takes 15-16 ms, i am working on how to reduce them now
@warped trail it can't find RenderMesh with this setup? What do I have to use then?
make sure hybrid renderer is installed as a package
Oh about that, I wanted to try out hybrid renderer v2
o - w/ the new sources from github?
well i thought so
but apparently i am missing something
Is V2 included in the 0.4 Hybrid Renderer ?
yeah you just need to put the scripting defines
yeah will do that
im curious as to how people write graphics tests π€
btw why does unity now open scenes in the visual studio
double click or press open => vs
that might be an issue with the visual studio package?
just wait for proper releaseπ
Well that should be fine for the time being - it wont be removed immediately
but i can't run with errors
that should be a warning tho
Oh I see - guess it was different in my project
What package is bugging it?
I can't locate the issue
also 2020-06-20 ? Is unity doing time travel now? 
wait
it just means they'll remove the feat for good by that date
@warped trail @coarse turtle did you really try v2 ???
https://forum.unity.com/threads/hybrid-rendered-v2-dependency-urp-9-0-0-missing.846421/#post-5590225
I tried it
nope
it says u need b3
and no, there's no official 9.0.0
which is not out yet
there is master branch on SRP github tho
but 2020.1.b3 is not out yet?
that being said
IMPORTANT: Unity 2020.1.0b3 is a hard requirement for Hybrid Renderer V2. Visuals will be completely broken if you test with earlier version (such as 2020.1.0a25).
no it's not
we just got b1
so how would you even have tried it
well, I didn't say it worked perfectly
-<'
there were meshes missing and stuff
ok
π
and like people before warned here you'd better wait if you want better experience
pretty sure b3 isn't a thing yet even
I'm not sure if even b2 is up internally yet as it doesn't show up in issue tracker yet
when they say you need b3 to run this, it means they have the changes launching on b3 eventually
right now they are just running this internally from their dev branch / turnk
also meaning, they probably missed the window to sneak these changes into b2
so b3 it is
wait 2 weeks basically
Official URP support (minimal feature set) i hope minimal doesn't mean only 1 direction lightπ
does it also add support for one-off rendermeshes?
without those getting their own chunk mansion
oh I missed that they finally updated online docs for new hybrid renderer
Just found out about DOTS this morning, I am so excited to learn this!
The main thread bottleneck of Hybrid Renderer V1 is gone, and render thread performance is also improved. The new data model allows us to feed the shader built-in data from C#, allowing us to implement missing HDRP and URP features.
@zenith wyvern when you get back online, do you think you can elaborate on this? I think it could save some frames, also I did get Burst working but the result was... underwhelming so trying this.
@odd cipher
Not sure what else there is to say about it, you store all the content for a given variant within a subsection of the array, and access the subsection based on the size of the content.
heh IMPORTANT: Hybrid Renderer V2 is experimental in 2020.1. We have validated it on Windows DX11 and Mac Metal backends in both editor and standalone builds. Our aim is to validate Vulkan, DX12, mobile device and console platform support for 2020.2
this explains why I got nothing on DX12
I don't think the proper unity version is out for it though is it?
do you have any hints if lightmapping is part of v2?
when 2020.2 :P
2020.2.0a3 can already be seen on issue reports
would expect public alphas this or next week
but it'll probably take a long time to get that DX12 support there
do note that 2020.2 is set to release on Q3/Q4 this year
so it's going to be the longer alpha/beta period in recent years
there's only two tech releases this year, 2020.3 is going to be the LTS
(which is supposedly out in 2021)
I have a world made out of tiles (one tile is probably as but as a minecraft chunk). But it won't be infine. How should I create the meshes for the world. I want the tiles to be able to change colors (I could do this through the Color array and using or writing a shader that uses the color array). What should I do:
- One big mesh for the whole map
- Small chunks (say 5x5 tiles), with different meshes (for the height), and different color arrays (for different colors) but the same material
- Every tile is its own entity/mesh (all the same mesh now, just different positions at which the meshes are rendered) and a different color property (now color is just a material property, not the color mesh array, which maybe makes it easier somehow?)
Any help appreciated, I just don't want to spend a lot of time doing the wrong thing in case one of the ways is obviously better
btw, have any of you looked at the hybrid v2 code?
they literally have few line files for those material property overrides now for HDRP and URP
so you think I should use the third way to use the material property?
it feels bit hacky but I guess it gets the job done
ah, I'm just wondering about hybrid v2 in general here
but it's supposed to ease the pain on setting those properties too
so if you need it, might be worth waiting few weeks
hmm, I don't need it yet I think I can do with Graphics.Draw, but if one of the ways is obviously more clever in future I would chose that
i wanna try it now
Hi. Seems to me that Dots requires the user to know alot more math or i'm not going to the right documentation.
I'm trying to make my object rotate to aim where the mouse is. But the way i'm doing, the object is moving in the scene. I know i'm doing something wrong here, but i'd like a help.
The mousePosition is a float3 with the world position.
My game is 3D but i'm doing a 2D game using X and Z positions.
Can anyone help me make my 2D aim to where the mouse is or tell me what am i doing wrong?
Thanks.
@gusty comet it's not going to work properly without those beta 3 changes tho π
and there's nothing you can do about it but wait
Yeah .. anyway I am trying the physics now but it's a bit confusing looking at this :
I learned to create an entity via the manager
just create entities through authoringπ€
authoring?
conversion scripts
there's conversion from rigidbody and colliders but you can just use the new authoring components for physics body and physics shapes
I do latter
just put Physics Shape , Physics Body scripts and ConvertToEntity script
@glad solar you sure this is the only system that affects the player ? your player shouldnt be moving at all with this system, you are just rotating your player and thats all
@opaque ledge, i deactivated it, but it still moving depending on the angle it looks towards mouseposition.
The object have Rigidbody
o i got it to work, i didnt know what to pass in rendermesh but i just had to do the same as before
sooo, what you want your system to do then ?
i thought you didnt want it to move, just rotate ?
Just rotate (look at) to where the mouse is.
Right now is very glitchy
then disable that movement system
you can put [DisableAutoCreation] attribute to your system calss
Ok so my collider works when i set its size as i want but the mesh ofc stays the same size, how do i scale that up?
scale meshπ€
Like I have this simple cube selected as the mesh
See that blue cube that should cover a wider area. The collider as you can see is as far as I want it (the boxes above not falling through)
you are creating it in code?
The cube no, I still have it selected in the inspector
I think it's default cube
Like normally on a gameobject you can scale it it looks bigger
~~o or i just draw 100x100 cubes ~~
i guess you are following some old tutorialπ€
have you looked at official unity ecs samples?
not that
o nice thx it even has physics samples
and this video https://www.youtube.com/watch?v=TdlhTrq1oYk
o damn
thx
will have a nice watch later
btw thats a meat texture i just found today on textures.com 
erm if I remove and add a component in an ecb
please tell me it will do the magic of just not doing anything?
I mean of just changing the component data maybe, but not actually copying it to a different archetype in between
or how should I do this:
I have some entities that have a component X currently and I have a new set of entities that will now have component X (it is just a tag component, which meshes to draw). I want to most efficiently only remove the X from the entities that don't need it anymore and add it to the new ones
if I would just remove it from all that have it currently and then readd, it would do a lot of copying I am scared
adding/removing is structural change, so yeah they will be traveling from chunk to chunkπ
yeah I hoped that the ecb will notice this
if I all submit it to the same ecb, he might only do the copying in the very end and then there won't be much copying necessary
that was my dream
you are removing component from entity and then adding it again?
You can use batch operations by passing entity queries to the ECB on the main thread, that will be pretty fast
@warped trail yeah as I described above
hmm I now added a bool to the component X, to check if it should still be there
then I will just remove only the X that that should not still be there
can't you just not remove it at all?π€
You could always use state components to track newly created entities. This is pretty much what they were made for.
If you're not tracking external state just use a normal component, like a "RemoveX" component
``` I am using Rider 2019.3 if that makes a difference. I could use ```World.Active.EntityManager```, and it didn't tell me that that was depreciated
the first one wont resolve symbol
Its a monobehaviour
what entities package ?
Its not rider - same issue in VSCommunity
entities preview 0.1.1
unity 2019.2.2.f1
well, entities package is 0.8 now
lemme upgrade unity version
you need 2019.3 i think at least
what about using beta 2020?
yep, thats also way to go, it gives me weird errors so i downgraded to 2019.3.5
i probably will try to upgrade it at b3
π
I will learn from your issues and stick with 2019.3.5 for now π
π
``` Let me try a fresh install instead of an update
those packages are connected to each other so you have to upgrade them all
except platforms
that was after updating to .8 and hybrid to .4
entities, burst, collections etc.
yeah, package manager is kinda derpy
collections is installed and up to date, going to try fresh
just restart unity π
i did
well deleting library folder can also help, but yeah maybe try it on new project
Usually you shouldn't have to install Entities at all
Just install Hybrid Renderer, and it will automatically get the right dependencies
Should also work when updating
i'll keep that in mind bmandk for next time
There are a few times where it derps out though, so this might be it
@opaque ledge Thank you, it works now
I just noticed that 2d finally seems to have gotten some love. Admittedly it has been a while since I last checked
is ECS going to be the default way to program in unity eventually
MonoBehaviour is not going anywhere π
I doubt that given how much they emphasized the conversion workflow intially. I hope it will be but I highly doubt it.
I am fine as long as there are means to go full dots eventually if you so choose.
oh
tho its likely that "final" ECS editor does have something like conversion workflow, it has its uses after all, like flattening hierarchies
I mean if you have a full dots enviroment there is no such thing as a hirachy anymore I would say.
oh there is
prefabs and other stuff, people do still want to abuse hierarchies for scene editiont
On the note of dots though, are there any recent tutorials especially on the 2d side of things?
yep conversion has its uses as editing a character in a native ecs editor today would be pure hell, so many buffers/arrays to keep track of and floating entities that are actually connected parts of it
@gusty comet no, but the Tiny 2d samples are pretty great
Where can I find those? I just installed the package via the package manager
Because I learn best by picking apart working code. So looking at them would be a good thing to do.
For reference I am speaking of the 2D Entities package in version 0.22.0
I don't suppose anyone can figure out what I'm doing wrong, and why I can't run this job multithreaded?
why not just make RequireSingltonForUpdate() instead of this? cs if (!HasSingleton<BezierGraphSpawner>()) { Debug.Log("There is no Bezeiergraphspawer"); return default; }
ok yeah, good point
is there a definite pure ecs tutorial that covers all the basics, like physics and stuff? or do i just look around and skim what i can?
I still just get the error The previously scheduled job Bezierecs:<>c__DisplayClass_OnUpdate_LambdaJob0 writes to the NativeArray <>c__DisplayClass_OnUpdate_LambdaJob0.Data._lambdaParameterValueProviders.forParameter_moventy._type. You are trying to schedule a new job Bezierecs:<>c__DisplayClass_OnUpdate_LambdaJob0, which writes to the same NativeArray (via <>c__DisplayClass_OnUpdate_LambdaJob0.Data._lambdaParameterValueProviders.forParameter_moventy._type). To guarantee safety, you must include Bezierecs:<>c__DisplayClass_OnUpdate_
yeah codemonkeys tuts are good
oh yeah i have that open in another tab. just making sure i start with what's recommended
we're all just winging it basically, learning, and then having to relearn things as they change
@pliant pike you are not returning valid inputDepsπ€
@pliant pike not sure if that's the issue, but you are not returning the JobHandle from the Entities.ForEach
inputDeps = Entities.ForEach(...).Schedule(inputDeps);
return inputDeps;
^
I didn't think you had to do that π€
Not if you're using SystemBase
unless there was dependancies
this is SystemBase thing
if you use systembase you dont
I don't even know what systembase is
If using system base you don't need, but then you shuldn't pass the inputsdeps in the Schedule too
where you inherit from JobComponentSystem, inherit from SystemBase instead
But as this is a JobComponentSystem, then you need
there will be errors at first
shucks I tried the github sample project that was posted but it seems to be out of date.
@gusty comet what do you mean?
Ok then thanks everyone
This is what I get when trying to run the sample scene
camera cant be in subscene yet. I had the same issue
try build, tiny is not friendly with editorπ
oh it works in build? did not know
Well that does not help me much If I have to build every time I want to see something?
welcome to tiny π€·ββοΈ
but you can build from IDE if you have only code changes π
You have to keep the Main Camera SubScene open in Edit mode at all times to see anything being rendered in the GameView window
tbh, I'm not sure if even that is enough
it isnt
it at least renders now but a blank screen
This is why I was saying way back in october it needed another year.
try running once?
ok this sounds alarming: But on the other hand, we do believe dots runtime as a framework can scale in every dimension very well, and in the long term we believe it will actually scale better than hybrid. I'd hope that we can even make a UI situation that you would prefer to the current hybrid one, but we'll leave that for you to judge when we ship it.
I know I had to do that
ok I've done the above, now I just get that error once ate the start instead of constantly
that sounds like they make DOTS ui solution that only works on tiny / dots runtime
π
and Unity has already said earlier they are making UI Elements runtime work with DOTS I think
so it's all messed up again
URP, HDRP, Tiny3D, Tiny2D, BuiltIn
we going to have like 5 UI solutions
IMGUI, UGUI, UIElements, DOTS UI
well 4
and I'm going to use all of them to make a frankenstein UI
what's the context here? maybe they mean editor UI
oh wait
meh, dont count IMGUI imo
they might not even talk about game UI on that comment π
Is there a DOTS UI? And UGUI is for GameObjects
they could really talk about dots editor again
why not? you can still use it in runtime.
both IMGUI and UGUI is being depracted anyway in favor of UIElements
IMGUI is really old
it's a nightmare I do not want to relive, but you can
So UIElements is the future
at this point, I'm so confused that I have no clue anymore
I'm surprised it's not just stripped out at this point
the editor UI depends on it
yeah
used for some editor still if I recall
when I started using Unity, there was only wonky ui
is that IMGUI?
one we had on editor before ui elements?
yeah
GUILayout.Label("This one...");
yeah
is there not even a full documentation on 2d entities or am I just blind?
thanks, its weird because it did not show up through the documentations search function
package docs are elsewhere
ah that would explain it
basically the old docs have stuff that are not in packages
and each package have their own doc page which isn't integrated to the old doc system
I actually like UGUI, but the web designer in me is very excited for UIElements
I absolutely hate UGUI for making me assemble the UI in scene
or prefab but it doesn't take the point away
I prefer that over having to use something css like
that's UI Elements for you
where the hell did SystemBase come from 
systembase is cool
I thought I was just getting used to JCB's
and that's DOTS for you
I can't remember how long they've kept some base usage api intact without replacing it with the new thing
and now they are deprecating IJobForEachπ€
yeah, I think SystemBase is at a really good place. getting to the comfort level of MBs in a way
tbh, I'm not missing that injection stuff at all
I'm just now reading the docs and finding JCS are being phased out dammit 
yeah exactly DROD, more systems i write more comfortable i become with it
but i dont like loong lambda parameters π
how would you make it more concise?
to be precise i don't like formatting partπ€
I am even more confused now did what the doc said and I end up with this.
So yeah it works but what the heck are the various entities there?
All the tile has is literally one sprite
scene usually has some "overhead" of several entities. just some helper entities.
given I see an entity with just the texture on it looks like a massive amount of overhead for some arcane reason.
your main camera has a main camera in it, is that normal?
I might be totally of there mind you but it looks like that.
Thats what the doc said to do
put the main camera in its own subscene and the sprite in another.
my main camera doesnt have an object under it on a fresh project
The subscene holding the Main Camera is just named "Main Camera". Doesn't have a camera of its own.
Guess I wait for a few more month. The more I look into it the more this looks cobble together.
In a nut shell im trying to spawn RenderMesh with a random color. This doesnt work but this is where my brain is at: _entityManager.GetComponent<RenderMesh>(entity).GetComponent<Material>().color = Random.ColorHSV(); I can set my position using _entityManager.SetComponentData(entity, new Translation { Value = position }); But if i do new RenderMesh in the above the material that i have access to cannot access the .color property.
@finite ibex Use the ECS-version of MaterialBlocks to control materials, see my post here:
https://forum.unity.com/threads/per-instance-material-params-support-in-entities-0-2.782207/
Thank you, i will take a look
for hybrid renderer v2 there are override components i think
you can pass even multiple params to your shaders, not just color. Hybrid V2 also has component material overrides, but we're waiting on HDRP 9.0 and 2020.1 beta3 to use that.
var renderMesh = _entityManager.GetSharedComponentData<RenderMesh>(entity);
renderMesh.material.color = Random.ColorHSV();
_entityManager.SetSharedComponentData<RenderMesh>(entity, renderMesh);```
afaik that will change the color of all entities sharing that mesh, ie in the same chunk.. no? The correct way to do this is as outlined in my post (and the Hybrid V2 docs).
man
it's so weird they call it hybrid renderer v2 when the previous hybrid renderer was also referred to as v2
so now it's a different v2
totally agree
there was RenderMeshSystemV1 a long time agoπ§
yeah before the hybrid package π
@flat talon Do I need to do something to open the lit shader? UnityEditor.ShaderGraph tab opens but its a blank, and then i get this. Exception thrown while invoking [OnOpenAssetAttribute] method 'UnityEditor.ShaderGraph.ShaderGraphImporterEditor:OnOpenAsset (int,int)' : NullReferenceException: Object reference not set to an ins
...yes im still on step 1 π
until we get HybridV2 you might need to create your own shader graph and expose a color parameter.
my instructions are perhaps a bit confusing, in step #1 I meant create a new shader graph (based on lit)
I did Shader -> HDRP -> lit graph
but i cant open that
I get a windows pop up asking me what application to use
and the editor bugs out
that is very strange. Do you have the shadergraph package added ok?
yeah its there
when you have your new file selected, what do you see in the inspector?
should look like this
then you can press the Open Shader Editor button or simply double click on the file
I think the problem might have been i didnt press the compile button, its doing something
lets see if it opens after that
its been stuck on 105 of 113 for 5 minutes, idk what im doing
what Unity version and HDRP version are you on?
2019.3.5f1 and 7.1.8
that should work, but I believe that v7.2 was the official non-experimental release
as for what i see, i see what you see but a compile button and no 'preprocess only'
it says im up to date, so idk
Does the HDRP wizard window find any errors? (Window->Rendering->HD something, can check for you in a bit)
oh lots of things to fix
also tells me 7.2.1 is available but package manager says im up to date so ..... idk
I think i'll put this to the side, im still early in learning ecs and my question was to understand a bit better, which i do. I'll bookmark your post and revisit when im more mature in my understanding
tyvm for your help!
your welcome π I know its a lot to take in, even a whole new renderer
to be fair i dont think i even touched the old one yet
Can anybody think of a way to achieve sorting in a NativeMultiHashMap?
as far as I can tell the sort is not guaranteed
One solution I can think of is to add the sort order as a property on each entry
"Mean to be" is one way to look at it for sure, but there are uses for ordered sets
Would be nice if there was a NativeSortedMultiHashMap π
NMHM is already pretty slow without adding sorting to it
Unless someone can think of a better data structure? I need to store an array for every [X,Y], the array length is not fixed.
I think if you need something like that your best bet is to try to collapse it into list
Seems like that would be challenging since it's not fixed length per coordinate
Maybe a second list to track how many per set
i see
interesting proposition
i guess the problem there is that lists need to be allocated aot
i dont know the length aot
You could always check the source for NMHM and try to extend it to be sorted
could maybe do a nativehashmap that points to an entity with a dynamicbuffer on it
and sort the dynamicbuffers
But yeah I think it would be very slow
i may stick with sorting jit for now. the number of items in the array is trivial - usually 3, rarely more - so maybe it wont be that slow π€
no, there was RenderMeshSystemV2π
to make this even more clear hybrid renderer v2 is introduced in hybrid renderer 4.0
Do you mean 0.4? π
be ready for Hybrid Renderer NT and XP π
v2b
How does Unity determine/extract info about component array order within a chunk?
Is there some sort of explicit type order? Is it arbitrary, and the chunk header just has full pointers to the head of each array?
Just curious.
@zenith wyvern Just unsure how to make it work with my "TerrainSprite" struct and such
@spring hare I think it's arbitrary. Though it's alphabetical in the inspector π€·ββοΈ
So I guess chunk header data determines where the start of each array is?
@spring hare afair the archetype stores the offset for each component for its chunks, but the order is essentially random
I see
Do you know how archetypes store component membership info for when queries are first built? Is it some sort of bitfield mask, or an array with component type ids, or something else?
Maybe the component membership for an archetype is associated with that archetype through some external data structure?
Last time I dug deep into this code was ~v0.2, if you are interested I'd recommend looking into what CreateArchetype() does, since it is guaranteed to touch all those data structures
^ how do I figure out exactly what/where the problematic allocation happens?
the stack trace doesn't go through my code, but I assume the object was allocated 8 frames ago or whatever
I"m not sure how to track this down
I dont even know if it's happening on the server or client
turn on leak detection
@zenith wyvern Hey, when you get back online, do you mind talking in dms about some things in my code? So I dont clutter this chat as much π
@odd cipher Sorry I'm just coming off an insane work week, not really up for a one on one code review, hahah. I'm happy to give you some general advice here as long as it's on topic. My one suggestion is to dial everything way back. Like Topher suggested it seems like you're pretty out of your depth. Learning dots is hard enough without trying to build a complicated framework on top of it at the same time
Im trying to Spawn an Entity from prefab, but it's not showing up. What do I miss?
using UnityEngine;
using Unity.Entities;
using Unity.Mathematics;
using Unity.Transforms;
namespace ShiftBall
{
public class Startup : MonoBehaviour
{
[SerializeField] private GameObject playerPrefab;
private Entity playerEntity;
private World defaultWorld;
private EntityManager entityManager;
void Start()
{
defaultWorld = World.DefaultGameObjectInjectionWorld;
entityManager = defaultWorld.EntityManager;
var settings = GameObjectConversionSettings.FromWorld(defaultWorld, null);
playerEntity = GameObjectConversionUtility.ConvertGameObjectHierarchy(playerPrefab, settings);
InstantiateEntity(new float3(4f, 0f, 0f));
}
private void InstantiateEntity(float3 position)
{
var entity = entityManager.Instantiate(playerEntity);
entityManager.SetComponentData(entity, new Translation
{
Value = position
});
}
// Update is called once per frame
void Update()
{
}
}
}
i think passing null blob store to conversion is no longer supported, you have to create it
just do new BlobAssetStore() and pass it, and in OnDestroy method of MB dispose it
@opaque ledge same. Can see Entity in Debugger, but not on screen
does it have any component in it ?
@opaque ledge no
π
yeah like i said in my post, try it out^^
if you dispose the asset store right after the conversation it will crash your editor, so thats why you should dispose it in OnDestroy
@opaque ledge so the prefab needs at least on Component ?
Assets\Scripts\Startup.cs(11,45): warning CS0649: Field 'Startup.playerPrefab' is never assigned to, and will always have its default value null
But it is assigned
no thats not what i am saying, it just doesnt properly convert if you pass null
@opaque ledge as I said, I put BlobAssetStore, and it same result. The object is not showing up on screen
hmm π€
no idea then, i mean it should at least have Translation component
does it give any error on console ?
No :/
do you spawn other entities ? does the same thing happens for to them as well ?
No its my first steps with dots
First script
I do have this warning in console Assets\Scripts\Startup.cs(11,45): warning CS0649: Field 'Startup.playerPrefab' is never assigned to, and will always have its default value null
does your prefab has convert to entity script > no
can you put it ?
yeah but does that entity work properly ?
can you see it once you go into play mode
Yes,
Can you tick DOTS->Live Link Mode->SceneView: Live Game State ?
and?
go into play mode π
And, nothing changed
if that doesnt work, i have no idea, there must be something wrong with that conversation script
eh
What Entities package are you using ?
0.8.0
Can you take SS of what your prefab's inspector looks like and how it looks like in Entity Debugger after conversation ?
yeah
you said there was no component in your entity π
its working fine actually but for some reason your render components arent being converted
do you have hybrid renderer package installed ?
No
Cheers man, gl^^
@opaque ledge one more question. I put rigidBody on my prefab, but it's not working. Is there something special for Phycis in DOTS?
do you have Unity Phsyics package ? @urban remnant
edit the manifest and specify that version
you have to update collections to 0.7
Collections, Jobs, Burst, Hybrid Renderer, Entities, Physics, Havoc Physics, these are all connected
perhaps even Unity Mathematics
so you have to update all of them to most recent version
except Platforms, 0.2.2 gives an error
so 0.2.1 better
i wonder why it doesnt detect when installing and auto update
yeah, we have discussed this before with some other people, Unity is working on it, but until then its kinda derpy
Now I have to options
I can add typical Rigid body
Or c-sharp script Phycis Body
What should I use
yeah, c sharp script one is Unity.Physics
they are both fine, if you use normal Rigid body and colliders then will be converted to Physics body and Physics Shape
tho i personally go with Physics body and Physics Shape
i made it in code
Ok
does this physics work with the mesh colliders too or only simple ones?
Noob question. How do make a rigid body not fall, like static?
make gravity modifier 0 ?
physicsvelocity and some stuff
go far down
it shows how to create an entity without prefabs
https://medium.com/@ajmmertens/building-an-ecs-1-types-hierarchies-and-prefabs-9f07666a1e9d
https://medium.com/@ajmmertens/building-an-ecs-2-archetypes-and-vectorization-fe21690805f9
2 blogposts by the creator of "Flecs" ECS lib (C lib)
its very similar to the way unity ECS works, tho it has more advanced stuff than it in some places
the second article basically explains how archetypes work, which is more or less the same unity uses
uh that latest is actually missing what i meant
So I have a plane with Rigid body and Box collider. Then the Entity with Phycis Body and Phycis SHape
The entity falls trough the plane :/
you have to handle the collision filter
its in Physics Shape, belongs to, collides with
in order to things to collide both sides want to collide with each other
so if you make 1: Test, and you give it to both of your plane and your Entity they will collide
well tbh, sometimes deleting Library folder or restarting unity helps when you update your packages
especailly preview packages
@opaque ledge
Belongs to, collides with? Nan i see there
Collision filter is locked
Ok it says Eveything
does your plane with Rigid body and Box collider converts to entity too?
@warped trail no
this is why they are not colliding
@warped trail I just added "Convert to Entity", same falls trough
change RigidBody and Box collider to PhysicsBody and Physics shapeπ€
Ok I will try
I think I'm giving up
Tons of errors and crashes
Nice for experimenting, but actually making a game and publishing, seems not ready yet
you are probably doing something wrongπ€·ββοΈ
i get crashes as well, in fact i just got one, but its still open for experimenting, and yes definitely not ready for publishing, but you can still do stuff with it
like i said remove library and let Unity re create it
I did that
still getting this
I did add Phycis Body and Physics Shape to both, plane and ball
And it still falls trough
what does the line at Startup:23
?
not sure, maybe use plane instead of box
what about Startup:23? π
@warped trail I think I fucked up there, some bad code π
No idea how to fix that Phycis
0.003 is pretty small radiusπ€
idk man, i dont use physics/collisions, i only use triggers and its working fine
are you using deafult unity sphere?
No its fbx
i know that BARGOS is doing physics/collisions stuff and its also working fine for him so
π€·
try with default unity sphereπ€
OMg, the problem was related to that 23 line in Starup.cs
π€¦ββοΈ
Jahu
Is this cool to destroy the blobAsetStore?
void OnDestroy()
{
bas.Dispose();
}
I have on Enity in debuuger that I have no idea where it comes from
Is that normal?
probably yes
one of them is prefab(they have prefab component) other one is the one you instatiate from the prefab
no, it suppose to work like that π
Hmm
thats what instantiate does, clones an entity
SO when i try like this
by default, entities that has prefab or disabled component is exluded from system queries
void Start()
{
defaultWorld = World.DefaultGameObjectInjectionWorld;
entityManager = defaultWorld.EntityManager;
bas = new BlobAssetStore();
var settings = GameObjectConversionSettings.FromWorld(defaultWorld, bas);
playerEntity = GameObjectConversionUtility.ConvertGameObjectHierarchy(playerPrefab, settings);
entityManager.SetComponentData(playerEntity, new Translation
{
Value = new float3(0f, 2f, 0f)
});
//InstantiateEntity(new float3(0f, 2f, 0f));
}
It doesn't work
yeah because you are not instantiating an entity
But its weird. If I instantiate, I got 2 entities. And I can see in debugger, that the original is falling due the Physics (the position is changing)
That can not be good for performance
did you check if your 'original' entity has prefab component ?
it doesn't
'original' one is the one who has the prefab component
Ahh
So it might be some Phycis thing, that some values are changing all the time, despite the fact that my ball is standing still
unity physics has no stacking, so you bodies will always moveπ
dynamic on static body is kinda ok, but dynamic on dynamic is not okπ
and it is framerate dependent out of the box
@opaque ledge when i clicked latest i couldnt find the part for creating physic entities in code only
Is it possible to use the new Unity Dots Physics without an actual Dots based project?
I would like to make a gamefeel focused (not physics) character controller with gravity/collisions but without all that rigidbody pushing each other and mass stuff
I tried both charactercontroller and rigidbody but I feel like in both cases I have to use a lot of gimmicks to get collisions without real physics
Alrighty, I'll take a deeper look when I get the chance, thanks
Anyone have a good 'pattern' to pass prefabs to systems? I'm looking to spawn a VFX prefab when an enemy is destroyed
I was going to use a GameObject, convert it to an entity and get the data on an update
But that feels a little hacky
## [Burst 1.3.0-preview.7] - 2020-03-16
### Added
- Added additional diagnostic for tracking Visual Studio location failures.
- Added an override to bypass link.exe discovery under certain conditions.
- Added a ldloc -> stloc optimization which improves compile times.
- More documentation on function pointers, specifically some performance considerations to be aware of when using them.
### Changed
- Updated tools used for determining Visual Studio locations.
### Fixed
- Embedded Portable PDB handling improved.
- Fixed a case where our load/store optimizer would inadvertently combine a load/store into a cpblk where there were intermediate memory operations that should have been considered.
- Fixed a bug where the no-alias analysis would, through chains of complicated pointer math, deduce that a no-alias return (like from `UnsafeUtility.Malloc`) would not alias with itself.
- No longer log missing MonoPInvokeCallbackAttribute when running tests
"More documentation on function pointers, specifically some performance considerations to be aware of when using them."
@opaque pilot You could do that, or use a ScriptableObject or Addressables to get your prefabs in OnCreate
Scriptiable object converted to an entity?
How would the SO be referenced to the system?
Well yeah I guess with a SO you'd still need to use addressables or Resources.Load to access it
Ah, I see
Could also look into using BlobAssets. I don't know much about them, but seems like they might be useful
Using the conversion system seems like a good way to go. Prefabs are ignored by queries unless they're explicitly included, so you can just query for your prefabs in whatever system needs them
Awesome, thanks @digital scarab
Soonβ’π
i use shared statics to hold my prefabs so i can instantiate them easily in a job
There's some stuff that is going to be streamed from GDC
I don't think Unity has announced anything though
i want to see DOTS stuff π¦
Maybe we'll see something about Hybrid Renderer V2
megacity 2
new fps sampleπ
Even More Mega
I want to see about code stuff, like how would they code for certain situations, or even a MB to DOTS guide or smth
i want physics prediction for NetCode
@digital scarab i've had two issues with that approach that i hope are being considered.
-
Addressables has no synchronous request currently, so you have to download and cache all addressable assets in advance then trigger conversions to create all your prefabs.
-
The conversion system doesn't ensure that child conversions have been run before parents that reference them, which makes certain situations of nested references fall apart if you do any processing in the child Conversion scripts (such as setting up add/remove components).
cheers, ill take a look, to be fair i haven't looked at it in maybe 6 months since i wrote the my caching setup to get around it.
my case is an addressable prefab that contains level definitions. After the game loads that prefab is instantiated, the conversion script grabs referenced prefabs (stuff used in each level - effects, parameters and whot-not) and turns them them into Entity Prefabs.
So in this case it needs to call GetPrimaryEntity on the referenced addressable prefabs, and multiple levels may reference the same assets.
@digital scarab is there any plan for use of convert&inject on a child where the root also has convert&inject?
hmm interesting. im still working with skinnedmeshrenderers so in this scenario the root gameobject(with legacy stuff like navmeshagent etc) needs to be injected, but then I also want to take advantage of the new conversion for joints so currently it doesnt work out of the box. ive made a copy of those systems to convert it manually but it doesnt sit right with me doing it this way π
ive been doing some ecs experiments with multithreading, on my self-rolled cpp ecs
ive been tinkering with "merging systems" in a pipeline
parallel-fors run across a set of chunks
but what if
instead of doing 1 parallel for per system
you instead gather all chunks that could match a set of systems, and then on the parallel for you execute multiple systems per chunk
saw some pretty sweet gains (20%) by removing sync points of parallel fors, and due to the improved cache usage
my pipeline was like boid_logic -> update transform matrix -> cull. So the 3 systems essentially get "merged"
so... I guess I need to rethink my current convert and inject workflow :p
I'm pretty certain hybrid renderer v2 will take way more time to mature to a point where I can use it than what I actually have so I need to sync the GO transforms efficiently some way
convert and inject isn't mandatory there
it just makes it convenient
looking at the messaging on hybrid renderer v2, the initial goal is to support core functionality on SRPs
but that tells nothing about more niche things, like DXR support etc
well personally i hope to ditch it like a hot plate when animation conversion is more simpleton friendly for me to use
I personally don't even need traditional animations much
presumably 'things like skinnedmeshrenderers.. online' is like years away though so it'll be around for a while yet?
@amber flicker well that hdrp animation samples project shows it appears to be on the horizon, as opposed to something like navigation
tech on horizon, sure.. but a drop-in replacement for existing animators etc? seems like a verrry long way off no? Talking about a time when animators would happily use a built-in dots anim editor to author character animations before you could seriously think about switching over to that. Would love it if it was closer than I thought.
is there an easy way to create the float4x4 matrix of a localtoworld component?
rotation is not relevant for now, I just have a float3 position
float4x4.TRS()π€
I'm ~~mildly ~~concerned the line between 'experimenting with ECS' and 'using Unity in production' is going to get a lot more blurred than that over the next couple of years @digital scarab but I'm really positive about the direction.
changing api's and deprecating old workarounds for hybrid solutions isn't ideal
ECS core is pretty solid in Unity now, but almost everything else has strong "alpha" feel to it
so if you want to use it in production today, you'd assume Unity would make it easier to use in hybrid scenarios today
but that part isn't that great today
I also do hope Unity can show some serious workflow improvements on conversion stuff soon
or rather, using editor with them
Do particle effects work in dots?
There's a very fine balance to strike between giving people tools to experiment with (that they shouldn't use in production for years*) and expecting people to use years old tech... Especially if the answer to peoples performance problems is to use the new stuff. Just hope I'm not watching a car crash in slow motion as I want the endeavour to be a success.
*~2 so far and expecting another 2-4 more
not via entities @opaque pilot - I think at some point I saw an open source dots particle system but a quick google's not turning it up - this is one of those cases you need to keep a GameObject around (I think)
@opaque pilot they work like all old UnityEngine things with Inject but theres no official dots equivalent yet
Anyone wrapped their head around the new physics package update where they now use LocalToWorld instead of directly Transform? It seems like they fetch from that, but writes back to localposition :S
I wasnt aware they made a change to how they handle translation?
If a static body as a Parent, then its transform is always decomposed from its LocalToWorld component (which may be the result of last frame's transformations if you have not manually updated it).
If there is no Parent, then the body is assumed to be in world space and its Translation and Rotation are read directly as before, if they exist; otherwise corresponding values are decomposed from LocalToWorld if it exists.
In any case where a value must be decomposed from LocalToWorld but none exists, then a corresponding identity value is used (float3.zero for Translation and quaternion.identity for Rotation).```
I noticed this also is true for dynamics on a side note.
really disappointed I haven't seen any GDC online talk activity today. I was hoping to hear some more about DOTS and Tiny.
What are options for spreading jobs over multiple frames?
With MBs, it was really easy with coroutines
It's much harder to do it in a precise way due to scheduling other threads etc. One technique is simply to use the number of entities as a proxy for how much work needs to be done and use a queue/list or something to only process x entities per frame. I personally quite like this as it's very scalable. Also, as usually all the entities have very similar data associated, combined with chunk behaviour (cache line), it's a much more predictable proxy for work done than managed monobehaviours/data of past.
What about something like chunk-based procgen? You don't really want it to happen all in one frame, and it won't run every frame. You'd want it to run over maybe a seconds worth of frames or something, and then not run it again until it's needed
The problem is that sure, you can specify every frame to run X amount of batches, but that's going to be pretty arbitrary. It would be really useful if I could say run for X ms or something like that, and then stop
But I guess that would break determinism
so.. I don't know if there's a better way.. but x seconds can be calculated with sample size and then quantity lerped - similar to auto adjusting graphics ... that's how I'd approach it. Run xmin amount of batches, next frame increase it while time taken < threshold or similar. Just a thought.
Hm, that might be a way to go. Thanks for the input, I'll try it out if I need to spread a task over multiple frames π
the one thing I'm not sure about off the top of my head is what non-editor api allows you to measure the time taken across all threads for a job.. that would be useful
Oh yeah, I didn't really think about that. How would I even check when a job has completed?
well.. there are markers in the profiler but I guess you can't use the profiler api at runtime - perhaps someone else here knows a good way
I know there's the IsComplete field, but I can't really check that multiple times in the frame
well, even if you could, it doesn't help much as often the work doesn't start until a while after it's scheduled.. for scaling you want to know how how long the job took in a similar way to what's displayed in the profiler I'd have thought
Yeah, would definitely like this to be dynamic
I mean, not blocking the main thread seems to be the whole point of multithreading, but with ECS they've kinda removed that π
not sure I know what you mean by that?
maybe you can move this work to another world, like they do with subscene loading?
that is one approach.. but it doesn't help much with comfortably splitting work across frames? Also you incur the cost of copying all the data there and back again once it's done
is it copying, i thought you will just pay the price of remapping entities?π€
I didn't mean so much blocking the main thread, but more blocking other stuff, like rendering and input (and just other jobs in general)