#archived-dots
1 messages Β· Page 142 of 1
ok - dont use angles - just use quaternion.LookRotationSafe(worldPosition - playerPosition)
@coarse turtle Ok thanks! I'll test it when I am back at my PC π
Really appreciate it
@coarse turtle LookRotationSafe requires two parameters apparently, float3 forward and float3 up.
just saw these tweets 2 days before Unite Copenhagen keynote:
lol
@coarse turtle I've figured out that the second parameter is the look rotation
but I've tried with (1, 0, 0), (0, 1, 0), and (1, 0, 0). In all cases it looks, but rotates in 3D as well π
@coarse turtle FOUND THE ISSUE
Turns out ECS maths uses radians not degrees π€¦
ez fix
@ocean tundra Is there a math.all equivalent for "or"?
Since math.all is just and
math.any
@warped trail Thanks!
How does one get the Euler angles from a quaternion?
@warped trail Any ideas? I've gone through the docs and I can't find anything
@grim walrus what are you wanting the Euler angles for?
i think we are meant to go Eular angles ==> quaternion
@ocean tundra I want to add to the euler z rotation
Actually, scrap that
I just need to access the euler z rotation
Looked through every single thing and I can only find how to get a Quaternion from Euler angles, not the other way around
So you can access it the same was a Rotation?
and the transform systems will read that and convert that into Rotation.quaternion
yup
but you need to add it first
not there by default
@ocean tundra How do I add it? I'm using convert to entity
after convert
EntityManger.AddComponent
or inside a monobehaiver with IConvertToEntity
the monobehaviour convert option would probably be best
Wait so you can have a MonoBehaviour on an entity if you use IConvertToEntity?
All I want is to get the z rotation π
Turns out im not even using it
:/
IConvertGameObjectToEntity
on a monobehavior attached to your gameobject
it will make you implement a convert method
inside that you can do entitymanager.addcomponent
ill take a look at maths again
:/
i think that component is the way
I'm trying to do it in System
protected override void OnCreate()
{
EntityManager.AddComponent<AddRotationXYZ>();
base.OnCreate();
}
you need to pass the entity to it
Where can I get a reference to the current entity in a system?
there isnt a current entity
Entities.WithNone<THAT_ROTATION_COMPONENT>().WithAll<SOME_PLAYER_COMPONENT_ON_YOUR_ENTITY>().Foreach(........ ADD COMPONENT HERE
@ocean tundra Sorry for being a pain. But how do get the Entity reference in the ForEach?
Add a ref/in like with the Components?
Ahh ok
its optional
Got it
@ocean tundra Last problem for some reason it doesn't like it
error DC0002: Entities.ForEach Lambda expression invokes 'get_EntityManager' on a FaceMouseSystem which is a reference type. This is only allowed with .WithoutBurst() and .Run().
I am using .Run() though
protected override void OnCreate()
{
Entities.WithNone<RotationEulerXYZ>().WithAll<FaceMouseComponent>().ForEach((Entity entity, ref FaceMouseComponent faceMouseComponent) =>
{
EntityManager.AddComponent<RotationEulerXYZ>(entity);
}).Run();
base.OnCreate();
}
So .WithoutBurst().Run(); works? You can stack them?
@ocean tundra Now a new error EntityQueryDescValidationException: EntityQuery contains a filter with duplicate component type name FaceMouseComponent. Queries can only contain a single component of a given type in a filter.
FaceMouseSystem which is a **reference **type.
and 2
Dont need ref FaceMouseComponent faceMouseComponent
when its in a WithAll or WithNone or WithAny you cant use it in a ForEach parameters
So just Entity entity
the FaceMouseSystem being a class isnt much of a issue, but good practice to make them structs whenever you can
yup
i always just call it e
π
cause i hate typing
Still broken though
.WithStructuralChanges?
π what's that?
Sorry for wasting your time man
na its fine
I really appreciate your help
I can't figure out why it doesn't work now though, it seems like I've done everything right
WithStructuralChanges is needed when using entitymanager
Ah ok
sorry when entity manager is making actual changes (add/remove/create/destory)
EntityQueryDescValidationException: EntityQuery contains a filter with duplicate component type name FaceMouseComponent. Queries can only contain a single component of a given type in a filter. still is getting me
using UnityEngine;
using Unity.Entities;
using Unity.Mathematics;
using Unity.Transforms;
public class FaceMouseSystem : SystemBase
{
protected override void OnCreate()
{
Entities.WithNone<RotationEulerXYZ>().WithAll<FaceMouseComponent>().ForEach((Entity entity) =>
{
EntityManager.AddComponent<RotationEulerXYZ>(entity);
}).WithoutBurst().WithStructuralChanges().Run();
base.OnCreate();
}
protected override void OnUpdate()
{
Camera mainCamera = Camera.main;
Vector3 targetVector = mainCamera.ScreenToWorldPoint(Input.mousePosition);
float3 target = new float3(targetVector);
Entities.ForEach((ref Rotation rotation, in FaceMouseComponent faceMouseComponent, in Translation translation) =>
{
float3 difference = target - translation.Value;
rotation.Value = quaternion.Euler(0, 0, math.atan2(difference.y, difference.x) - math.PI / 2);
}).ScheduleParallel();
}
}
Wait what? I only have one foreach in OnUpdate
the with none means it wont try to add over and over
and you can have as many foreach's in a onupdate as you like
they will be created/scheduled to run one after the other
That's in OnCreate though
yea move it
To where?
into onupdate
yes and no :/
the with none will prevent it from doing anything
long term you probably want to do the add component in the IConvert... flow but this should get you going quickly
no leave it
Then what should change?
nothing
it should be happy now
you have 2 entitys...foreach
first one only runs if your player dosnt have that rotation component
using UnityEngine;
using Unity.Entities;
using Unity.Mathematics;
using Unity.Transforms;
public class FaceMouseSystem : SystemBase
{
protected override void OnUpdate()
{
Entities.WithNone<RotationEulerXYZ>().WithAll<FaceMouseComponent>().ForEach((Entity entity) =>
{
EntityManager.AddComponent<RotationEulerXYZ>(entity);
}).WithoutBurst().WithStructuralChanges().Run();
Camera mainCamera = Camera.main;
Vector3 targetVector = mainCamera.ScreenToWorldPoint(Input.mousePosition);
float3 target = new float3(targetVector);
Entities.ForEach((ref Rotation rotation, in FaceMouseComponent faceMouseComponent, in Translation translation) =>
{
float3 difference = target - translation.Value;
rotation.Value = quaternion.Euler(0, 0, math.atan2(difference.y, difference.x) - math.PI / 2);
}).ScheduleParallel();
}
}
and will add it
Still gives the error
EntityQueryDescValidationException: EntityQuery contains a filter with duplicate component type name FaceMouseComponent. Queries can only contain a single component of a given type in a filter.
yea it looks fine to me
@ocean tundra Unity was being dumb. Restart fixed it π
yay
Again, thanks for all the help
all good
If there is anything I can do to help you out let me know!
maybe one day testing over the internet
but im ages away from that
but fingers crossed a week or 2 away from a small lan test π
Ok! Best of luck on that
I'll swap out Rotation tomorrow it is getting late here
and can begin to scale up π
I'm doing a networked game too actually
Still not sure what to do for my networking solution though
The new Netcode seems to be really unstable
But I'm familiar with Mirror, but that isn't directly integrateable with ECS
How hard do you think it would be to get it working with an ECS project?
Or make some sort of bridge
umm
i would say not worth it
they have some good things
their message router is very handy
and their network time
probably serialation as well (but i used Ceras)
but any of the high level stuff probably not worth it
sweet
Maybe we can talk about networking later
night
Thanks for everything!
Is it possible to create a child/linked entity in the conversion, like in IConvertGameObjectToEntity? Simply creating an entity there seems not to do the trick, but seems to spawn it right away (even if prefabbed).
@mystic mountain Yep, conversion contain 5 major groups
You should run your own conversion system after conversion done in one of required systems
Theres a way to add a entity
GameObjectConversionSystem.CreateAdditionalEntity
use that inside the IConvertGameObjectToEntity Convert method
Will try
i dont think it creates it as a "Child" with the child/parent relationship
but it should be added to the linkedentitygroup
That's what I want anyway ^^
Hmm, seems I need to specify a gameObject, I want to create it from scratch or archetype.
oh
ideally at least π
thats really dumb
i guess you can try manually creating the entity
and then adding to the primary entities linkedentitybuffer
sometimes the DOTS api is really cleaver, like when it can rewrite our code for us
but sometimes such simple things just cant be found
i guess it would be easy enough to write a extention method for entitymanager
There should be a GameObject if conversion is taking place right? Just want to make it known that you don't want to be creating entities outside of CreateAdditionalEntity - even matching SceneID components etc it just becomes a mess π
@amber flicker What I want to do is specify states/abilities in scriptableObjects, and on conversion create & add these as linkedEntities, instead of fiddling with each and every prefab if they are using same structure
What I might do now is to just add a gameObject for each of these and use the CreateAdditionalEntity, but it's just one unnecessary layer to setup.
If you want to do it 'on conversion' then it makes sense to have it associated with an object being converted. On the broader point of what you're trying to achieve though, how will other entities access the data? Is the data mutable?
e.g. do you plan on having a monobehaviour with a field for one of these scriptableobjects and then that gameobject later gets converted?
@mystic mountain Fingers were greasy, had breakfast. Ok. CreateAdditionalEntity it's your case, you don't need additional conversion systems as I suggested above (misunderstood your question initially). CreateAdditionalEntity takes GO and will return you new empty entity to which you can add your components, yep this is not created form archetype, but this is what you have in IConvertGameObjectToEntity. This entity will be in same linked entity group where your IConvertGameObjectToEntity called.
I'm really confused about the Hybrid Renderer V2. It seems like it uses compute shaders of all things to upload data
Why even use a compute shader for such a thing?
So in the end, meshes are rendered under the unity's hood and the materials just pull data from the buffers that are created and managed by the C# side of Hybrid Renderer V2 and updated via a compute shader
Why such a convoluted thing? It's already a big problem if you use compute shaders to update the buffers.
Furthermore, such a restriction forces your ECS renderable objects to have struct only values. So, lightprobes, previous model matricies, light indicies and all that, cool and good. But now you can't setup reflection probes for instance, or lightmaps, because all of the data is updated via a compute shader.
such a restriction forces your ECS renderable objects to have struct only values
Isn't that just a general burst restriction? I don't know much about how rendering works, but it sounds like they're just using the hybrid renderer with Burst
You can do such stuff in default Unity. Unity already did it for you from the C++ side nicely. But now, because it's all data oriented and struct-based, you cannot update reference types. Now you can't update the lightmaps or reflection probes assigned to a renderer and only do hacks like indicies and texture arrays.
Builtin unity doesn't need such a thing, so it's a problem.
It's all about the performance
Sure, you can do it that way, but it's not as performant
That's the whole idea of DOTS
Again, builtin Unity already does this from its C++ side. It already can nicely cull and update lightprobes for renderers.
Reflection probes, I mean
Sorry if this is obvious, I didn't find it on a search - how do I SetSingleton() when calling for an entity command buffer system to create an entity + component?
If you're just annoyed about the feature not being in Hybrid Renderer, then it's just because it's not supported yet - it's still a preview package
It's not about it being supported or not. It's about the foundation. So far the foundation is that a compute shader is used to update the buffers from which the shaders pull data during the rendering.
This foundation is the problem, and it won't allow for stuff that I describe
Unless, again, stuff like texture arrays and indicies are going to be used, but those are hacks
Well you're free to write your own renderer if you're unsatisfied with it
And on the other hand, if lightmaps or reflection probes or any other reference types are going to be managed on the C++ side, then that also is a major problem, because the whole talk about "the line between the engine and game code disappears" is now a false claim.
I can't write a renderer for Unity, I don't have the access to the source code and I can't have components in the ECS to store reference types.
anyone know what the latest animation package version is or where I can find out?
oh wait, it is now I added it to my manifest π thanks
can you create a singleton entity from an ECB?
there is no singleton entity, there is singleton component, which means there is only 1 of a kind of that component type in a world
### Fixed
- Fix an issue when changing the base type of an enum that would not trigger a new compilation and would keep code previously compiled, leading to potential memory corruptions or crashes.
- Fixed a subtle AArch64 ABI bug with struct-return's (structs that are returned via a pointer argument) that was found by our partners at Arm.
- Fix an issue that was preventing Debug.Log to be used from a Job in Unity 2020.1
### Changed
- JIT cache is now cleared when changing Burst version```
yes, you're right I chose my word poorly
aww, i guess no enum equal check fix yet π¦
Currently I create a entity and add a component to it in an ECB, but I want to change my code so that that component is singleton Component.
well i mean, as long as there is only 1 type of that component, that is a singleton component, instead of creating an entity, you could try to get the entity that has that singleton component
GetSingletonEntity<T> is the method you are looking for
so instead of creating new entity, you add the component to the entity that is returned from GetSingletonEntity
yeah I see, just have the component there all the time and use the data within it instead of its presence...
although that's more of a pain because I'm using RequireSingletonForUpdate to only run a game end system when I create the game end component with the relevant data on it
or rather, I'm not using that right now I'm using RequireForUpdate on the EQ but you get the idea
you can have your end game system remove the singleton component/entity, therefore it will only run once and will stop working until you add your singleton component again
are you trying to implement a end game signal ?
well I have that implemented, but I am tidying up the code so I don't have to create a NativeArray of the components with ToComponentDataArrayAsync then check the length of the array and dispose
but I can't access the system on which to call SetSingleton from within a job via the ECB so that's put a bit of a spanner in the works
The problem I'm trying to resolve is working out why the component isn't getting destroyed when it should be - if I create the end game event on winning or pressing the quit button, it works and the quit game event data is read and the component destroyed, whereas if it's created on player getting caught, for some reason it's getting processed but not destroyed
that does sound weird, but probably a code fault somewhere ?
assuming both cases are processed by same system
yes probably, I was rather hoping in tidying up the obviously-singleton-but-not-implemented-as-singleton it might also help me debug! π
Perhaps you are adding 2 end game components at the same time ?
becaues you are doing RequireForUpdate on EQ right ? not on singleton
yeah
the event is getting created from other systems
and read by the one that destroys the EQ
so perhaps another is created on the frame after the first was created/then destroyed...
ayeeeeee silly roo fixed it by changing the system update order!
Thanks for engaging @opaque ledge appreciate the help!
@fringe sinew Unity NEED such a thing long time ago. Because CPU<->GPU is costly part of rendering pipeline. With ComputeShader and ComputeBuffers part they now operate directly with GPU memory pointers, and for that thing they added Begin\EndWrite as native array pointer to GPU memory instead of marshaling data from CPU to GPU. They getting GPU pointer of data buffers (matrices, etc.) and write directly to GPU and then in compute shader they process that data batches operations and store on GPU. It excludes requirement to pass batches of data to GPU every frame, because that data already passed and stored on GPU until you update it, or untill buffer lifetime in frames not ended up, moreover direct GPU pointers with nice batch ranges allow them easily parallelize process now, instead of being bottlenecked for CPU->GPU synchronization they now just write all data batches in parallel to GPU and main thread uses only for open\close write streams. it's huge rendering performance improvement. For supported platforms it use direct GPU memory pointer for other (D3D11 for example) it uses temp buffer (D3D11_MAP_NO_OVERWRITE) on CPU which will copy (through CS-readable buffer) then to global preallocated buffer to GPU at the end (which uses for all new rendering). Also why compute shader involved here - they reducing bandwidth (and they mentioned that on forum, that it's their intention, because bandwidth is one of common rendering bottlenecks), instead of passing two matrices (initial and inverted) to shader, which initially have huge cost, they pass only one matrix and inverse it in compute shader, where matrix inversion cost - zero in comparison to CPU inversion and passing in as additional matrix.
About lightmaps, reflection probes etc. They working on that now, don't forget - tech in preview and things not become magically converted by gods, they need time to rewrite that, at the moment, they rewrite all core rendering engine (!) π
I can't write a renderer for Unity, I don't have the access to the source code and I can't have components in the ECS to store reference types.
You can becauseclassIComponentData was added 3 versions ago. But you can't use that in burst and jobs, and in the end you'll fallback to Unity legacy renderer and bottlenecked by main thread CPU->GPU synchronization.
You can now create reference-typed IComponentData and access them in jobs?
So, yeah, I can't. It's still limited to the value types. I wonder how they're going to implement lightmaps or lightprobes without using texture arrays
Can't say more details here, sorry, but they working on that and investigating that π
We just should be patient here π
But still, with compute shaders some of the platforms are out of the question and won't work. And moreover, I fear that if more and more things will start to be implemented on the C++ side the whole meaning of the DOTS will disappear, it won't be truly open for some stuff.
I'm patient, but I'm really worried about the future.
Besides, I don't think the default Unity ever needed such a setup.
Only thing now on C++ is BatchRendererGroup. All other things on C# side and passed to GPU through things I mentioned above, matrices other properties etc.. And about CS, most of hardware now support it, GLES 3.1 Vulcan for android, metal for ios, DX11\12. Consoles ps4+, xbox one+. (not sure about switch) CS requirements at these days not so high.
Sure it's not the most performant thing in the world, but it could render a lot of objects nicely CPU-wise, without instancing and direct memory access
I'm saying: why even use computes when other solutions (and unity itself) could do relatively fine without using them?
And this is why big open worlds in unity was real pain for implement π With current approach it become "performance by default". But for any conclusions we should wait a bit more detailed view to what will be implemented.
I'm saying: why even use computes when other solutions (and unity itself) could do relatively fine without using them?
@fringe sinew Of course it can, but it not scalable and performant.
If you don't need that
You can ignore HR that simple π
If built in cover your case
Has fine performance for you
Why you event thing about HR at first place π
You still can use DOTS for logic
and use built in rendering things
HR renderer is not complete replace for built-in rendering in long term
SRP not require HR too
in "performance by default" here "by default" is matter π You can implement huge amount of drawings on current rendering solutions, and it will works fine, but you need extra work for that (for example DrawMeshInstanced(Indirect) processing matrices, hand written shaders). And by default mean that regular Joe just putt many things on scene and they just will for out of box without all that 'weird for regular Joe stuff"
Why Unity listens to you anyway
@opaque ledge It's question to me?
yeah
What do you mean?
"Can't say more details here, sorry, but they working on that and investigating that "
so you guys are in contact π
Yes we in contact π
Why Unity listens to you anyway
Just confusing me π
I got it like "they listen and do what I say them" π
@storm ravine Hmm, I tried with CreateAdditionalEntity. But it doesn't seem to create the entity when it's part of prefab? Any ideas? π€
If the CPU->GPU data copy causes so much performance bottlenecks, then what the hell was SRP Batcher for?
That thing was specifically designed to solve this issue with many drawcalls and data transfers, and IIRC Frostbite was the pioneer behind a similar feature.
Never heard or saw it having performance problems.
Why use specifically computes now to upload the data? Besides the parallelism, what does it bring? And how fast is it on the GPU itself now?
@storm ravine Doesn't get added as linked even though I use CreateAdditional π€
So would guess CreateAdditional can only work on the same gameObject or in the hierarchy that it is converting?
@fringe sinew SRP Batcher it's additional performance gain, in comparison to scale which HR can cover. But they work together and SRP Batcher will give additional performance boost to HR. Compute shader initially not for upload but processing, for creating inverse matrix, and because they already have data on GPU just use same compute shader for copy data to destination preallocated buffer on GPU memory which exclude transfer bandwidth at all. It fast as possible, because it already on GPU.
And as I told before they reduce main thread overhead here
you can even not use many worker threads, but just one worker thread for processing data, which already freeing your main thread
But because they can parallelize that and give much more performance - they do π
SRP Batcher thing not related to HR in common, but uses some features which used for HR. Like BatchRendererGroup with materials, meshes, culling info, material property blocks. BatchRendererGroup is bridge between them. And BatchRendererGroup itself not relates to HR and just used by this. Thus BatchRendererGroup with SRP Batcher is just different beast which used for GO, and provide some stuff for HR.
And what you mean about "more C++". Only C++ thing (and it's partially) which used by HR is BatchRendererGroup, that's all.
All other stuff is Shaders, CS and C#.
Ok, I had it all wrong, I thought the parameter of CreateAdditionalEntity was the GO that would be converted. big thanks^
Dangit, I had such a clear idea on how I wanted to setup chunks to streamline my future physics engine, but 2 days back on my job and I;ve totally forgotten my idea
Ive implemented the kindof techniques the SRP batcher uses
and more complicated ones
the thing is that usually, even today, the engine loop goes something like this
foreach(camera){
set_gpu_cam_settings(camera);
foreach(object){
set_gpu_material_settings(object.material)
set_gpu_object_settings(object)
set_vertex_buffer(object.vertices)
set_index_buffer(object.indices)
draw(object)
}
}
thing is. Every time you are setting those object and material settings, you are uploading to the gpu
even of the object is static or dynamic, doesnt matter. Every frame every object the data goes up for each object in the view
SRP batcher, and unreal engine, move to a "big ass buffer" approach
Same as HR, which uses big preallocated buffer
instead of uploading the data per object and per material when rendering, at the begin of the frame, they upload this bigass array with the object data of ALL objects, and the material data of ALL objects
and then, rendering loop is very fast
bandwidth is reduced by only uploading the data that changed since last frame. It makes static objects stupidly fast because they basically upload nothing to the gpu per frame. They just stay on that buffer, and rendering them is super quick
they have also been adding some stuff to the ECS that basically memcopies ECS arrays to the gpu
so when it sees one of your component arrays has changed (version index) it uploads to gpu, and then you can read ecs data from gpu for your materials or shader
this opens you up to some absolutely crazy techniques, like what Frostbite and Ubisoft engines do, which is where you dont even do rendering on the CPU. The GPU uses compute shaders to calculate the rendering and culling
And reason why they can't get pointer to that big buffer is that things moving around in that buffer and pointer will point to wrong GPU memory in this case when you in opened write stream, this is why they populate buffers first and fill them through jobs and then copy that buffers data to big buffer on gpu when write stream closed
yup
btw, the big ass buffer approach is actually very easy to implement
if you do it from the start
it simplifies rendering code quite a bit, + is much faster
Yep I know all that and this is what I decribed to @fringe sinew above π
how come the package manager is so buggy
i cant find the Platforms package
also unity beta 2020 doesnt allow to show preview packages
the option is gone
on unity 2019.3.13f1 i dont see the Platforms package
how do I find 0.3.0-preview.2
Unity beta 2020.1.0b7
Can someone explain to me how the hell you debug compiler errors when updating packages in Unity, I've updated from 0.8 to 0.10 entities and now have 243 lovely errors all relating to Library\PackageCache\com.unity.entities@0.10.0-preview.6 but have no clue what the coflict is coming from
But that's the case, SRP Batcher already takes care of that, that's the big-ass buffer.
as I said, 2020.1.0b8 doesnt have Show preview packages, and 2019.3.13.f1 doesnt see the platforms package
I've never heard of any other tech to accelerate this particular thing via computes
Which used for different things - GO with which HR not work. And that not reducing send data size bandwidth, they still pass 2 matrices etc. speedup (and it's big speedup) here is frequency of uploading, it's very good optimisation. With CS in HR it not only frequency (with SRPBatcher) but reducing upload size bandwidth. As I told (and HR devs told) CS removes requirement for passing second inverse matrix to GPU, instead only one matrix passed in and processed in compute. And it become valuable at scale.
And in future it will be extended for other things
But the compute shader isn't simply used for the sake of passing just one matrix. It's used for all the per-render setup, like light indicies, lightprobes, etc.
What's the point of SRP Batcher by that point is then? It also does the same job IIRC, both for material and per-renderer properties
@storm ravine wait, SRP batcher uploads the bigass array every frame?
you should get finished write stream with data
@storm ravine wait, SRP batcher uploads the bigass array every frame?
@vagrant surge no. HR without SRP batcher pass data every couple of frames in parallel with Begin\End write
What's the point of SRP Batcher by that point is then? It also does the same job IIRC, both for material and per-renderer properties
@fringe sinew no, per-renderer properties is not SRP batcher same as not HR. All this handled by BatchRenderGroup which both things using
What's the point of SRP Batcher by that point is then? It also does the same job IIRC, both for material and per-renderer properties
@fringe sinew one more time - GO land. Reducing frequency bandwidth.
But then we get back to the original topic: why even use compute? SRP Batcher didn't need any computes to work or to create such a scenario by not reuploading data constantly.
Alternatively, if computes are so fast and efficient, why not use computes in the GO land?
For SRP Batcher I mean
SRP Batcher NOT reducing that - upload size
Alternatively, if computes are so fast and efficient, why not use computes in the GO land?
@fringe sinew Well because it already written long time ago and require huge rewrites underhood I guess
Convenient
And one more thing - scale. SRP batcher doesn't give you performance gains if every thing will be dynamic. Because if every thing changes every time - everything will be reuploaded
And HERE where HR with CS and reducing upload size become a valuable thing.
Because in that case you can't have a boost of frequency, all dynamic all changes
And upload size it's only thing for reducing bandwidth here. And reduce upload size for thousands things for even one float4x4 is 128 bytes! and for 10k things for example - is 1.25Mb! and than size every frame is VERY big bandwidth reducing.
Bloody hell, I try to update Entities package one version and now i get 1fps lag spikes
Everything Idle, CPU just needed a nap I guess
I know, even after downgrading back to the same version of the entities package its still happening weirdly
You reloaded Unity?
Yup
And still persist?
Yeah
Have been but its so inconsistent its hard to catch
What inconsistent? Just run and select frame spike
That's all
And if you speaking about that it not "pausing" editor profiling just uncheck profile record button
doesn't match to the in game spikes propperly
Editor shows constant frequent spikes, where as game profiler shoes infrequent big spikes
Which doesn't mesh with what the game profiler tells me about it being the editor
That's what i thought the cause was originally till i saw the big editor times
Oh you mean in the editor
If you disable profiler will spikes still persist?
GC in play mode expected of course if you have enabled jobs debugger, safety checks, full stack trace
looks like it still happens
Ah and switch form timeline to hierarchy and select EditorLoop to see full profiler spikes
It can show you additional spikes
which can match your player spikes
ah now that is a thing i did no know existed
I've always had player expanded
Yeah the only time my player spikes is GC collection, the rest is allll editor
Should probbaly do a deep profile to work out why im getting semi frequent player GC's though
Safety checks
Jobs debugger and full stack traces
disable them
and switch to release mode if you in debug mode
It will show you performance close to build in which GC spikes produced by safety checks wouldn't persist (if of course you haven't your own garbage for GC)
jobs debugger i had turned off, and my stack traces are on script only
Yup that makes it run a lot smoother, just the occasional 60ms spike on the editor
Which is just GC from the looks of it
I just cant work out why it's stated happening today
Oh well, mystery for another time, I wanna actually code something for once, thanks for the help π
Hey everyone. Quick question about dynamic buffers:
I''m trying to add 2 (or more) dynamic buffers to different entities in mono. I understand that structural changes like em.Add invalidates the data.
Is there a way around it?
Delay that calls by EntityCommandBuffer. Or add one buffer and process, add second buffer and process
I'm unsure what you mean by "process". It's not in a job/ system
If you not processing them what the point of avoiding structural change here?
by process i mean you add them and fill their values
ECB still valid here ECB.AddBuffer return you buffer immediately which you can populate, but structural changes delayed, because you delay this structural changes at the end of frame for example (or what ever ECB you using\creating) and not interrupt jobs in a middle of dependency chain and frame.
Alright, before I declare myself a terminal idiot, can I recap this whole argument to verify that I understand the whole thing correctly?
@storm ravine I see! Very good to know. I'll keep that in mind!
HRV2 provides potentially better performance because the data is written by all jobs in parallel and only for those buffers that changed. It's not just the rendering thread that writes the data before rendering, but all of the HRV2 jobs.
They do this by using compute shaders to write directly into the memory adresses on the GPU in parallel. Additionally, some data is generated by them specifically, like the inverse of matricies.
Is that correct? @storm ravine
Not exactly. Give me a minute π
I'm sorry if I'm an annoyance.
No problems it's discussion
- Parallel writings is bonus thing added by HR them in to Core Unity thing - ComputeBuffer. You can write to them in parallel from 2020.1, it's independent thing, but obvious reason why they added that is HR team want to get parallel writing performance here which gives you BIG boost. That BeginWrite give you array which points directly to GPU memory (for supported platforms like D3D12, Vulcan etc.) and to D3D11_MAP_NO_OVERWRITE buffer in other case when hardware doesn't support direct memory writing.
- SRP Batcher - reduce frequency of writing, and writes only when data changed and that works with HR same as for GO land. Goal - reduce upload to GPU frequency. Without that HRv2 will reupload to GPU often.
- HR uses CS for reducing Upload size. When you have many dynamic things which updates every frame. You can't get here SRP batcher frequency bandwidth reduce because of obvious reasons. How they reduce upload size with CS - they just moved inverse matrix calculation from CPU to CS and thus send less data to GPU by compute buffers. For CS they still using ComputeBuffer, because they should upload initial data to GPU and you can't write to big preallocated buffer directly, because when you write async that buffer can change it's content and you'll write to wrond memory stride which will corrupt your data. In CS their initial intention - process that data - like creating inverse matrix in CS. And because they have structured buffers on GPU with data, and CS dispatched it mean write stream closed, and they can safely write to Big Buffer, because it's main thread call which guarantee that no one will write to that big buffer at the same time (of course if not doing that manually by intention π ) and content of that big buffer wouldn't change, and they copy that linear buffers data to appropriate memory parts of big preallocated buffer.
Can you clarify what are the obvious reasons behind not being able to use SRP Batcher effectively in such a scenario? Is it that many dynamic objects will invalidate a lot of buffers/memory so a ton of it will need to be uploaded?
And well I asked Sebastian Aaltonen, He is lead of HR team about devices which doesn't support CS and ComputeBuffer (which connected, devices which doesn't support structured buffer usually doesn't support CS) If people want to make simple mobiles games (often 2d), then GameObjects usually is the right choice. Developers choosing DOTS often want to scale up to high entity counts and they require very high performance and scalability. So we made a decision to use ComputeBuffer to allow better GPU data persistence. This makes things much faster on current high end mobile phones and all desktop and console platforms. We can support around 3 generations old Androids and 4 generation old iPhones. That should be good enough for DOTS launch. It usually takes at least one year to develop a game, so there will be 1-2 more generations of new phones out when DOTS is mainstream. It's not optimal for early adopters who wish to ship their mobile games immediately with DOTS v1.0 and they want to reach maximum audience (meaning that the game is pretty simple), but this will be better for everybody else.
Can you clarify what are the obvious reasons behind not being able to use SRP Batcher effectively in such a scenario? Is it that many dynamic objects will invalidate a lot of buffers/memory so a ton of it will need to be uploaded?
@fringe sinew Well for example matrices again - you need them every frame if object moves
And instead of 2 matrices you send one matrix
But that's just the model matrix. If we include the previous matrix too, then it's only two float4x4 that HRV2 saves by using the compute. But it's not just the inverse of matricies, there's the regular matricies, light probes and potentially more. Is it really a big save in the end?
But the other reason behind using computes is to be able to write to ComputeBuffers in parallel from multiple threads. Is that correct?
No
ComputeBuffers parallel writing - independent thing as I mentioned in 1
But that's just the model matrix. If we include the previous matrix too, then it's only two float4x4 that HRV2 saves by using the compute. But it's not just the inverse of matricies, there's the regular matricies, light probes and potentially more. Is it really a big save in the end?
@fringe sinew I showed example is ~1.25Mb savings for 10k entities
if they're changed
And this IF is the point π
It's two beasts which solves two bandwidth problems π
So, technically speaking, CS is used strictly for uploading less data to the buffers by generating additional data on the fly before writing, correct?
Yep
But what about the upload operation?
Yep it's for copy data to big preallocated memory
Bah, started writing up my chunking system and forgot I can't use Lists, so now I'm stuck looping a entire DynamicBuffer on every entity which was what I was trying to avoid. I really should buy Fabians book to hammer this stuff home into my noggin.
BTW: SRP Batcher uploads materials once and caches them on GPU side. But it's not fully resident. For example all UnityEngine builtin properties (such as transform matrices) are uploaded for every viewport for every frame. In Hybrid Renderer V2 all of this data is also persistent, and delta updated. Also all per-instance material override data is persistent. In GameObject MaterialPropertyBlock, all of the overrides were uploaded every viewport. MPB actually disabled SRP Batcher for each affected GameObject. So everything was uploaded for objects with MBP.
We have plans to make things even more persistent. For example create persistent resource descriptors and descriptor sets on DX12/Vulkan/Metal/consoles. All the new APIs that make this possible.
I don't get the first and third points then and who writes where.
Do I properly get that jobs write to a CS compute buffer and then that CS writes the data to the big persistent buffers?
why wouldnt you want to use a dynamic buffer in that instance @loud matrix ?
Because I forgot I can't use lists and wanted to use Linq for easy filtering
Nested Dynamic buffers with for loops it is
I don't get the first and third points then and who writes where.
Do I properly get that jobs write to a CS compute buffer and then that CS writes the data to the big persistent buffers?
@fringe sinew Jobs writes to ComputeBufers, that's all π Depends on hardware it can be direct pointer to ComputeBuffer on GPU which used by CS or some intermediate buffer.
But in the end idea is write data to that buffers
And then merge them all to big buffer
@loud matrix want to describe the problem you're actually solving? Just wanted to note that a) to my knowledge you can't nest a dynamic buffer inside another (just in case you were thinking of it) and b) that sounds like an expensive problem - you may want to consider some kind of other structure ala boids potentially?
But do I properly understand that, in the end, the CS writes data from the ComputeBuffers into the "big buffer"? I'm investigating the code and so far it looks like no job actually writes to the "big buffer" @storm ravine
Alright, so the actual path of the data is to write to the ComputBuffer -> make the CS write to the persistent buffer
Correct?
Yes
Alright, now I get it.
Thanks a ton for enduring me.
No problems, that's wide and interesting area
hello there where can i ask for some help about DOTS
thats the answer for me or the other guy
oh thanks , can i share u a forum url that explain my problem and then u can try to solve or help if u want ?
i share it anyways,i hope u could help me, it is important for my degree final project
Thanks so much
cant get my stupid model to work with dots animation, rage rising
I have decided to shelve creating y own simple physics engine for now, hopefully by the time i come back to it the unity one won't eat 100FPs while doing nothing.
Time to see how it runs at scale with 1000 happy little entities crashing into each other
How would one implement something similar to how Mathf.LerpAngle works?
Because simply using the new math.lerp with an angle doesn't properly wrap the angle
Hold on I've got an idea, let me test it
Nope that didn't work
This is what I have at the moment π€
float3 difference = target - translation.Value;
float from = rotationEulerXYZ.Value.z;
float to = math.atan2(difference.y, difference.x) - math.PI / 2;
if (from > to)
{
from -= 2 * math.PI;
} else
{
to -= 2 * math.PI;
}
rotationEulerXYZ.Value = new float3(0, 0, math.lerp(from, to, deltaTime * faceMouseComponent.speed));
Well shoot, I tried using Mathf.LerpAngle instead of the stuff in the new mathematics package and it still does this weird behaviour
Here's the issue
(I've asked on #π»βcode-beginner too)
Yiiiiikes, from 450fps to 160fps for a single box collider entity. Perhaps I should dig out the old physics collision book
I've been digging through the physics collider code for a couple of days, and it seems like there is a lot of room for improvement...
I'd only seen their truck demo in video before, I never realised how bad it was. The rear wheels were floating when I tried it
I think they focused on scale rather than performance at the moment as it is a massive hit, but scales at that level.
I'm still trying to see if I can dig down into it and disable collisions when needed as I don't need them on 99.9% of the time.
Issue I have is I know, when they're done with it, it will be better than my very scaled back version if I do build one, so trying to decide If i wanna just stick with it in jank mode till it improves.
yeah that sounds like a good move, im the same right now where my basic box/point box/box type collisions are much faster, but unity physics has nice authoring setups and more advanced types which i would struggle to implement, so its better to use as much of the unity physics ones as i can.
It's just not optimised at all yet. Just adding the package tanks 150fps (about 1/3 of my in dev fps)
how much is that in ms
And the docs are wrong in places
@loud matrix You can step the physics world yourself, break things up into different worlds (or physics worlds) and only step them when you need them?
300 fps to 200 fps is different timings than from 200 to 100 fps
450 to 300
last i checked it was doing 10k moving rigidbodies in ~15ms on i7 8700k
Like i said, they focused on scale
@ocean tundra I still need to look into doing that, I can easily step the sectors the user is not in, but with the speeds involved I'd need to switch between no and full physcis quickly if needed and I'm still not 1005 on my chunking system yet (and still need to look into splitting up my worlds)
because "tanking 150 fps" is relative, it wuold be fine if you tank from 1000 fps, but horrid if you tank from 160
opps i meant 11ms for 10k rigidbodies
but ms is just a different expression of the same number
but ya
it def has issues but should be faster than physx from what i tested
also no it's not
200fps to 100fps is 100 fps difference
300fps to 200fps is 100 fps difference
but the timings in ms is different
You're comparing 2 different things though
also ms matters less with DOTS as we have great things like Jobs, we should be aiming for 100% cpu usage π
Its the same as me saying "its tanked by 30ms" that's also missing context
@loud matrix nope
because 30 ms is 30 ms
no matter what the baseline is
but FPS is a different length of time depending on baseline
so talking about FPS lost is 100% pointless
as an example
lets say i say "i lost 30 fps"
if my baseline was 60 fps
then that "30 fps" means 16 ms
but if i have 120 fps, and i lose 30
those 30 are instead 3 ms
That's not right though, if i say I lost 100 of 200 FPs that's me doubling my run time, if i gain 10ms from 10ms up to 20ms, same thing.
no, because it also depends on how it goes with the rest of the frame, and the budget
if something takes 1 ms, thats 1/16th of a 60 fps frame
FPS cant be added together
but ms can
No, you're right
so you can take your physics with 1 ms, + rendering 3 ms, and still know you have 12 ms left
I need a ******* drink apparently
after workign 2 19 hour days I forgot how to maths
if you're at 450fps your time per frame is about 2.22ms
i can imagine ecs physics taking up like 1ms base cost at low scale so that would tank fps by 1/3
but then if you double your colliders it should still be around 1ms (assuming low scale)
it doesn't scale linearly
yup
system overhead in current unity is huge
so it might be 1 ms to activate purely on system overhead
but then 1000 physics colliders is maybe 1.2 ms
which, btw, i believe its bullshit, the current overhead in unity ecs is completely unnaceptable
dumb question but is ms relative to hardware? like 16 ms on a pentium gold vs 16 ms on a quad cpu xeon workstation?
there should be a way to tell unity to run a number of systems with low overhead, with the job systems doing nothing, all singlethread
@safe lintel yup
ok just checking π
@vagrant surge you can use .Run for that
@ocean tundra still overheads
because it still checks if there are job systems touching those components
even with run()
yea and they have said they are working on system overheads, but at least you get Burst so its better π
if I have a job A and B, and I need to get the result of A to know how much job structs I need to create of B(I will scheduleParralel each B struct), is there a way I can do that without having to Complete the job A ? :/
what i mean is that there should be a way to basically set a group of systems as "just run all of them togther as Run()"
and that would lower overheads to near zero
hell, my unity style ecs has near zero overhead
more than 100 times less overhead than unity
but it doesnt do multithread checking
@zinc plinth Expose the JobHandle from A (Dependancy) and pass it into the schedule call of job B
the thing is... what if you could tell unity to not even bother with multithread checking
how much overhead is there to run a system atm
@hollow sorrel from my tests, unity tiny, on editor, with all debug checks disabled
0.2 ms for a 8 component system
linear
what
4 components is 0.1
that's huge
the entire logic of Tiny Racer takes about 2 ms or so
and tiny racer
is so tiny
that it shouldnt even take 0.1 ms for the entire thing
so 10 systems already = 1-2ms?
That's like 10% of the 60 FPS gone, just by doing nothing.
red box is actual real execution
blue is overheads
of course, thats with profiler and editor. But even if its half that size in non-editor-build, thats completely unnaceptable
@ocean tundra as in for now I have
var jobA = ...
var jobHandleA = jobA.Schedule()
jobHandleA.Complete()
for(int i = 0; i < jobA.someArrayThatIGetFromIt.length; i++) {
var jobB ...
}```
how do I avoid using `Complete` in this situation
if thats in the same SystemBase
damn
you dont have to worry
btw, overhead being completley linear to however many components you access in your system
wait wat
i would like to try it on a build, but the samples are hella broken and cant build
I can just use the length at the time of scheduling even if the array isn't allocated yet ??
using SystemBase and OnUpdate, jobs and Entity.Foreach..... will automaticly be scheduled to run one after the other
only within the same SystemBase
hodamn, that's rly nice
between Systems is different, you need to get the jobhandle (like you did above) and pass it into JobB.Schedule(HANDLE)
yea was really nice when i discovered that
i think it was even in the docs π
is there somewhere this is explained more in depth ? cuz from how I saw things at first all the stuff I do in OnUpdate is the scheduling of jobs
but does using this create a sync point or ? @ocean tundra
@lusty otter the thing is that, from analyzing that trace, basically the entire overhead comes from job system checking dependencies
if you could remove that
by telling unity to execute a chain of systems singlethreaded (or as 1 compound job), you could lower the overheads HARD
i think job scheduling takes ~0.05ms too last i checked
@zinc plinth what docs there are are here https://docs.unity3d.com/Packages/com.unity.entities@0.10/manual/
so lets say you have the tons of systems on your physics
cant find exactly where i found that
but you dont need the multithreading until you go past 1000 objects
it would be great to tell unity
if less than 1000 objects, do not bother, execute all systems one after another as a single job for all that chain
at more than 1000, have proper multithreading
That's what I'm doing with my extremely simplified ECS too
my own unity style ecs doesnt even cache archetype lists, its just not even needed with how stupid fast it is
My systems are supposed to complete their jobs before moving onto the next, it's calling complete anyways.
i think i measured each system being like sub 0.01 ms
@zinc plinth I'm not super smart about sync points, i think they come when your doing something with the EntityManager (adding/destorying) or using .Run
and thats without caching things
I would like them to just not check multithreading safety stuffs, there's no need for it.
with caching it would be literally 0
@lusty otter there was a lunatic on the Entitas github
that said he was running 1500 systems
cuz using such array's length seems like it would hit spot on the definition of a sync point A synchronization point (sync point) is a point in program execution that waits for the completion of all jobs that have been scheduled so far. hence why I'm so surprised of this behavior, and have no idea how that would work in practice
of course, thats entitas systems using change tracking, so its systems that only run when something changes
but still
1500 systems
good luck doing that on unity ecs
on a phone
π
damn
It starts to make me think it's not even worth using Job system if the job itself isn't expensive.
also 3000 components
The overhead might just be bigger than the benefit you get from Burst.

rust has rayon for job systems that is crazy smart and wont launch the job if the worker threads are busy
it's so weird to read "0.05ms overhead isn't anything" in the forums when ppl were showing 1 million byte iteration+addition calc taking 0.05ms couple weeks ago here
could be doing 1 mil iterations per system overhead
have you tried writing the jobs manually and not using SystemBase?
maybe that would be faster
i only checked jobs manually and that took 0.05ms
apparently systems take even more
0.05 ms is super high
pretty sure cpp task systems arent so slow
i kinda wonder exaclty whats doing for that sort of overhead
its probably just all the stuff they do in the wrapper around Update - running in normal c#. Its got multiple delegates, exception handling, bunch of branches its easy for that to add up.
Theyβre trying to make all the jobs structs that can be bursted which should hopefully help a lot. I also posted a suggestion on the forums for a ScheduleParallel that takes a chunk threshold - below which it uses Schedule
struct AJob : IJob
{
[WriteOnly] public NativeArray<int> test;
public void Execute()
{
test[0] = new Unity.Mathematics.Random().NextInt();
}
}
// Start is called before the first frame update
void Start()
{
AJob aJob = new AJob
{
test = new NativeArray<int>(1, Allocator.TempJob)
};
JobHandle dep = aJob.Schedule();
for(int i = 0; i < aJob.test[0]; i++)
{
Debug.Log("result: " + aJob.test[0]);
}
}``` https://i.imgur.com/YMBS6Ef.png
idk what u read but that's wrong apparently, and makes alot more sense @ocean tundra
yes I know; the question I asked was how can I modify this so that I dont need a Complete..
if it's at all possible
edit for what I actually want to be able to do: AJob aJob = new AJob { test = new NativeArray<int>(1, Allocator.TempJob) }; JobHandle dep = aJob.Schedule(); for(int i = 0; i < aJob.test[0]; i++) { BJob bJob = new BJob { }; JobHandle jobHandle = bJob.Schedule(dep); }
if I have a job
AandB, and I need to get the result of A to know how much job structs I need to create ofB(I willscheduleParraleleachBstruct), is there a way I can do that without having toCompletethe jobA? :/
@zinc plinth
i don't think this is possible because you can only schedule jobs from main thread
yea that's what I thought..
but it's so annoying, because I will need a lot of this kind of system, and throwing 10+ sync points right off the bat isn't the best :x
the A jobs will always be really small (3/4 entities) but still..
what happens exactly when you use Complete, does the main thread completly hangs or ?
hooo, you mean combining the sync points of all the systems into one ?
yea so you have one system near the end of your frame that calls complete on every of those A jobs and then does the scheduling of B
or something like that
hmm, how do you pass job handles between systems ?
make them public and entityman.getsystem<>
hem are u sure it's in the entitymanager ?
why do you need that pattern alot?
I have grids that can be flagged as to needed to being worked on, and members of each of those grids
I don't want to process all the grids that are not flagged
and each grid element has a shared component with the id of the grid
for the entityquery
yup makes sense
so first job is to gather everything that needs to be worked on?
and 2nd is run per thing?
ya
i think you can get away with only 2 jobs
ops i guess it's world.getexistingsystem
but the 2nd needs to be custom written as a IJobForEach (i think it is)
https://i.imgur.com/cUUJBR4.png ayy @hollow sorrel
and it can be scheudledParrall
@ocean tundra hemm, can you pseudocode that ? I don't see where you put the entityQuery.setFilter in there
oh the 2nd Is not a Entities.foreach
so im actually doing simlar
i have a Entitis.Foreach () this builds a nativemultihashmap of PlayerIds, Messages
then i have a Job.WithCode that loops over that result and sends it to players, but due to reasons that has to be .Run
but somehow its possable to get a Job that will schedule many depending on the size of the input list
but pretty sure you have to write that 2nd job without using the SystemBase helpers
IJobParallelForDefer
Oooo whats that?
If you need schedule job with dynamic range which unknown at schedule time
For example you have job which populates NativeList
You don't know how many item will be in that list
And you want schedule parallel job
with size of NativeList.Length
IJobParallelForDefer with NativeList.AsDeferredJobArray solves that problem
well yes, except I would've liked to scheduleParralel on my second job :/
and I can't use my setFilter with this
And all what you're talking above was a bit wrong, because of @zinc plinth wants different thing, not what @ocean tundra tried to suggest π it was like "I want juice" answer - "Go jump with dog"
You don't need any filters here
I don't ? 
IJobParallelForDefer
@zinc plinth
hemm, the array I get from the first job is the grid ids, I don't want to iter over all the grid members of my world
ahhh i though you did
Who speak about whole grid? if you populate array with only required items which should be processed next you should use IJobParallelForDefer
Example:
Problem:
{
var listOfItemsForProcess = new NativeList<int>(Allocator.TempJob);
Dependency = new JobA()
{
list = listOfItemsForProcess
}.Schedule(Dependency);
Dependency = new ProcessList()
{
listOfItemsForProcess = listOfItemsForProcess
}.Schedule(?????, 10, Dependency); //<- you don't know how many items will be in listOfItemsForProcess and can't schedule parallel job for that count of items here, because it not yet known
}
public struct ProcessList : IJobParallelFor
{
public NativeList<int> listOfItemsForProcess;
public void Execute(int index)
{
}
}```
Solution:
{
var listOfItemsForProcess = new NativeList<int>(Allocator.TempJob);
Dependency = new JobA()
{
list = listOfItemsForProcess
}.Schedule(Dependency);
Dependency = new ProcessList()
{
listOfItemsForProcess = listOfItemsForProcess.AsDeferredJobArray()
}.Schedule(listOfItemsForProcess, 10, Dependency);
// you pass listOfItemsForProcess as argument and use listOfItemsForProcess.AsDeferredJobArray() as field
}
public struct ProcessList : IJobParallelForDefer
{
public NativeArray<int> listOfItemsForProcess;
public void Execute(int index)
{
}
}```
Thus secong job will be scheduled properly and will run only for items populated in previous list
without completing dependency chain
hoooooooo you mean by providing them in advance
but that blends all the grid members of the flagged grids together, and prevent to get a per-grid processing state 
And one more (again, which was mentioned by me here many times) Complete() - Not Sync Point. It just completes current dependency chain. Sync Point - complete ALL jobs in world
but that blends all the grid members of the flagged grids together, and prevent to get a per-grid processing state :Notlikeduck:
@zinc plinth rephrase that, I don't understand what you mean π
You populate list of elements. It can be indicies to grid, it can be some items etc.
You just take possibility schedule job with deferred array with appropriate length which unknown at schedule time
For example, I have 100 units with some their state in component, in first job I collect only units with required state, and then I want run parallel job for that units with required state and process it on 1 worker thread per unit (batch count 1) for AStar for example
hemm, like for one system I did I need to iterate over specified grid elements and check if they are in range of eachother, if a "connected" grid member is in range of some other, that grid member will get turned into a "connected" one
I use 2 native arrays to store these(one for non connected members, and one for connected) and both are the size of all the members combined; this works because all the grid members are from the same grid
if I throw multiple grids in this, there is no way I can make it work without jumping everywhere in memory between the thousands of elements I need to sort, and I need to find a way to keep 2 arrays for all the grids in the same job somehow
You can even collect in parallel job first by parallel list writer or in to NativeHashSet\NativeHashMap and use intermediate IJob for remapping hash map\set to list which will be used as deferred array
I don't get what you want
I just can't understand what you trying to do from your explanation
I'm sorry 
What you trying to say now completely different from what you asked before :)
var jobA = ...
var jobHandleA = jobA.Schedule()
jobHandleA.Complete()
for(int i = 0; i < jobA.someArrayThatIGetFromIt.length; i++) {
var jobB ...
}
it's because all the detail lies in the jobB, that I thought I could avoid explaining at first but was crutial in the end 
sorry for wasting your time
Well let's try again
You have some job A - what purpose of that job
abstracted from your exact logic, just in couple of words
I have grids that can be flagged as to needed to being worked on, and members of each of those grids
I don't want to process all the grids that are not flagged
and each grid element has a shared component with the id of the grid
for the entityquery
first job is is getting grid ids;
Ok you have grids where ISCD is ID per grid right?
First job collect required ID's right?
ISCD ? 
ISharedComponentData
ho, ya it collects the ids & other metadata I need for each grid
Grid itself is entity?
yes
Ok. You process in job all grids, collect for example with ID 5 and 7, then what you doing with them?
exclude Complete schedule part
Just intention
For every ID run parallel job
Which process items with same ID?
yes
That items also has same SharedComponent with that ID?
in the Grid it's just a ICD containing the id, in the GridMember it's a ISCD
Ok not a big difference
I'm so retarded jeezus christ
I can just get the amount of entities from the original EntityQuery 
because every Grid in the entityquery are going to be worked on
Well if they have some tag component which indicates that they should be processed, and EQ returns you not all grids - then yes
I'm so sorry this shouldn't have taken so much time to figure out 
each grid can contain a tag that says "this grid needs to be worked on"
Well then all clear.
thank you so much β€οΈ
I have the slightest feeling this is not quite 100% on the ball realistic
It's clearly a cube made of rubber
π super rubber
rubber so efficient it has >1 elasticity 
That's what we call "Just Right" game feel
ehehehe
Hi guys, i have an issue with the following code using blob assets.
I have the following error: error MayOnlyLiveInBlobStorageViolation: You may only access .Name by(non-readonly) ref, as it may only live in blob storage.
@eager jungle Where are you trying to access the data from and can you show the code of how you're trying to access it.
@mint iron So err, what is that then?
they're volume modifers using the physics shape authoring. drawing the shape colliders at edit time (while not selected), doing collision test on the native colliders (outside of physics system) and marking up flags on the grid
the grid is a blobasset in a subscene, so it all gets baked but the volume modifiers could also be used at runtime in dots.
thank you @loud matrix !
hey guys sorry for the newbie question, im trying to get started on dots and I just installed the dots editor package. It installs burst as a dependency but burst has been giving me a problem. I keep getting a pop-up saying "The version of Burst used by your project has changed. Please restart the Editor to continue."
The issue is that I restarted the editor multiple times, but it doesnt go away and also throws some errors in the editor itself.
apparently it cant find glibc? I know for a fact that i have it installed (im on linux btw)
DllNotFoundException: Unable to load the unmanaged library /home/bluebouris/Dev/Unity Projects/DOTStestproj/Library/PackageCache/com.unity.burst@1.3.0-preview.12/.Runtime/libburst-llvm-9.so Reason: /lib64/libm.so.6: version GLIBC_2.27' not found (required by /home/bluebouris/Dev/Unity Projects/DOTStestproj/Library/PackageCache/com.unity.burst@1.3.0-preview.12/.Runtime/libburst-llvm-9.so)
That's what I'm getting
Okay i'm getting at something. Apparently my distro provides me with glibc 2.26 while burst is looking for 2.27 according to that error
At this point I cant tell if the physics engine is cursed or what. It seems to demand i have a custom component in my archtype, one thats not used and doesn;t have any systems or data. But only sometimes, its iffy with it being there and sometimes just won;t work even if it is. And now I remember why i dropped this thing last time i tried it.
Ahhhnnnd now it won;t work at all, just makes my entity NaN on all WorldRenderBounds, LocalToWorld, Rotation and Translation
@storm ravine the solution I thought was possible isn't in the end because beyond just needing the amount of grids it needs to work on, it actually needs the grid id for the setFilter sooo..
And what the problem? _q.ToComponentDataArray<T>_q.ToComponentDataArrayAsync<T> where T your component with ID and you have array of your ID's for SetFilter
didn't they want to deprecate these ? 
No
ho
actually, what's the behavior of ToComponentDataArray if you use it to get arrays of 2 components on the same query, will the indexes align so that 1 index is the 2 component from the same entity or can it be random ?
actually, what's the behavior of ToComponentDataArray if you use it to get arrays of 2 components on the same query, will the indexes align so that 1 index is the 2 component from the same entity or can it be random ?
@zinc plinth
They are guaranteed to align
Nice!
Unite Now talk for Kinematica was recorded 2 months ago and it only now got out
meaning, there are still chances they've stacked that Mike Acton talk on the queue π
the dream
is EntityManager.SetEnabled() intented for editor use only or both ?
Both of course it just add\remove Disabled tag to entity archetype (or for all LinkedEntityGroup if exist)
Hello there , I am trying on editor to fill a not main scene with gameobjects and then use it as subscene but when i try too close the scene unity crashes
Scene aux = EditorSceneManager.GetActiveScene();
Debug.Log(AssetDatabase.GetAssetPath(Subscene));
Scene aux2 = EditorSceneManager.OpenScene(AssetDatabase.GetAssetPath(Subscene),OpenSceneMode.Additive);
EditorSceneManager.SaveScene(aux2);
Debug.Log(aux2.name);
EditorSceneManager.SetActiveScene(aux2);
// GameObject a = new GameObject("SubsceneGameObject");
// Undo.RegisterCreatedObjectUndo(a, "Created SubsceneGameObject");
EditorSceneManager.SaveScene(aux2);
SceneManager.SetActiveScene(aux);
subsceneGameObject.GetComponent<SubScene>().SceneAsset = Subscene;
//if (aux2 != null)
//EditorSceneManager.CloseScene(aux2, true);
I am sure is about a race condition but maybe u could help , i dont know much about scenesmanagent and subscenes
The code above its just a test
im using hybrid_renderer_v2 and ECS, my entities created in ECS are not being SHOWN being rendered, even with it showing that they are being detected. I can also render objects in scene, with the same mesh and texture, im not sure whats going on
the only thing i can think of in the debugger is that AddWorldAndChunkRenderBounds says "not run"
but the entities in the debugger show render bounds, world bounds, mesh as normal
HybridChunkInfo too
any thoughts
HybridRenderer 0.5.0 package is present and you're using 2020.1+ ?
yes
are you using a subscene or convertAndInject?
uhh, neither, I am creating entities using entityManager.CreateEntity(EntityArchetype archetype, NativeArray<Entity> entities), im using defaultworld, and just the normal scene. I have URP 9.0.0-preview.14
im sure im doing something wrong
its just weird cuz I can render objects I add
are you sure they arent falling or flying off in a random direction?
i think someone asked this question before, does your entity have "RenderBounds" component ?
yea
that's what happened to me a few days ago
the position in the editor/debugger might not be updating correctly
that makes sense but let me check
do you have physics stuff on your entity ?
no, actually I forgot to mention that everything stopped showing the second I enabled it, but works without it "ENABLE_HYBRID_RENDERER_V2" in project settings
but the code is working the same, and its still batching everything
just not showing anything
but it will show the same mesh and sprite being added post scene starrt
as game objects
is translation NaN ?
translation is normal coordinates as intended
like therre are no errors for any entity
within camera
i would try getting something to show up using a subscene - like create a subscene, drop a cube GameObject in it and hit play, if it renders you'll know the issue is related to how you're creating them in code.
its advised to instantiate renderable stuff from prefabs instead of creating on code
hmm off the top of anyones head, let's say I had this native list. It has a capacity of 100, with a few added elements so its length is like 3. If I memset from [3,99]
would the length property still be 3? π€
yes, you'd have written the data but the length will only change using the default methods Add, AddRange etc
there's a method to set the length though, cant remember what it is off the top of my head
wow
not sure how but anything tied to ECS wont render at all
with hybrid_renderer_v2
enabled in project
even using other projects
is there another setting im missing
Sorry can you explain further @bold sleet so you start a new project, import the ECs packages, add a camera and nothing renders?
@bold sleet are you using netcode package?
why does rider just sit there saying 'evaluating' or 'processing' forever when i try to inspect serialized properties :S
It's just a thing it doesn't support properly. There's an issue listed on their github
awesome, ty sir!
I am trying to clean up some old jobs I had where I was manually calling CompleteDependency() in order to read from the data elsewhere. Is the best approach to use [UpdateAfter] ?
I guess what I am saying is should I add them all to a group, and then order them inside that group with update before or update afters, or is there another approach that someone would reccomend
I followed the approach listed above and it appeared to work out for me
So. Weird "bug" in the multiplayer sample (has anyone else seen this?) the CubeInput code all seems to happen for every connected client (in other words, all cubes are moving not just the cube from the currently "presenting" connection)
Might not be the right place to ask but here goes:
I'm trying to make a "floppy" stick using a Chain IK Constraints from the Rigging package (2.6). But the stick is very rigid in the way it bends. Is what I'm trying to do possible (the dark blue line is what I wanted to happen) with the Chain IK Constraints? Or no?
@tardy locust Yea pretty sure thats not DOTs, isnt rigging just a animation package? Maybe try asking there?
Yeah I'll try that
@loud matrix yea for some reason having ENABLE_HYBRID_RENDERER_V2 active causes nothing relating to ECS to spawn, no subscene (with simple setup), no one elses stuff, nothing, but i remove ENABLE_HYBRID_RENDERER_V2 and it works again as normal, weird... but game objects load just fine. using same textures.
like i have ENABLE_HYBRID_RENDERER_V2 and use gameobjects, not ecs entities, and they work fine
idk!
@bold sleet are you using URP or HDRP?
not spawn,l i mean render
i have URP installed
everything spawns btw, just doesnt render
yea im using that too
i just want to fix this build bug i have, and after that i can try activating V2
see if i get the same
is like, V2 worth it, using game Objects
V2 without game objects should be worth it. the preformance boosts look great
just hold entity data... which is what I wanted ECS for, since I get immediate preformance gains, like 100k entities working on screen with over 20fps, which is alot for me
for what i am doing
?? they hold entity data?
no like
i'd use the game objects as entities
if i had to choose
but i'd have less of them since game object is slower
oh nvm
I see why ECS is faster, no game object overhead
Anyone know how to track down Burst exceptions from a build?
I'm getting things like:
lib_burst_generated.dll caused an Access Violation (0xc0000005)
in module lib_burst_generated.dll at 0033:ca7e9f46.
makes zero sense to me π¦
pretty sure its happening when burst compiles a bunch of jobs needed for the first time
well thanks everyone for the help, i'll just mess with this in my spare time and be grateful for ECS working at all
good luck π
I also get things like "Attempt to access invalid address." in my logs
Is there an easy way to limit the number of entities a job runs on in a given update? Use case is loading chunk for a world, for example, not wanting it to hang on one frame
I haven't heard of anything like that but you could probably do it yourself
but also with the JobSystem and Burst you can process crazy amounts of entities
your "start" system needs to find all your entities and add a component to them, but stop adding that component when a counter is too high
every other system only processes when that component exists
but again not sure you need this, unity has new ways of loading/unloading things (subscenes)
and pretty sure you can do it all in a background thread
I might do the add the thing to only a few entities, just wish there was a simpler way of restricting the amount of processing done per frame, or earlying out in some way that wasn't obnoxious
I guess that wouldn't be deterministic though, if was based on processing time
take a look at substreams
subScenes*
and exclusive entity transaction
pretty sure you can do all the loading in background threads into background worlds
then "pop" those worlds into the main one super quick
thats what that mega city demo did
Thanks, I'll look into it
I don't know if subscenes work for complete procedural stuff
yea i dont think so
my plan (still super early) is to create a few "generation worlds"
do all the procedural generation in those
then use that transaction thing to bring it all into the main world when ready
i also plan on ticking my systems manually
so not limiting number of entities, instead limit what systems can generate each frame
and maybe one day unity will support long running jobs for anything that i cant break up
but im still ages away from all that
How can I add something to a list in a Foreach.ScheduleParallel()?
The parallelWriter hasn't a function called .Add()
I think it's AddNoResize @wide fiber
Ok ty, but if the list hasn't enough capacity and I use AddNoResize will it work?
No. It will throw overflow exception. Parallel native list version expect you have known capacity.
@storm ravine ok I've switched to Schedule() instead of ScheduleParallel ()
Why can't I use https://pastebin.com/4wfpqFxY
Entities.WithDeallocationOnJobCompletition(list).Foreach(...); ```
how do i use hybrid renderer for a 2D project?
@gusty comet
2D Renderer is only for Project Tiny right now https://forum.unity.com/threads/first-batch-of-2d-features-for-project-tiny-0-22-is-now-available.830652/
Trying to get my head around converting from a direct position system to a physics system is messing up my head. So simple to just say 10ms acceleration, 300ms max speed. but nope, now I need to define impulse acceleration and vehicular mass then work out the conversion to show what the max speed actually would be.
If I have an entity with a physics shape (a sphere) how can I get the radius in the code? In the entity debugger the only component that I can see is Physics Collider and it is empty
You can get the radius from the BlobAssetReference<Collider> SphereCollider that's created for the entity. Should be accessible from PhysicsCollider
Are you using convert to entity or making your entities and physics programmatically?
Hey. I'm trying to iterate over a dynamic buffer in quite the naive way to understand it better:
I'm trying to do int x = buffer[i] inside a loop. but the engine does not allow that.. how should I go about it?
Can you show your full code
It's really as simple as that:
IBufferElementData with int value.
Filled the buffer with ints as one would treat an array (works as expected)
Then just trying to do
for(int i =0 ;i < buffer.length ; i++)
intx = buffer[i]
That's why I suggest posting the entire thing, as it should be that simple.
"Cannot implicitly convert type (buffer) to int"
You need to access the property in the buffer int = buffer[i].Value Or what ever property that is a int in the buffer struct
yep. that was it... goddamn. Thanks man
__
<(o )___
( ._> /
`---' Rubberduckie to the rescue!
Rubberduckie \o/
umm
Why can't I use https://pastebin.com/4wfpqFxY
Entities.WithDeallocationOnJobCompletition(list).Foreach(...); ```
@wide fiber because only native array support that attribute.
For other native containers you should use Dispose(JobHandle)
btw @storm ravine are you doing all of the rendering for you own game yourself or do you use any part of the hybrid renderer?
Already answered above π Every thing with animation - render by myself through DrawMeshInstancedIndirect (units, buildings, animals). All other - hybrid renderer with custom shaders (trees, cliffs, ground)
Working with pure ECS with the physics engine is a new level of mind bending
Are you using convert to entity or making your entities and physics programmatically?
@loud matrix convetToEntity
@wide fiber because only native array support that attribute.
@storm ravine ok ty
It should still be accessible from the PhysicsCollider.Value as a BlobAssetReference<Collider>
Ok I'll try, thanks
What would be the simplest way to run the same Entity Job with different queries (in different systems basically).
Entities.ForEach, could be chunk if req.
Well, I know you could do it with IJobChunk, but it's a bit messy to set up.
but Entities.ForEach is a query
IJobChunk much cleaner for setup π
@opaque ledge Entities.ForEach is IJobChunk π
Yeah sure. So doing a calling a method from the Entities.ForEach, but I need to specify it multiple times, it's just some tag that differs.
Well with Entities.ForEach you can write your struct with some method and call it struct from all your ForEach which should do that thing
Or write your own job π
Which do all boilerplate under hood π
IJobForEach will be deprecated, hmm alright.
IJobForEach - yes
I basically have a module I want to be able to run for both predicted, interpolated and client local entities. Hence for predicted they need to be in special group which can run multiple times.
I haven't understood the problem, can't you make a static function that takes the things that you need and call it from the Entities.Foreach?
Yes, I figured that would be the best solution anyway. I thought I could use a EntityQuery with Entities.ForEach and on creation of the system feed in the additional components that would be appended on the query and later used. But realized I would either way need some additional code for ShouldPredict() on the client side anyway.
Why didn't they make math.select and math.step paramaters the same order as a ternary, I keep having to search the git repo to remind myself of the order.
Hey, does anyone know where im going wrong rying to make a basic Job:
Youβre using light theme (jk π ) - you need to put your code in a class that extends SystemBase to use Schedule etc - might be worth checking out the samples quickly first.
I've seen something similar working

Yes you fell free to ask here about DOTS