#archived-dots
1 messages ยท Page 2 of 1
Ya know, the documentation on this converted sprite rendering system is actually really good
using UnityEngine.Experimental.U2D;
hmmm
seems like it's removed in older versions
so you can't use native unity sprite renderer API
hmm
the only thing that bothers me atm is Culling
2019+. Should be fine
It's not in a manual though
Internal native code attachments.
Basically hardcode rooted inside the engine. No use rolling our own sprite renderer short of SRPing it manually.
So if we want to use a converted sprite renderer, it's this package or custom srp.
thats custom srp
organize your own draw calls. Uses the same API. Graphics class. Doesnt matter what RP you're using, it wont go through them.
ahem
Thats what I'm doing with my lighting system. A render pass / command buffer with my own drawmeshinstancedprocedual / indirect
if you use Graphics api it won't work?
why not?
features? Like ScriptableRendererFeature?
That is essentially an API to Graphics class. Well they both point to the same driver C++ API.
I always assumed that if I draw meshses with Graphics API it will be processed the same way
with URP options
There are no URP or HDRP specific rendering feature options.
You can use the same code in URP as in HDRP and even built in. All that is changing is the attachment point for the command buffer to the camera rendering loop in the engine.
Im assuming you have to implement those manually.
I havent tried. Hell, I need to manually implement my own objectToWorld matrix because procedural calls doesnt set it.
I already have it setup
I just need to figure what can I use
in order to see whether it's affected
here's my quad
I think for the RP to affect Graphics calls, you need to use RenderPrimitive or RenderMesh.
here with x8 msaa
So yes?
MSAA is a graphics driver level implementation though
Vulkan has their own MSAA, same as DX
The [Graphics.DrawMeshNow] mesh will be just drawn once, it won't be per-pixel lit and will not cast or receive real-time shadows. If you want full integration with lighting and shadowing, use Graphics.DrawMesh instead.
Use
RenderMeshto control Mesh rendering programmatically without the need to create and manage GameObjects.RenderMeshsubmits the Mesh for rendering, which means it does not render the Mesh immediately. Unity renders the Mesh as part of normal rendering process. If you want to render a mesh immediately, use Graphics.DrawMeshNow.
it is indeed affected
Entities.WithNone<DisableRendering>()
.ForEach((in RenderTargetLine line, in GetToPoint gtp, in LocalToWorld ltw) =>
{
if (gtp.target.Equals(float2.zero))
{
return;
}
float2 position = ltw.Position.xy;
var delta = gtp.target - position;
quaternion rotation = quaternion.LookRotation(Up, delta.ToFloat3());
float3 scale = new float3(line.thickness, delta.Magnitude(), 1f);
var matrix = float4x4.TRS(new float3(position + 0.5f * delta, 0f), rotation, scale);
Graphics.DrawMesh(MeshDatabase.Quad, matrix, MaterialDatabase.PlanetTrail, 0, null);
})
.WithoutBurst()
.Run();
this is how I draw movement lines
so yep
nothing to worry about
can simply write SpriteRenderer with C#
and draw instanced through Graphics API
hrm, .withoutBurst() and .run(). Basically a fancy foreach loop?
this is so fun
yeah
I can do instanced
ez
just was too lazy
Graphics calls have to be mainthread?
Im 99% sure commandbuffers can be threaded / jobbed.
with this rendering features you can actually test stuff
And then frame-end you can complete and Graphics.ExecuteCommandBufferAsync
but but, bursted jobs
everything needs to be burst compiled
even the rendering calls
no, this won't
in the end you'll just do
Graphics.DrawMeshInstanced(mat, ltws.ToArray(), Mtb);
smth like that
foreach loop
I never heard of graphics APi being bursted
ever
well, im gonna try
and I don't care way too much about it
since instanced rendering is already fast enough
faster can only be indirect
Well, first mesh are classes and thus can not be bursted
well yeah
so that goes out. How about jobbed...
that's why you batch them
as shared components
so you know all same meshes by sharedcomp id
wait
Does Graphics DrawX respect render targets?
DrawMesh and the bunch
hm
not sure
I'd assume
if RenderTexture is null
it'll draw for monitor
if not - it'll draw for selected render texture
at least that's how CMD worked
If i can instead shift this into a systembase using instead Graphics class, that might be better
but you can
and simply use URP
kek
I just showed you - rendering features affect DrawMesh calls
urp bad though. Maybe I should go built in?
URP has slight overhead. fractions of a ms but still
it's literally faster than built in
hrm, yea. thats what people are saying on the forums as well
But if I'm rolling my own lighting, my own physics, and possibly my own sprite renderer, why am I using URP?
because UI tooling
Despite everything, i admit UIElements is pretty good. And Burst. I cant use C# without burst anymore.
Either that or I go back into the hellhole that is C++
kek
I personally avoid going down the path of creating everything from scratch
I would spend more time creating engine
than game
this is sad part about Entities
most of things you indeed have to recreate
Control and custom features. You aint gonna get this lighting using provided systems
maybe that too, I haven't used it too much
500 lights simultaneously though? URP 2D lighting uses geometry shaders, at most.
And a draw call per light which is a travesty.
Nah, it's shit. I have no regrets rolling my own lighting.
I guess it really depends on the type of game then. I'm making a top down 2D. Sidescroller probably doesnt need lighting.
Or if it does, the built in functions well. In fact, URP 2D lighting was probably designed with side scrolling 2D in mind.
it would look nice to have planets cast shadows, kinda.
properly scaled planetary systems would have a literal pixel width shadow cast beyond the planet compared to the size of the star
eh
it's 2D
ships are flying over planets, kek
and I use 3D planets
so planet satellites indeed will leave a shadow
at least I hope I will be able to implement it
2D shadows are important. I have prototypes for real time 2D global illumination. Makes things look amazing but slaughters the FPS
smth like this, with an angle offset for light rotation
I have no goals to make it realistic, just want it to be fancy
I guess that is the good part of unity, it's a 3D engine that can do 2D.
tbh
if I use Lit sprites
all will be affected by lights
but point is same
I don't see goal in it with this kind of game
you just want everything to be visible good enough
If you're not planning on any complex or a lot of lighting sources, yea using the provided lit shader works perfectly I admit.
hehe
visuals are great. That's where all the complex magic coding goes into
and that's what I'd avoid
focusing on player's game story is way more important in RPG
gotta make unique experience
also interesting
that's why burst and jobs come so in handy
ppl love when everything is simulated precisely
Huh. Dots 0.60 is already on 2022.2
April fools long gone
And they're using IAspect<>'s. Hrm. Dont know if I like what im seeing
Not the code itself, but how IAspects are structured. Seems like a manually implemented [GenerateAuthoringComponent]
I thought it would be replacing IComponents authored from Editor but in that codebase, they still have to manually code in the IComponentData as well. And then also code in IAspect.
And then there's the converter as well manually implementing GenerateAuthoringComponent https://github.com/Unity-Technologies/DOTS-training-samples/blob/dots-training-2022-07-eu-group3/Ported/Combat Bees Port/Assets/Scripts/Authorings/BeeSpawnAuthoring.cs
Hrm, I must misunderstanding what an Aspect is.
It's a replacement for Archetypes, not IComponents
This is so incredibly odd
not for archetypes, it's like a high level abstraction. nice in theory but I think it leads to some very bad habits
But that's an example of a bursted ISystem in possibly DOTS 1.0
tile.Scale.ValueRW.Value like why.
Abstraction of what? You still need to manually code the authoring, the components, and of course the systems. It's an archetype.
why do you think it's an archetype? it's just another way to look at an archetype and make it easier to build references and custom accessors
It defines a collection of components that compose a single entity. Sure it also defines the accessibility of the properties of an entity but otherwise, it functions exactly as the current script based Archetype does.
notice in the bee sample that no aspects are used for authoring, only components. the whole thing could be built without aspects and the low level data would stay the same. the aspects are built on top of the data and give a high level access for components and entities. what i don't like about it is that aspects stink of oop
True. Hrm. Im looking at buckets as it seems to be a completed training sample rather the currently in progress bees
using aspects won't change anything in the archetype is my point i guess
i'm honestly not too sure what's up with the aspects. the only thing it does is making it not as obvious that random memory access is used via pointers. so, a whole system to enable pointer access without using pointers really and staying in non-unsafe space.
Hrm, I thought it would be easier to instantiate entities since now there's a compile time struct based archetype definition but now, no clue
what would be the difference to an authored prefab?
is 0.60 ready for use? or just the examples?
good point, no clue. hrmmmmmm
you know what's missing? Lambda statements
There are no Entities.ForEach()
https://github.com/Unity-Technologies/DOTS-training-samples/blob/dots-training-2022-05-na-group1-Buckets!/Ported/BucketBrigade/Assets/Scripts/Systems/TileRenderingSystem.cs
This is a classic case to use Entities.ForEach() and such except its not used. Regular c# foreach is used instead.
No, just internal unity can use 0.60. And no official examples are published. I'm using the training samples for info like how we scraped for changes back during the 0.17 dark ages.
ah sad.
foreach (var tile in SystemAPI.Query<TileAspect>().WithAll<Combustable>()) This is how they're getting lambdas into bursted struct based systems.
hm, well, to not be all negative about aspects. i think querying with them is a lot better defined
I now think that Aspects are replacing the lambda queries.
not totally related. they are changing it because codegen was slow
it might also be a possible performance upgrade for queries.
Like how currently we have:
Entities
.WithName("FovCollectionJob")
.WithStoreEntityQueryInField(ref _fovQuery)
.ForEach((Entity entity, in GoTrs trs, in FovProp fovProp) =>
The .ForEach() will be replaced.
This is all codegen replacements so I dont know about performance.
newer is much better ๐ fk Entities.ForEach
i mean, performance of the actual code-gen. it takes quite long and causes a bunch of problems in VS
c# foreach and using aspects for queries will help with intellisense at bare minimum
true, this might help with that. I have 2 jobs so Im not running into any performance issues with code gen so far
I dont know how debugging features like naming jobs will function
but, as this code-gen'd foreach query stuff is too dumb anyway for anything more complex than a basic prototype i'll still stick to good ol' jobs
as long as they can't figure out how to handle conditional component type version changes it's not usable
havent touched component versioning, everything on my system runs every frame so i havent run into any issues on that front but yea, i can see how it might be difficult
and they will never allow getting a RO pointer access from a write handle and manually bumping version, so, goodbye change filtering
i've just rewritten my last Entities.ForEach because there was a ref touching a TargetEntity comp.
and having the peace of mind of proper version filtering is golden ๐
oh, ForEach lamba is so terrible
even Rider has problems with that, kek
IDE just gets stuck if when it opens argument list for it
https://github.com/Unity-Technologies/DOTS-training-samples/blob/dots-training-2022-05-na-group1-Buckets!/Ported/BucketBrigade/Assets/Scripts/Systems/BucketMovingSystem.cs
I dont know if this is any better on actual runtime performance. Sure, it allows for lambda-like implementation inside a bursted struct system but the ToComponentDataArray calls every frame? How is that better than a ComponentHandle?
would love to have some better API
Ha. I had to disable that as it lagged my computer if I tried typing in a foreach lambda with it on
Wait no, these are entity relationship modifiers. So component handles are all rolled into an IAspect but these are basically ComponentDataFromEntity I think.
It is odd but I'm getting the impression that Unity will be shifting entirely to bursted ISystems. Which is good.
potentially it just gets fancy pointer
bursted creation and bursted access so probably
But huh, where's the scheduling?
are these all mainthreaded? If so, ewww
i have never seen a simd implementation in their training samples ๐
why have a fancy SoA and then not use it ...
Burst is magical enough that even the most newbie of coders can just slap a [BurstCompile] on their job and it'll work
hrmmmm
It seems like if you want any sort of threading done to the job, it must be done though a lambda ForEach
Mainthread .WithBurst() and .Run() can be done though built in C# foreach and SystemAPI.Query<Aspect>
but they mentioned that this is more for engines and etc
not for high level code
that ToComponentDataArray usage is pretty gross
It's probably just a bursted access to ComponentDataFromEntity, I think... actually probably not
didn't someone mention that Burst creates it's own simd?
well, great. that high level code runs worse because of it ๐ AoS would be much better then
in compatibles loops
You can use the assembly calls or let burst do it for you?
that kind of code and data access is never compatible for simd
i mean, that's what burst is
the ToComponentDataArray is probably better for burst as it aligns data from a query of discontinuous entities into a single array to iterate though
there's probably a cross over point from using ComponentDataFromEntity to creating and populating a component data array depending on how many being queried
ToComponentDataArray builds a collection of structs. they turn int* to type T, as they are not using ref i think it initiates a copy
That's returning a managed array. Is there one that returns a NativeArray?
Because that code was in a bursted OnUpdate()
ah yes, give me a sec
can't post the whole thing
i have no idea why anyone would do that.
hrm, readonly copy. Well, if you want that
maybe it's better for non-linear access?
Merging chunks maybe?
You can not run simd commands over pointers, this pulls the data out of the pointer and aligns them into one native array
kind of interesting which would be faster. i mean, copying all comps is pretty huge. i don't think it's worth it in the end
random access is slow but not that slow to compensate with a write
Possibly over many many entities and if you're running a lot of simd commands over the same data set
because you also need to mem copy it back if you want that data to be applied
when you are having non-linear access simd won't work
if you know how the access is patterned, you can sort it so the access is linear?
and then unsort it, and then mem-copy it back
yea, it's very roundabout but there is possibly a very small niche where it's faster than direct pointer access
i have tried these kind of things. sorting is really slow. the code you posted, i don't see any random access.
these are also training samples, not hyper optimized for burst simd
so it seems to revolve around this bucket. makes sense with that implementation to not have it run parallel.
and it runs on these buckets. not on actual chunks
i dunno, i'm not investing too much brain power into this problem. i'm just pretty sure that this is not a good solution
doesn't use ecs or jobs
ecs data would be better off in a simple nativeList
instead of this whole copying per frame ...
It's an implementation of a GO project in DOTS. Not the most efficient, just that it's possible.
and im sure even with this non-optimal project format, it provides better performance
which is why they use these projects instead of rotating 1000 cubes
i'd bet the go project without copying a massive of data around is faster. there's really not much burst can do here
it can't magically make a chain of conditions faster
that's where you're wrong kiddo. Burst is love. Burst is life. (jk). Yea, maybe not a lot of data?
you are leaving out il2cpp :)
when i have learned one thing. writing data in memory is baaad
and per frame allocating is even worse
you'd have to make up alot for it with burst to compensate that
@rustic rain Yea, 2D Entities (the sprite renderer converter) works out of the box. Kinda. Gotta edit the assembly definition files to whatever the editor complains about but otherwise works.
The conversion must be done in a subscene though, not through the convert and destroy script sadly
you mean you just imported sources from github?
since DOts by itself sprite renderer conversion is just doing GO clones
I just imported the package, copied it to local, fixed the assembly refs, then ran it. Works.
com.unity.2d.entities
Interesting
I wouldn't think that experimental sprite renderer static cache is valid
kek
still exists in 2021. Also 2022. So gotta love codebase bloat and debt.
yea, all the functions work
Translation applies, color applies, dont use masks so no clue on that
it's for hierarchy. if you don't use one. remove translation, rotation, etc...
LTW has accessors for all these
it's like interface to work with
translation is like local position
you don't always want to work in absolute one
Local to world isnt the absolute position though? Translation is the bottom 3 values of a L2W matrix
what I don't understand - why have 3 different types of scale
it's copied direct to it.
LTW is absolute
Ah, parenting and inheritance
forgot, i have no hierarchy so that doesnt come into play
I have never seen uniform scale used. Even if the scale is uniform across all axis
yeah, but sometimes...
and what's the third scaling?
and then you sit for hour figuring out why it's not working
composite
this one applies automatically with physics
no idea why
what is that, oh.
no idea what for
but it exists
and I hate it
would rather just have non uniform one
I've only seen the default authoring use Non Uniform Scale. Even with uniform scaling. So I just shrug.
Well no, if scaling is 1, 1, 1, then scaling doesnt exist
yeah
if (transform.localScale != Vector3.one)
DstEntityManager.AddComponentData(entity, new NonUniformScale { Value = transform.localScale });```
Doesnt even check if it is uniform
hasNonUniformScale ? float4x4.Scale(chunkNonUniformScales[i].Value) : (hasScale ? float4x4.Scale(new float3(chunkScales[i].Value))
Well scale just translates into a float3 anyways
you're just saving 8 bytes by using scale over non uniform scale
yeah, it is kind of important, hehe
more entities to put into chunk - more CPU cache utilisation
doesn't matter what happens on execution stack
what matters is amount of entities in chunk
If you're worried about chunk utilization and packing, you wouldnt use any of these interfaces anyways. Just write straight to the L2W
nope
that makes quite a lot of things... single threaded
due to way too many dependencies on l2w
huh?
implement your own L2W and pass it to shaders via compute buffer manually
let's say you have 10 systems that depend on l2w
all will be chained in dependency
and only read access will be parallel
turn off safety, manually dependency
true performance comes with sacrifices in sanity
@rustic rain that makes no sense. if you need to write 10 times to localtoworld you also need to write 10 times to transform if youd use that. you would chain it exactly the same way
not really
Manually implemented L2W
you might need to write to scale, to rotation and translation in l2w
meanwhile doing it seprately can be paralle
I get why rotation is an interface though. Separating it from scale and then re-applying it is pain.
when 10 systems write to the same ltws you have a problem anyway. i'm also not understanding how t/r/s would make anything different really
because this way
you will write to separate components
and then TRS system will combine it into LTW in one go
why not write to the actual data instead?
you will have lower cache utilisation overall if you only used l2w cause if you write to position youd also get the rotation data to cache
If you have 1 system writing to the translation element and 9 systems modifying the rotation, that 1 system can be done in parallel with the 9
because if you only need to change rotation in ltw, you are blocking whole ltw
while scale/translation systems wait
And yea, cache utilization inside the CPU as well. L2W is beefy.
well, that's true but it's reeeeeally weird
that's just sacrifice for better good
data duplication for faster access pattern is not weird
its even mentioned in the best practice guide for dots IIRC
yeah, I want to make my UI interface with it
Denormalization. Always a tricky thing to balance
this is not just data duplication. it's the premise that x systems write to one comp. that's just bad
DOTS UI? Good luck.
for every UI elements visual element create entity with set of components
and let's say you have label
in which you need to write float
you'll have component with float field
every time you write to it
i dont see that as bad at all.
UI Elements really need a native array and job access. But I'm pretty sure it's near entirely a compute shader
it triggers other system that will write to managed text field
kind of like ECB
kek
when x systems overwrite something constantly? why write at all?
this way you can change UI in bursted systems
i can't even think of a proper use case tbh
additive changes. like forces in phsics. translations can be additive too.
then you have a clear sequence of dependencies
i wrote whole character controllers with additive movement for modularity
so in this rotation example, you could use ltw instead
yes order might matter. not in all cases. you could always use l2w instead of the other 3 components. makes it slower and more complicated though
_selectionQuery = GetEntityQuery(typeof(SelectedTag));
_selectionQuery.SetChangedVersionFilter(ComponentType.ReadOnly<SelectedTag>());
RequireForUpdate(_selectionQuery);
Any idea if that is achievable?
yes why not?
so far it's not working
it updates every frame
no matter whether there were any changes to selectedTag
(it's not actually tag)
hmm i guess the problem is that the query has to be checked at that point in time where the system has to run. so the system starts running , the filter is checked and the system continues running.
i really hope that will be improved in the future
if (!_selectionQuery.IsEmpty)
I'll try this
that works
well
yeah, I guess that UI entity idea should be good
having burstable interface for UI
should be pog
UI Elements is suppose to interface with DOTS
was suppose to at least
But then development hell happened and that was striked off the roadmap for the forseeable future
UI Elements is really really good. 1 draw call for static elements and 1 more draw call for dynamic elements. Absolutely amazing.
that should not even be that hard to implement
yea, i dont know why, just give us pointer access to the compute buffers used to feed the ui rendering system
we'll make it work from there
yea, you're implementation will probably be along the lines of UGUI. Which is ewww but I doubt any actual development is going into that anymore.
UGUI is element based. You can attach events to every specific element of the UI interface that trigger if only that specific element is interacted with
The downside is that each element requires a draw call per, IIRC. And data is uploaded to the GPU per element as well.
I don't really see any of that is relevant to UI elements
UIElements is flattened. Data is uploaded to the GPU all at once in a single buffer. It uses a single shader for every single element. It renders in a single indirect draw call.
and unmanaged interface I want for it
The point is, I dont think it's formatted the way you want for systems to be triggered if a specific UI box or text input is interacted with.
but that's how it is?
If you want to change label text, you change this label's text, kek
ooh
nothing about events
just
just interface to change values in VEs
in unmanaged world
you change struct's field, this field is then copied to Text's value property
events can be made unmanaged too btw
but that requires structural changes
They'll need to expose the compute buffer data used and the relationship values to connect indices of that buffer to UI elements.
you simply create entities during callbacks with some settings for event component
or assign data to precreated entities
I have a list of static entities that are created on world creation
eh, too low level
I'd say it's already fast enough
Any higher level and you'll need to go through the existing API. That's basically what it's doing.
so you don't really want to struggle with compute buffers just to make 0.01ms overhead lower
xD
Compute buffers arent hard to understand. It's a native array.
They are simply not convinient to work with
going that way, binary is also not hard to understand if you know what I mean xD
If you want unmanaged access in a job and bursted, you must work with compute buffers. There's even a write as nativearray method to it for modification in a bursted job
yeah, but this is unsafe access
unless they actually implement some dependencies along
duplicated data components is the way, imo
you can even do queries this way
Im sure they were planning that until DOTS stumbled
I also favour component interface idea
because you can simply do language change with it, kek
just query over all entities
and switch all strings from one language to another
Did they skip 2022.3 LTS?
i think they're sticking to a bi yearly stable release
i guess that removes one entire team spent on maintaining a branch
Does Unity support any sort of foldering for hierarchy debugger besides SubScene and Parenting?
That was actually a feature Unity is planning for... years now.
๐ด
There are both paid and free assets that do that. But nothing built in
I meant for entities
Oh, yea no. I dont even think there are paid versions
simply due to how subscene conversion works. It'll need to slip in before editor conversion and delete itself
but here we go
How about multiple subscenes then? Nested subscenes?
I need to create entities during runtime
#if UNITY_EDITOR
EntityManager.SetFolder("PlayerScene");
#endif
tbh
considering Editor's UI is UI elements, kek
I think it's possible to just modify it
to work with it
var parentUIEntity = EntityManager.CreateEntity(typeof(LocalToWorld));
EntityManager.SetName(parentUIEntity, "UI");
var uiFolder = new Parent { Value = parentUIEntity };
foreach (var system in systems)
{
var systemFolder = EntityManager.CreateEntity(typeof(LocalToWorld), typeof(Parent));
EntityManager.SetName(systemFolder, system.Root.name);
EntityManager.SetComponentData(systemFolder, uiFolder);
var localFolder = new Parent { Value = systemFolder };
foreach (var ve in GetAllRecursively(system.Root))
{
if (!string.IsNullOrEmpty(ve.name))
{
var uiEntity = EntityManager.CreateEntity(typeof(Parent),
typeof(LocalToParent),
typeof(LocalToWorld));
EntityManager.SetName(uiEntity, ve.name);
EntityManager.SetComponentData(uiEntity, localFolder);
}
}
}
With this disgusting code you can achieve this
and then you destroy any sort of parallel transform application due to nested local to parent values
this is only for editor
during runtime none of this is required
but performance profiling in editor?
i will die if I had to build every time I tried profiling a small change
it's not really the kind of application for profiling
but big fps gooder
the whole point is that you interface for bursted code
but that's still singletons mostly
which will probably be accessed by EntityManager
not chunk iteration
After using subscenes for a while now, it's actually not that bad
is anyone using Latios framework?
The LTS version always comes after the next year alpha/beta version, usually around may
so 1.0 is due around may next year??
Last I heard a preview end of this year, full release sometime after lts (~may)
thanks
or at least checked it out ๐
Wow, that is buried. Why is that not in DOTS forums? Where's my daily drama in the replies?
Seems like a great addon to DOTS
Dont use it myself. 2d game
yeah seems like it, and that's why i'm looking for more info about
with the recent animation addition it seems like a must
The docs are fairly robust. and it's open source
if i'd build an actual game I'd use it
audio and animation is nice. rest is, i dunno
physics seems nice, especially when you don't want any actual physics simulation
like i.e. collisions and raycasts only
Personally I'd never use it, I think it's going to cause some nightmares in 1.0
Unless you have no plans of updating anytime soon
yep, that could turn out somewhat annoying
as every custom package tbh
man, what i'd give for a dark skin in unity forum
Well yeah why I avoid them but this more so since it has a very heavily modified hybrid renderer
And I expect hr to be vastly different in 2022
did you know the light skin is actually better for your eyes? ๐
I just dark mode everything
@rustic rain Wow, hybrid sprite renderer performance is hot garbage
i don't believe that! ๐
I didn't expect any other way tbh
I believe it's actually true, less strain to read though don't quote me
even collecting of data is not bursted
in my private project I just dumped HR at all
how many sprites do you have?
So what part of latios appeals to you then?
just 500.
animations, I have my own painfully simple implementation of it that needs a lot of more work
I think I would like to delegate this task ๐ and make actual game
i'm interested what makes it take so long.
just use GOs for animations and keep your sanity
@hot basin have you tried if animations from latios works inside of subscenes? because audio doesnt unfortunately
it's project Tiny's sprite renderer
But the animation requires HR
I didn't try it at all besides clicking few samples ๐
hybrid renderer, uses shared components which is why it's not bursted and mainthreaded
Not in 1.0!
Yea, which will be amazing.
ive tried it, played around with it. Works as advertised
you mean in case of Latios Framework? If someone ale writing animations for me I don't care if HR is present or not
You might if you can't update to 1.0 because of it?
I'm sure dreaming will update the library he's been good at maintaining
But I think it's going to be a lot of work
Thats it, im building my own sprite renderer from manual draw calls
I think you can use HR, just use quads with UV override for different sprites in the atlas
yeah, that's the point
but instead of using actual HR
hold on
that is actually pretty interesting approach
hehe
I wrote it to you few days back ๐ when you have worked on your own project BTW ๐
you go to the API, construct a DrawMeshInstancedProcedural shader with it. Dont quite know how to structure the texture lookups though
it would be similiar
his suggestion just to pass suitable data to HR
which is actually good ngl
but you will need to manually update Buffer in the material with correct UVs
Nah. I refuse to download HR
lul
I will do this manually, to get it done properly
HR does it properly
I wonder if anyone actually falls for those <@&502884371011731486> ^^
does it, does it really?
it's same as my animation rebnderer but I have static buffers with animation data and update current frame ๐
I had no issue with it
how's the performance with 500 sprites?
I do a quad plaster screenside for my light rendering. So it's not difficult to retool it again for sprite rendering and then sample a texture for the sprite (i think)
this is thousand of capsules + spheres
meanwhile each has it's own personal draw call for movement line
(my bad with it, kek)
turned it off
oh no, bad bad. get it GPU instanced either procedural if you know how many lines you're drawing or compute it indirectly
this is HR sir
oof, 5ms. thats bad. You can probably get it down to 0.05ms if you do it in one draw call
that's why Kraja's suggestion is actually great
it's 5ms with all game logic
not just drawing
kek
no no, the difference between the two with movement lines on each
here HR profiled
yea, that seems... reasonable.
I'll fix it as some point
rn I'm just lazy
and have other things to attend to
but sprite renderer is a completely different API from 3d. Does it still work? Or does a form of it need to be implemented through HR?
you don't get it, sir
you literally just convert sprite renderer into RenderMesh
you do it by creating special Quad for unique sprites
but you dont need a special quad per sprite. 1 should be enough for everything
you just rewrite uv for vertices and that's it
yeah, but HR does not work with MPB
the whole point is to just pass all the work to HR
so you don't have to care about culling and etc
all done by HR
it doesn't necessarily means unique quad per sprite
though
it just means that every unique uv will be unique quad
if all you need is 500 sprites I'd say F the culling ๐
Graphics Draw calls are fulcrum culled though. I believe that's GPU side.
yeah, but you still make that call
you still calculate draw data
you still do CPU bound work
while HR culling system does a quick bursted check for that
ideally 1 call for all sprites, no matter the number, 5 or 50,000 sprites all in 1 call.
1 call per atlas
i was thinking maybe a Texture2DArray so all atlases are uploaded. Or a compute shader filtering used atlases
Nah, Graphics procedural or indirect are not bound by batch number
I know that for certain, spent a few long hours converting it from instanced to procedural.
wait does the hybrid renderer finally support sprites?
used to, not anymore
ofc not
probably will with 1.0, maybe
we just discuss how we can fix it manually
I was looking into that so I nudge into this conversation if you don't mind.
I was semi confused because of this https://docs.unity3d.com/Packages/com.unity.rendering.hybrid@0.51/manual/hybrid-entities.html
still, I think a manual draw procedural will be better than using hybrid renderer if it splits draw calls per atlas
oh, that lies. Used to back in the 0.17 days but it was cut.
it creates GO clone
currently
which... sucks
There's the sorta conversion that hooks into old Tiny API that im using. But performance is very very very bad.
I was pondering to use gameobjects or a tile renderer to just render the stuff and do all logic on the ECS side
I mean, it works, but it's bad. I might just stick with it as a temporary solution until 1.0 comes out
using tilemaps? I just stuck with the GO.
Given the pace we had I do not expect it before mid next year at the earliest
I do 2d turn based stuff so tilemaps make sense
Think turn based rimworld and you have my usecase
Suppose to drop with 2022.2 beta later in it's life. But probably 2022.2 full release or even 2022.3 LTS
I mean the 2021 LTS was when march this year or so?
Tilemaps come with rule tiles which is why I'm sticking with it.
As said my main reason for wanting dots is less the performance side of things and more of not having to deal with the messy way unity handles references
Data oriented design clicks far better with me.
For now, I'm sticking with a fixed up version of https://github.com/needle-mirror/com.unity.2d.entities. Performance is very bad but it functions for now and that's all I really care about.
define "very bad"
ok for small amount of entities
Regular GO renders 500 circle sprites in 0.03 ms. That renders in 1.0 ms. So about 50x slower ish.
tiny was only ever meant for running mainthread code
On the note of dots or unity in general I read that a major reason why dots had such a rocky development was that internally they were pushing and pulling in different directions.
Explains a lot of the half baked features we got in recent years.
they were too optimistic with the timeline. 0.50 cut a lot from the promised feature list to get shipped and even then, it barely functions.
The key feature, the entities debugging UI is bugged in 2021. Selected entities arent highlighted.
The other half, code-gen works well enough. Need to hard restart the editor (deleting cache between restarts) if too many changes are done between code compiles and it dies.
0.50 is rough but im glad it's here and dots isnt completely dead, just scaled back a fuck ton
just use 1.7.3 burst
this is fixed with it
kek
not a burst issue, it's a code gen of the C# that occasionally stalls.
there's also that burst issue as well but it's fixed in 1.7.3 at leastr
Wait so an interop issue between the c# and the c++ side of it?
nah, code gen is the same as the wider C# .NET code generation.
there are no issues besides too much waiting, kek
Just unity's implementation is not quite robust enough for wider production use. Hence preview packages
And with a lot of it, it gets pretty slow. I think the 1.0 IAspect is suppose to help on that front
I think aspects are for usability not speed
Maybe both?
would love it if there were some speedup but not getting my hopes up
Checking the current usage of them in the unity training branch shows that it looks to allow for the simplification of foreach on main thread to use c#'s built in foreach() while also burst capable.
Job'ed for each aspects still had to go through lambdas though which is hrm.
Isn't that just the new entities foreach?
The usage was foreach(var entity in SystemAPI.Query<Aspect>()){} on the main thread. Burst the entire OnUpdate() to burst execute the foreach.
Hmm yeah that's the be entities foreach syntax
Not sure how it integrates with aspects
Aspects define the query and component access to whatever entity is matched.
I noticed they have a new bakers api for conversion
Just looks like a rename of IConvertGameObjectToEntity (which is pretty long)
I don't think so
I think it's a replacement for conversion system
Or a mix
Because you notice the bakers point to an underlying monobehaviour authoring script
// Bakers convert authoring MonoBehaviours into entities and components. class CannonBallBaker : Baker<CannonBallAuthoring> { public override void Bake(CannonBallAuthoring authoring) { AddComponent<CannonBall>(); } } ```
Ok code doesn't copy on my phone
It seems to bring in SystemBase's implicit methods that map to entity manager API
So yeah I guess it's kind of an interface replacement but needing an extra class
I guess separation of data and logic
I really hope they retain [GenerateAuthoringComponent] because writing a bake and a monobehavior for every component type that will be converted will be absolute pain
I dont see any of these training samples using it though which gives me a bit of concern
They seem to have got rid of the old conversion system
So maybe component system is finally gone
Need to see system group
You just use ISystem etc for conversion now
[WorldSystemFilter(WorldSystemFilterFlags.BakingSystem)]
the funny thing is that Unreal in UE5 has an experimental version of an ECS as well.
It uses a different nomenclature but its for all intents and purposes a fully features ECS
Which I hope lights a fire under Unitys butt.
how are we qualifying "ships"
Do you want salt, sugar or a condiment?
Unreals turnaround time from experimental to production is generally less then a year.
So there is a decently high chance of that happening.
var ecb = ecbSingleton.CreateCommandBuffer(state.WorldUnmanaged);```
missed this, new singleton API and how command buffers may work in ISystem
Better than the current version of finding and attaching it to a system
.WithAll<Turret>()
.ForEach((TransformAspect transform, in Turret turret) =>
{```
old api still seems to exist
and seems to handle TransformAspects as well
(also good to confirm TransformAspect exists as I was under the impression transform operations was one of the primary uses of aspects)
Yea, the old API is currently the only way to have threaded jobs accessing entity values. The foreach is for mainthreaded. So no need for .Run() anymore.
from what i understand this should not be the case come actual release
but yeah looks that way atm
hopefully but I have no clue how they're gonna do that
for 1.0 we've developed an alternative to EFE that requires several times less work from the sourcegenerators (which are both what slows down VS and also one of the many sources of bad iteration time in the unity editor). It unfortunately does require y'all (and also us) to convert manually, though. :/
Is it the Query syntax that was shown off at GDC for ISystem?
It's that plus some variations to use Aspects, plus some other improvements to SystemAPI, ish. I'm probably forgetting some, er, aspect.
was discussion about it i had on forum
i assume you probably just call ScheduleParallel() or something in the SystemAPI
its all code gen anyway
Noooooooooooooooooooooooooooo, manual conversion
good thing I have like no EFE
efe?
entities foreach
or yeet it over to IJE
ah, not the GO to Entity conversion, but converting the lambdas
that's fine. I can live with that. I can not live with writing out the monobehavior and the baker for every single component
i actually have no issue with that
i use generate authoring pretty rarely
most of my authoring handles half a dozen+ components at once
otherwise i end up with 12345 components per gameobject
yea, but im lazy
and it becomes unmanageable
you could probably setup a template in your ide to generate this nearly as fast
i made a template for ISystem recently, holy hell saves me so much time
generates the job, 2 type handles with updates, schedules everything, starts iterating in the job, sets up change filtering etc
I should be converting everything to ISystem shouldnt I....
writes a good 90 lines of code for me
you know they will
yea, which is why i'm prepping my condiments
hope it's a healthy hat
a nice, flavorful hat.
unity has been waffling about with dots for nearly 6 years now. 2016 was when we first heard of it right?
i think 2018. 2019 was the first release.
unreals data layout looks very similar
news might have been much sooner
what was that rust ecs thing again? i forgot the name
bevvy might have a v too much
i started using it like ~may 2018
oh boy looking at some really really old repos of mine (19 Jul 2018)
[Inject] private ReactiveUpdateBarrier _barrier;
back in the days of injecting
i dont even know what i was trying to do here
yeah mid 2018 must be it
That is hardly a surprise. Especially in a c++ context you can natively reap the benefit of heavily minimized cache misses, and far easier at that.
that's kind of a given with SoA layout
everything else has just as many cache misses
it's interesting because as far as i can tell it infringes unitys archetype style storage of chunks patent
How would they patent something that existed already since 1965?
ECS is not new, its just new in games.
they didn't patent ECS
they patented a very specific implementation of chunk/archetype mapping
what exists since 1965?
ecs as a way of structuring code was first popularized in 1965
Some random redditors summary of the patent if you cbf reading it
10-18 are related to archetype-style storage of chunks as allocated in memory as [ A1 A2 A3 B1 B2 B3 C1 C2 C3 ]
19-20 are related to non-transitory storage of instructions that facilitate 1-18. I interpret this to be "the software program".```
Bevy ECS does not store memory in chunks using either of those two memory layouts.
(there was a big concern at the time this would affect bevy)
that patent is pretty ass tbh
Ok I am semi confused with the whole sprite thing and entity conversion. When I use convert to entity it does create an entity with a sprite component but still has a gameobject clone?
what was your expectation?
Its less about my expectation and more me being interested why its doing it this way.
because it's one of the supported Companion Components
that's about the extent of support in hbv2
I was thinking of trying to fudge it using quads
Also my expectation fyi was to it simply not work at all which was the case in 0.17
It would just omit things it could not convert
I am semi confused I am doing EntityManager entityManager = new EntityManager(); Entity entity = entityManager.CreateEntity(); Which returns me a null reference error which I do no get what the heck is happening there since its literally just supposed to create an empty entity.
EntityManager entityManager = new EntityManager();
ah you should never do this
How else should I access entities. Is there now one global entity manager or something like that?
each world has an entitymanager
Sheesh the documentation is still totally sparse.
A lot of stuff for conversion but nothing of what you just mentioned.
served with a side of sparsely
And it does not help that tutorials are totally fractured and also mostly focused on conversaion bs that I do not care about.
that's weird, i always thought the documentation for conversion was basically non-existent
https://docs.unity3d.com/Packages/com.unity.entities@0.51/manual/conversion.html#conversion-systems-101 literally the first three big points there are all just conversion stuff
And no API documentation it seems?
yeah
you've already skipped the entire documentation
you're like at the end of the tutorial
there's a lot to cover before you get to conversion
stop ignoring conversion and you will save yourself a lot of headache adjusting
(that to)
huh?
i feel like everyone who starts on entities for some reason just hates on conversion and then has hell for months
I do not care about conversion because my game is literally only data and a bit of frontend displaying.
I am making a roguelike which is bascally 95% dynamic data and 5% ui
Why?
just going around in circles but just learn up about it, and then selectively ignore it where it makes sense, but it sounds like you are trying to run before you can walk
I have worked with .17 but nowhere in that documentation is there any mention of specific changes so where the heck should I have known that this is no longer the case?
nearly anywhere in your code that has
entityManager.CreateEntity()
should be done via setting up prefabs in conversion
Again prefabs are useless if I dynamically compose
I am not making some platformer with a neat player character.
The whole reason I want ECS is that I can dynamically compose
nowhere in 0.17 or previous versions was EntityManager entityManager = new EntityManager(); ever a thing, so really just take the time to read the docs. anyway changes can be found in the changelog
in that changelog the only time entitymanager is mentioned is in 0.16 nothing there indicates a change on how entitymanger is supposed to be acessed at all.
it was always accessed via world. wdym?
The syntax for that has at least changed thrice now if its something new again.
uhm, no
the first line in the ecs concepts in the manual for worlds
https://docs.unity3d.com/Packages/com.unity.entities@0.51/manual/world.html
A World organizes entities into isolated groups. A world owns both an EntityManager and a set of Systems.
World.Default(something).EntityManager for the default world
took me a few months of back and forth and I finally agree with you
what the
even full reimport didn't help
ok, full library removeal helped
some internal bug I guess
what version of burst and did your unity crash/incorrectly close recently?
Is there any way to have bursted OnUpdate in managed System?
it did crash before that bug, version is 1.7.3
yeah i noticed if unity crashes at very specific times it can still corrupt burst cache
just clearing that should fix it
you can create a function pointer and just call that
uugh
I guess I'll try that
if amount of work will be big enough
it's mostly EntityManager calls
getdata, writedata
hasComponent
and etc
what do you mean by that?
for ISystem to run, I need async assets loaded
but they loaded only after OnCreate is called
isn't that what RequireForUpdate is for?
it is, but I still need to grab data
Like entitiy
and I end up with inability to assign it
since there is no OnStartRunning that can be managed
how can I get one?
implement ISystemStartStop
/// Optional interface for start/stop notifications on systems.
/// </summary>
internal interface ISystemStartStop
{
void OnStartRunning(ref SystemState state);
void OnStopRunning(ref SystemState state);
}```
public struct MySystem : ISystem, ISystemStartStop
ah, too bad I scrapped it all already
I might reimplement it later, for now I have another task on my head
I want to make a selection tool
similiar to Editor's inspector
that will show all relevant data in text fields
and I'm not sure how can I grab that data without hardcoding anything
I kind of consider having special interface for components that will enforce to implement ToString override
but maybe there's a better way?
if you were just comparing to null should be pretty fast
would terminate first iteration
bbbruuuuuh
I swear
Entities really need a special phase
PostCreate
where all systems can get a chance to get static references
kind of goes against the whole ecs philosophy
is there a way I can do it manually?
not really
this is 100% ECS
I just want to call GetSingletonEntity in some kind of PostCreate
you said the word static therefore i'm doubtful
oh singleton entity
ok now i'm confused what you're trying to do
yeah, per world
in short
I decided to apply full Data approach
and now implementing simple input
mouse click
every time mouse is clicked on UI screen
before SimulationGroup data of click position is written to component
on same InputEntity
which gets created by that system
so I jsut want my other ISystem to get that Entity
because it'll last until World is destroyed
it's not burst compatible
public void OnCreate(ref SystemState state)
{
state.RequireSingletonForUpdate<GalaxyLoaded>();
state.RequireSingletonForUpdate<PlayerTag>();
state.RequireSingletonForUpdate<MouseEvent<Space, Up>>();
}
it looks like this
hmm that's unfortunate
though you can use query.GetSingleton
to basically do the same thing
MouseEvent<Space,Up> will get removed in Presentation phase
also not compatible
is there a way
I can manually do a call?
with ref SystemState?
I already have similiar implementation
with managed systems
but ISystems is smth I can't easily access it seems
or can I?
hmmm
maybe I can
But I don't want that just for one
I want to have for example an inferface
Can I somehow query over all?
a little confused what you're asking
I want World.Systems for ISystems
for (int i = 0; i < allUnmanaged.Length; ++i)
{
list.Add((SystemState*)allUnmanaged[i]);
}```
are you wanting to iterate over all unmanaged systems? if so i literally wrote this code 15min ago
(you need internal access)
i'm writing a system to automatically detect bad change filters i.e. they are being triggered much more frequently than you expect
so i need to record every systems version hence i needed to iterate them all
somewhat of a coincidence since i just dug into code to figure this out
I'm not very familiar with casting pointers
Could you tip me how can I do interface check?
smth like
allUnmanaged[i] is just an IntPtr
allUnmanaged[i] is IPostCreateCallback callback
oh yeah you can't do that
this isn't the actual system
hmm
so yeah not exactly what you want
i believe UnmanagedWorld._unmanagedSlotByTypeHash
contains all the systems
but it's stored as ulong, ushort ^_^'
internal SystemRef<T> GetExistingUnmanagedSystem<T>() where T : unmanaged, ISystem
{
if (_unmanagedSlotByTypeHash.TryGetFirstValue(BurstRuntime.GetHashCode64<T>(), out ushort handle, out _))
{
var block = _stateMemory.GetBlock(handle, out var subIndex);
var sysHandle = new SystemHandle<T>(handle, block->Version[subIndex], (uint) SequenceNumber);
void* ptr = (void*)(IntPtr)block->SystemPointer[subIndex];
return new SystemRef<T>(ptr, sysHandle);
}
FailBecauseSystemDoesNotExist();
return default;
}