#archived-dots

1 messages · Page 278 of 1

rustic rain
#

and also those components you want

#

super slow

#

but works

#

at least I hope xD

frosty siren
#

while it happens only once at start, meh, i'm ready to this tradeoff

rustic rain
#

it happens only in Editor

#

client gets already serialized subscene

frosty siren
#

in perfect project - yes, conversion happens only in editor

rustic rain
#

ahem

#

you don't use subscenes?

frosty siren
#

I've tried

rustic rain
#

what made you stop?

#

maybe I can convince you back xD

robust scaffold
#

subscenes are meh

frosty siren
#

there was some issues i've found on forum which have no simple soultion. Some stuff just doesn't work correctly, i don't remember what in particular, because it was pretty long time ago. But i have hope that 0.50+ will solve my problems. Also i can't 100% avoid conversion, because i use some hybrid things + addressables to be able to load presentation layer, but i saw some kind of streaming entity prefabs, so that also can solve this part

rustic rain
#

welp, idk what exactly you don't like

#

but so far entities work perfectly for me

#

with all hybrid

#

I mean subscenes

frosty siren
#

didn't say i don't like something 🙂

robust scaffold
#

subscenes lead to sorta fucky things with custom rendering pipelines

#

beyond the usual fucky things with SRP

rustic rain
#

welp, can't argue with that

#

never tried custom rp

#

but with URP it's all good for me

frosty siren
#

the idea of having serialised entity data is obviously a need. But all this live link stuff, i guess, ruins ux

rustic rain
#

I'd say, they are quite simple to use for the most basic stuff
They are hard to figure out once you need more complex stuff
and they are just godsend once you realise how they work, as they offer so much custom options

#

I personally use a lot of subscenes for different states of game/layers of objects

#

1 for player related entities
2 for background (which is reused in main menu)
3 for custom objects for new game

robust scaffold
#

well it works in URP 2D renderer

#

Now i gotta figure out how to set the render target to not be the camera

solemn hollow
#

@robust scaffold dont u have to render to cameras everytime? but u can set the cameraoutput to texture instead of screen

robust scaffold
#

wait, but this brg doesnt target a camera?

solemn hollow
#

no idea how that works sry

frosty siren
#

Is it ok that inherited system class doesn't automatically created?

solemn hollow
#

a system that has generic arguments is not added automatically. but i think if you had a system that has no generic arguments but inherits from one that does it is still automatically added to defaultgameinjectionworld

#

just now i debugged an error produced by this

frosty siren
#

i have no generic arguments, just inheritance

robust scaffold
#

DOTS doesnt really do inheritance

solemn hollow
#

it does for systems

solemn hollow
frosty siren
#

yep, but this is conversion system

solemn hollow
frosty siren
#

i don't know how to add them manually

solemn hollow
#

awkward

robust scaffold
#

been a long time since I added a system but it's very simple

frosty siren
#

i see how to create a world from scratch and i have my custom utility to do this, but how to initialize conversion world

solemn hollow
#

i mean you get a reference to the conversionworld via entitymanager of conversionworld. cant you get the playerloop of the conversionworld then?

rotund token
#

Can we step back

#

Why is your system not being added to conversion world when it's not generic?

#

Do you have an attribute on it?

robust scaffold
#

Alright, BRG is outputting to a render texture through a camera which is iffy

solemn hollow
#

well atleast consistent with the rest of urp

#

@rotund token the codegen to get my generic systems to burstcompile in 1.7.2 worked. i still hate it though

#

did u guys also see alot of editor speed improvements when updating to 2021?

#

like night and day for me. but alot of it could be the native support of apple silicon

#

so im wondering how it was for windows users

misty wedge
#

Is it intended that entities 0.51 tries to convert stuff like constants to authoring code?

#

That seems incorrect to me

#

It seems to be completely ignoring any modifiers, for example it will also attempt to set private variables

safe lintel
devout prairie
#

damnit conversion system is just such a pain

#

feel like i'm having to jump through hoop after hoop

#

can't do this, can't do that, oh this component doesn't exist yet, but this one does, etc etc etc

robust scaffold
#

just convert it manually with an OnStart?

devout prairie
robust scaffold
solemn hollow
#

also there is declaredependency()

devout prairie
#

so for example i've used:

#

to grab the linked entity group from the converted object

#

but apparently, it doesn't exist yet

solemn hollow
#

linked entity group only fully exists right at the end of conversion. you wont be able to rely on that at all while conversion is ongoing.

#

pretty special case too

#

also reading from the dstManager while conversion is still ongoing might be a bad pattern. you read from a half finished destinationworld.

#

as long as you dont guarantee yourself that a conversion has fully run by ordering systems etc. i would not read from dstWorld

devout prairie
#

yeah i thought maybe the rest of the conversion process would have been done, at least for that gameobject, when Convert is called.. rather than calling Convert at some arbitrary point in the process

#

just irritating

#

so i guess i'll have to do some more workaround

solemn hollow
#

atm i had to resort to Systems running in the first frame instead of conversion to set some things up

devout prairie
#

i mean, grabbing linked entity group is already a workaround for another problem ( the fact that GetPrimaryEntity doesn't return the entity produced by joint components )

devout prairie
#

just annoying though.. i mean, make it easy for us Unity damnit, you're halfway there

solemn hollow
#

what do you need to do with the joints?

safe lintel
#

maybe try using a conversionsystem and run it in GameObjectAfterConversionGroup?

solemn hollow
devout prairie
#

what i'm trying to do, is basically set up my Prefab entity, and store it, so i can later instantiate when needed

safe lintel
#

prefab entity automatically created by unity?

devout prairie
#

yeah i'm using DeclareReferencedPrefabs to create and register them

#

which works fine

#

just trying to access the joint entities and do some component/buffer setup on my prefab during conversion is proving to be painful

viral sonnet
solemn hollow
solemn hollow
viral sonnet
#

yep, at least 2020.3 improved somewhat. it was total trash in the first versions

safe lintel
#

not scientific but what do you guys have for your hold on for recompile time? for minor code edits I think mine is between 20 & 30

devout prairie
#

i found 2021 to be quicker, but a friend was having constant 'redraw' or something, which i think was a known problem

solemn hollow
#

still testing 2021 but it seems really fast

devout prairie
#

yeah even on a very basic project, it can get silly

safe lintel
#

I think after a minute or two I assume the editor hangs up and restart it

solemn hollow
#

i did split everything up in assemblies etc...

solemn hollow
#

opening project is 10x faster atleast too now

safe lintel
#

5 mins seems like a huge wait though, is your codebase enormous?

solemn hollow
#

not really

#

im down to 21 sec for a small codechange in my biggest assembly now

#

counted until the editor is responsive again

#

nvm. 21 sec was the slowest time i counted after changes now. 4 sec was the fastest

#

not sure why there is this big disparity despite doing the same change?

safe lintel
#

I wish it always compiled like it was a fresh project

#

4s is pretty amazing though

solemn hollow
#

given its a macbook air even more so. the native editor does alot

devout prairie
#

i always suspected it was related to caching and possibly undo

#

when unity has been open for a while, and you've been working on a project, you might notice it chews up a few gb's of storage

safe lintel
#

thought that was just shitty memory leaks 🙂

devout prairie
#

closing and restarting unity for me generally frees up that storage space again

devout prairie
#

i'm not sure if unity is caching assemblies etc to make things 'quicker', but inadvertantly making it actually slower

solemn hollow
#

anyone else seen this? :

Assets/Scripts/UtilityAI/Core/ActionEntity.cs(1,1): error SGICE003: Seeing this error indicates a bug in the dots compiler. We'd appreciate a bug report (About->Report a Bug...). Thnx! :heart: System.UnauthorizedAccessException: Access to the path .../Temp/GeneratedCode/UtilityAI' is denied.

#

happend more than 5 times now. requires an editor restart to fix

#

Id report a bug if i would know what might be triggering this. but 0 clue atm

safe lintel
#

gotten it too but editor restart fixes it so cant really repro

rotund token
#

This is a common issue @solemn hollow in 0.51 and one of the reasons I warned people against upgrading

#

If you go look at that directory you'll see for some reason it's generated empty files instead of directories

#

If you just delete those files you can save yourself a restart

solemn hollow
#

sounds like new editortooling in the making

rotund token
#

Someone on the forums wrote a script to do it on the refresh keybind

nocturne bear
#

Is possible to get singleton entity from MonoBehaviour? I looking for solution for camera update.

#

Or better is update camera by system?

robust scaffold
#

bog standard movement script in mono Update(), dont try to make it hybrid

rotund token
#

i on the other hand for cameras, have a dots wrapper for cinemachine and use no monobehaviours

nocturne bear
#

Okey but how to find entity to follow?

#

I use for XR and I don't need cinemachine. In general I can use Input System but I need LocalToWorld (parent)

#

I can try spawn camera by system and connect correct EntityManager and Entity

#

But I looking for how to find Entity from MonoBehaviour (to know, it can be useful)

rotund token
#

but if its broken shouldnt be hard to fix, i still use it

nocturne bear
robust scaffold
# nocturne bear Why? I think that I can update camera (as singleton) in presentation update
using UnityEngine;

[RequireComponent(typeof(Rigidbody2D))]
public class Movement : MonoBehaviour
{
    public float speed = 1;

    private Rigidbody2D _rigidbody;

    private void Start()
    {
        _rigidbody = GetComponent<Rigidbody2D>();
    }

    private void FixedUpdate()
    {
        var horizontal = Input.GetAxisRaw("Horizontal");
        var vertical = Input.GetAxisRaw("Vertical");

        _rigidbody.velocity = new Vector2(horizontal, vertical) * speed;
    }
}```
Plop this on a camera and never care about movement again
safe lintel
#

yuck 🙂

rotund token
#

so so gross

solemn hollow
#

why is discord not deleting this? 😉

robust scaffold
rotund token
#

because it has no indents!

#

you just cant post code which is indented

#
    using UnityEngine;

    [RequireComponent(typeof(Rigidbody2D))]
    public class Movement : MonoBehaviour
    {```
#

it would be deleted

safe lintel
#

I think it was a joke 🙂

robust scaffold
#

ugh, i think batch renderer group is a dead end. There's no ability to designate the render texture target of a batch render outside camera texture. While you can set the render layer to be something other than default and then use another camera rendering to a RT, that additional camera costs CPU time and practically invalidates any improvement to using it as an alternative for post processing sequence of renders.

solemn hollow
nocturne bear
rotund token
#

what is this a jokes channel now?! serious discussion only 😠

nocturne bear
#

yes please

robust scaffold
#

especially a post processing stack that generates a lot of intermediate lookup textures. And it's definitely not worth it since culling needs to be done manually

safe lintel
#

speaking of cinemachine, what ever happened to that whole dots cinemachine 100 camera demo they presented ages ago?

rotund token
#

🤷‍♂️ i waited a while then went fuck it, wrap it myself

#

was only a few hours work anyway

#

and it's worked fantastic since

#

just dump camera, brain + cinemachine cameras in subscene, bam converted for you

solemn hollow
#

or maybe they all just wait for tertle to finish the job? 🙂

safe lintel
#

I ported ufps ages ago as my weapon/camera solution and now Im too lazy/entrenched to learn something new on that front, but I probably really should use cinemachine. too many things

solemn hollow
#

honestly if there is one package that feels complete from unity it is cinemachine

nocturne bear
#

I remember as a junior in my first job, I found a bug in Cinemachine package. My leader told me to send pull request with the fix. But it was rejected because it was fixed but not released yet. xD

devout prairie
#

got to 17

nocturne bear
rotund token
#

pretty much

#

during conversion all gameobjects get destroyed as usual but data stored on components

#

and I recreate and manage their lifecycles myself on loading

#

kind of like my own little companion objects

nocturne bear
#

It means that the solution is configuration by ECS System?

rotund token
#

yes everything is run by systems'

nocturne bear
#

But Camera is a GO, y?

rotund token
#

i never write code where monobehaviours can access entities

rotund token
#

which is off by default

nocturne bear
#

CameraConversion? What?

rotund token
#

HYBRID_ENTITIES_CAMERA_CONVERSION

nocturne bear
#

Wow

solemn hollow
#

so do you respawn the object with the camera after conversion or do you keep the camera gameobject around but copy the cinemachine components to entities?

rotund token
#

if you add CMBrain to an entity with a camera, it'll add the CinemachineBrain to the existing gameobject

#

for virtual cameras it'll create its own GO and manage that, just create a CMVirtualCamera component and it'll set everything up

#

destroy the entity, it'll clean it all up for you

#

then just use the entity components how you want and it'll handle syncing states etc

solemn hollow
#

very neat! atm my camera needs are met but ill keep this in mind

#

i wish i could write useful repos to share. im not at the point where i feel confident enough ^^

rotund token
#

i have so many awesome libraries i'd like to share

#

but its like effort

#

the best i can do is just dump some code above and if people care enough they'll look into it and figure it out

solemn hollow
#

big thx for that ❤️

viral sonnet
#

is anyone already on burst 1.8?

solemn hollow
#

im not because tertle earlier mentioned a burst cache bug which is only fixed for 1.7.2

viral sonnet
#

damn, I had high hopes that the cache bug is gone. hm, I remember 1.7 having that too. good to know that it's at least fixed in 1.7.2

solemn hollow
#

anyone has any idea why ecb.RemoveComponent<RandomColors>(entity); wouldnt remove a DynamicBuffer<RandomColors> ?

#

i do have addjobhandlefor producer etc

#

i wanted to only generate random colors at gamestart based on some seed. but somehow this system runs every frame cause the entities still have the RandomColors buffer.

viral sonnet
#

hm, no idea. maybe another system adds the buffer again?

rotund token
#

yeah what manarz said, cache bug fixed in 1.7.2 not fixed in 1.8 preview (came out before 1.7.2) should be next update

solemn hollow
rotund token
#

targeting wrong entity? 😬

solemn hollow
#

no the entities are correctly shown in the inspector. somehow the system doesnt execute the job but is still updating. and the entities.foreach query is correct

#

shit it was just an early out i missed...

#

shouldnt code 18 hrs straight

nocturne bear
#

There is a problem with LocalToWorld.Rotation if scale is not 1f. Thats why I have a problem if I using CopyTransformToGameObject. To fix it you need to use quaternion.LookRotationSafe(localToWorld.Forward, localToWorld.Up) for GO rotation.

#

Now I move my camera in LateUpdate based on initialized EntityManager and target Entity.

#

And it works correctly i think

solemn hollow
#

sounds fine. i think polling the Entity for its position is ok here. just make sure to not write from GO world to Entities world.

solemn hollow
#

is there a way to require an EntitiesForEach for an update of a system instead of an entityquery? i got an entityquery which should not necassarily trigger an update but an Entities.ForEach that should trigger the System update

#

its more for curiosity than anything else. i can of course just convert that e.Foreach to a IJobEntity and define the second neccassary query

rotund token
#

scale fucks with translation matrix

#

you need to remove it from the matrix before you can pull out rotation

#

life is much easier if you avoid scale

nocturne bear
#

I know, I solved the problem before. I using: quaternion.LookRotationSafe(localToWorld.Forward, localToWorld.Up)

#

But the system what use CopyTransformToGameObject component doesn't work and I cannot change it

#

Do you know if is possible to limit max. count of workers?

rotund token
#

JobsUtility.MaxJobThreadCount

nocturne bear
#

It's const

rotund token
#

JobsUtility.JobWorkerCount

tidal gulch
#

is there a way in 0.51 to show a list of UpdateBefore/UpdateAfter relationships for a system in the Entity Debugger? found it in DOTS debugger

robust scaffold
#

Some more time spent with the batch renderer group. Yea, this is cutting edge as fuck. It has a lot of potential, hypothetically my entire 18 draw call lighting system can be compressed into "one" draw call with it. But it lacks a lot of the flexibility with render command buffers. For one, there's no way to specify a render texture target other than screen I believe. Which is a major pain point. And there's no way to inter-weave procedural draw calls and compute shader dispatches without exiting the BRG ecosystem altogether although that is apparently on their roadmap to implement.

drowsy pagoda
#

Strange behavior. I have a SystemBase that has an OnQuitGame method which retrieves a singleton and uses GetBuffer to get it's buffer to read data, serialize and write to file. This is outside a Job System (including Entities.ForEach). Now, when testing it, it works, but after I exit play mode and go back in, and fire that same method, it throws the following:

Unity.Entities.ComponentSystemBase.CheckedState ()```
Things to note. I am using Editor Play Mode with Domain/Scene Reload disabled.
When scripts compile, this error does not throw, the method works, it only throws when I try it consecutively after compilation. Is there an extra step I need take to manually init system state (whatever that is) due to Domain Reload being disabled?
rotund token
#

are you unsubscribing from the event?

drowsy pagoda
rotund token
#

well what is OnQuitGame?

drowsy pagoda
#

It’s just a method. But you know what, I will comb through the code and verify I am unsubscribing from all related event listeners. I think you are on point with this, I’ll look into it tomorrow.

late mural
#

is there any known bug with colliders being converted into way too big versions, that randomly gain and lose force for seemingly no reason?

rotund token
#

are you touching scale?

late mural
rotund token
#

so memory is a little foggy on this but previously physics did not support scale changes at all but i believe now they might support unified. last i heard there were no intentions of supporting non-unified scale ever.

late mural
#

oh that is really annoying, ive never had any issue with non unified scale with dots before, only now, and all my things are made up of non uniform scaled cubes to create stuff, so hmm, ill have to use uniform scaled cubes, and just a whole ton of them

solemn hollow
#

are we talking about entity scale or adjusting the collider bounds itself? i hope the latter is supported?

rotund token
#

Uniform runtime scale is something we are planning on investigating, however at the minute for convex hulls or meshes the easiest thing is to modify the input geometry and recreate.
Note that non-uniform runtime scale is not being considered.

from 2020

#

i believe the top part was done but don't quote me on it

#

i try not to use scale

late mural
#

oh that is really annoying, also mine aint at runtime though incase that affects anything, still possible, but everything will take twice as long with converting from blender to unity, oh well i guess

rotund token
#

hmm i thought during conversion non-uniform scale was baked into the mesh

#

and /should/ be supported

late mural
#

really doesnt seem like it

#

judging by how my rigidbodies freak out at having a non uniform scale

solemn hollow
rotund token
#

baked into my collider

late mural
#

oh found a difference between entities and gameobject physics, if 2 colliders both under the same rigidbody collide with eachother, they both gain infinite speed for some reason, this usually does not happen in game objects, hence why i stupidly assumed it was scale related, sorry im very dumb sometimes

rotund token
#

was my go for conversion

late mural
#

good job though, and thanks for helping me, even if it was just me being stupid without realising it

#

still annoying that colliders that collide with eachothers under the same rb gain infinite force, i can find workarounds though

#

wondering, will it be performance costly to set a gameobject's position to the position of an entity every frame?

rustic rain
#

internal transform system

late mural
rustic rain
#

it does it through transform access array

#

so it's somewhat fast and optimized

#

but certainly has it's overhead

late mural
#

oh, what if i do mine unoptimized?

rustic rain
#

of constant 0.16ms for me

late mural
#

nice

rustic rain
late mural
#

oh

solemn hollow
#

hmm is there still no section about DOTS build config in the Doc?

rotund token
#

it let's you write it in multiple threads

rotund token
late mural
#

ill try it out then sure lol

rotund token
#

btw the build config is kind of busted in 2021 ^_^' ui toolkit issue

late mural
#

im just tryna make it so my game object based character controller cant walk through the entity based exit door and leave without beating the level

solemn hollow
rotund token
#

well the menu just doesn't work

#

so you can't add components

rustic rain
rotund token
#

though personally i just setup my configs in 2020.3 and copied them in

#

once components are on its all fine

late mural
rustic rain
#

why not just keep game logic in ECS?

late mural
rustic rain
#

Getting access to ECS from GameObjects is a pain

#

it was meant otherwise: ECS gets access to GameObjects

late mural
rustic rain
#

welp, good luck then

late mural
#

yup, i have a feeling ill need it

rustic rain
#

quite weird, Unity still doesn't use DOTS inside their classic Physics engine

late mural
#

perhaps there is an easier way of making my character colliding with entities using some kind of jank method though

rustic rain
#

or maybe it does...

#

idk tbh

late mural
#

i could do it the reverse, and have the entities grab the gameobjects positions and change them to be the same as the entities, which would probably be cleverer, still annoying to set up, but easier perhaps

#

wait im an idiot, i only have 1 exit door per level, so i dont need to use the transform access array, cause ill only have 1 level loaded at a time, so only 1 door needs to stay accurate at once,

#

laziness once again triumphs in simplicity

late mural
#

the real question is, how do you get a game object in a system base? Is there some way to get them by name, or tag, or something else?

solemn hollow
late mural
devout prairie
#

So for example if you have a mono that needs to send a gameobject pos/rot into the ecs world, just write the Vector3 and Quaternion values to the System field inside the mono Update loop, and the System can pick it up when it runs.

#

A System as i understand it is a managed class in any case, so if you're running mono's there's no reason why you can't just write to the System

rotund token
late mural
#

thank you so much!

late mural
solemn hollow
late mural
#

before i go to bed, with all my new knowledge, im wondering, does float3 convert naturally into vector3 or will i just have to manually convert beforehand?

coarse turtle
late mural
woeful comet
#

I'm running into a weird issue with Hybrid Renderer.

#

After updating the RenderBounds for an entity, the updated bounds don't seem to come into effect until I select its entity in the DOTS Hierarchy editor window.

#

Has anyone seen something like this before?

woeful comet
solemn hollow
#

u sure it has nothing to do with near clipping plane?

woeful comet
#

I don't think so, it happens for far-off entities too

solemn hollow
#

i had similar issues while working in the editor. focusing on another object fixed it for me so i didnt dig deeper

woeful comet
#

Interesting. It happens in the player for me too (where I can't open the DOTS Hierarchy), so I'm doing my best to fix it.

solemn hollow
#

if you find the cause let me know 🙂

drowsy pagoda
solemn hollow
#

he usually is 🙂

woeful comet
#

I think I've found the issue to the rendering issue above.

#

Hybrid Renderer doesn't update batch bounds unless an entity in that batch has moved.

#

That seems like a bug in Hybrid Renderer to me.

robust scaffold
woeful comet
#

Updating the RenderBounds component on one of the entities in the batch

#

I'm updating the meshes at runtime

#

Adding this after each RenderBounds update works around the issue for me:

var localToWorld = EntityManager.GetComponentData<LocalToWorld>(job.Entity);
EntityManager.SetComponentData(job.Entity, localToWorld);
safe lintel
#

hm ISystem doesnt work with IJobEntity? annoying waste of an 30mins to figure out that one

viral sonnet
#

I have never tried IJobEntity with it but very possible as only some IJobs are actually implemented

robust scaffold
#

and I believe they fixed the burst job scheduling

misty wedge
#

Are there any issues with storing a BlobAssetReference inside another blob?

robust scaffold
misty wedge
#

I was wondering since there's stuff on the wiki about the data in blobs needing to be "moveable", but I think that only refers to pointers pointing to something inside of the blob, not the blob itself

robust scaffold
#

But Im 99% sure blobs dont move past creation. If the blob gets disposed, then you need to manually go through all the BARs and unset them

misty wedge
#

When do they move then?

robust scaffold
misty wedge
#

I imagine that can't happen during runtime since that would be catastrophic

robust scaffold
#

I dont think any of my BAR ever got invalidated outside disposal so I think you're fine to store them

misty wedge
#

I don't really understand why internal references need to be stored as offsets instead of an actual pointer to the data then, since the blob moving would break everything anyways

#

Maybe for some authoring time stuff that uses blobs? I don't know

#

I don't do a lot of subscene authoring stuff for my project, can you serialize a custom created blob asset into a subscene?

misty wedge
#

Then I'm guessing this is the actual issue with storing direct pointers. I'm guessing you also can't store a BAR in a BAR that you are writing to a file, since the address would have changed when you load it again

robust scaffold
#

Oh yea, that wont work

misty wedge
#

Ok, then that part of the wiki makes a lot more sense. I only use BARs for runtime stuff, that's why I was confused

robust scaffold
#

Subscenes are streamed from hard drive byte file through blob assets. Storing BARs in blob assets will result in invalid BARs so dont save a subscene with it.

misty wedge
#

What's the plan on unity's side in the future? Since there are now two very different scene systems that exist at once.

#

Or is it just "keep the current one for GOs, and this one for DOTS"?

#

Actually nevermind, I think I misunderstood it

#

I'm guessing only the "DOTS" version of the scene is saved as a blob

robust scaffold
#

According to the guys making the batch renderer group API in 2022.2 alpha, the end goal is being able to put everything, GOs and Entity conversion into a subscene that will all be rendered in one super draw call with the BRG.

misty wedge
#

Huh, interesting

#

iirc I remember reading somewhere that they want to port a lot of the current GO stuff to use DOTS stuff internally for performance gains, but I haven't checked on that in a long time

robust scaffold
#

One draw call per subscene and you can have multiple subscenes streaming in.

misty wedge
#

Or is that what the BRG does

robust scaffold
#

Multiple materials, multiple meshes, multiple objects.

misty wedge
#

Does it even batch other normally un-batchable stuff, like non-uniform transforms on dynamic objects?

robust scaffold
#

everything front loaded at once and then it's GPU for the rest of the frame.

#

The transforms are per instance in a massive array buffer. So that doesnt matter.

misty wedge
#

Sounds pretty cool

robust scaffold
#

Very interesting but it's apparently GO/Mesh rendering to camera only. Wish I could do things like post processing with it.

misty wedge
#

I'm assuming that will be added at some point

robust scaffold
#

Post processing ability? Probably not. Im getting the impression that the current render features are the method for that

misty wedge
#

Doesn't the final image still exist in a render buffer at some point, and couldn't you just blit it then with effects?

robust scaffold
#

No, it's straight to camera. You need to set up a second camera just to capture the output.

misty wedge
#

And you can't set the camera's output to a render texture?

robust scaffold
#

You can, but the camera itself eats about 1.5ms of CPU just for the setup and rendering. The blit to RT can be measured in nano seconds so the entire camera is a massive computational sink

misty wedge
#

I guess it depends on the time saving you have then compared to "traditional" rendering, might still be worth it

robust scaffold
#

I doubt it. Using single camera with DrawMeshInstancedProcedural with a ComputeShader selectively updating GPU side buffers and meshes is very cheap. My current 2D lighting stack which is intended for hundreds of lights visible simultaneously and casting shadows costs 0.020ms of CPU time to schedule.

#

Full screen pixel perfect circles with 500 lights costs about 6.5 ms to render per frame. Using half resolution (which is barely different than full res especially with bilinear filtering and a small gaussian) cuts that down to 1.5ms. 1/10 rendering and it's CPU limited.

#

I can render 8000 lights (max supported currently) with 1/10 resolution which looks "okay" at CPU limited speeds. It's a completely empty scene otherwise.

#

The setup of the camera takes longer than rendering 8000 lights, and that's just one cam.

#

I dont know what you have to be rendering in order to make a post processing stack work on BRG. Which is a real shame.

misty wedge
#

Didn't know the setup and rendering alone takes that long, never checked. Yeah not being able to use post processing seems like a big downside

robust scaffold
#

Oh you can still use post processing through URP/HDRP render features. That's not an issue.

#

You just have to do it though multiple draw calls.

misty wedge
#

TBH I do so little rendering stuff I doubt I can add very much to the conversation, but you certainly seem to know your stuff

robust scaffold
#

And you cant "schedule" those draw calls on a job thread to async call them from the main thread.

#

I've spent the last few weeks neck deep in the post processing stack

misty wedge
#

I tried using the hybrid renderer a few years ago and it was so buggy I never tried again

robust scaffold
#

Yea, dont. Hybrid is a mess

#

Just build your own renderer if you're doing something simple or stick with GOs and handle the data processing entities side before re-distributing it to GOs

#

URP and HDRP were made with GOs in mind. Hybrid is trying to get in between but it's real difficult.

misty wedge
#

I've also never looked in depth at how URP/HDRP works vs the default rendering pipeline. To me it's still "URP/HDRP needs you to set up some extra stuff in scriptable objects to work, and supports the 2D renderer" 😬

#

The fanciest I've gotten on the rendering side is write a really simple shader for "prop-up" 3D shadows on a 2D plane, which is on the very low end of complexity

robust scaffold
#

BRGs are basically a completely new rendering system, kinda. Instead of trying to Indiana jones replace GOs to entities that feed into the URP/HDRP rendering system, it's completely replacing the rendering system and making URP and HDRP basically optional post processing stacks.

#

It's a third rendering pipeline, despite unity constantly saying HR will not be a third rendering system

misty wedge
#

Ah ok, I thought it was just some additional renderer feature for URP/HDRP

robust scaffold
#

Currently yes. 2022 version, no.

misty wedge
#

Then it makes more sense that it doesn't "natively" work with post processing

robust scaffold
#

yea, which is sad.

misty wedge
#

Just make the game so performant you have the milliseconds over for the normal post processing ok_handbutflipped

robust scaffold
#

the issue with BRG as a post processing system is that it's practically "single pass" only. I think, i dont see anywhere in the API that allows for the specification of subpasses to be rendered per material.

misty wedge
#

What happens if you use multiple BRGs, are they rendered separately? I assume the separately rendered objects in this case can't occlude each other

robust scaffold
#

You can specify multiple draw "commands" in a single BRG targeting different cameras / layers and each command has it's own (single) material, (single) mesh, any number of instances, buffer for per instance data for each of those instances, and rendering layer target. You can chain multiple commands with different materials and different mesh combinations and it will all render as one draw call.

#

I cant think of why you would need more than one BRG.

#

One for opaque, one for transparency?

misty wedge
#

But BRGs and the normally rendered URP/HDRP rendered objects "mix" correctly? e.g. a BRG object can be "between" two URP/HDRP objects on the Z axis from the camera's perspective?

robust scaffold
#

Yea, it just draws it to the screen at the proper location and depth filtering like the other two RPs. No occlusion culling so if a regular GO is rendered by URP right in front of the camera, BRG will still render in the target mesh except nothing will show.

#

If you want occlusion culling, ya have to do it yourself.

#

At least there's vertex culling, that's built in Core rendering feature.

misty wedge
#

Is occlusion culling even needed if this system is so fast?

#

I guess it depends on what you are doing

rotund token
#

unitys hybrid renderer dynamic occlusion culling has a lot of potential

#

high hopes in the future

robust scaffold
#

The benefit of BRG is that it's single GPU data upload and launch point for all object rendering to camera. There's no need for small sync points with main CPU thread for further draw calls or whatever. It doesnt revolutionize how things are actually rendered.

#

What is happening right now is with a bunch of different objects with different materials, the RP takes each individually and draws them one at a time if none of them are batched. CPU halting until GPU says it's done rendering and then it sends in a different object with different materials and so on.

#

Sometimes like dynamic batching and the SRP batcher, it detects identical meshes and materials just different transforms and it can merge it into one, but it's really fragile.

misty wedge
#

Is that what the profiler shows as GPU.WaitForSomethingICantRemember?

#

I don't know what it is specifically called

robust scaffold
#

GPU.WaitForSignal?

misty wedge
#

Yeah

misty wedge
#

Is the "new" game view VSync still done by stalling the CPU?

robust scaffold
#

It's Semaphore.WaitForSignal that's what I was thinking of.

robust scaffold
misty wedge
#

Random rendering question: Do you know how Unity's 2D tilemap renders the Z ordering (the Z position of the Tile) to screen? I've never been able to get the Z position inside of a shader, and I need it for an effect

robust scaffold
#

A tilemap is completely flat. If it's the default tilemap and you didnt change the transform's Z value, it will be 0 according to the shader.

misty wedge
#

Bummer

#

Would have been nice

robust scaffold
#

you might be better off basically recreating a tilemap. Use the unity provided one for editing and rule tiles then mirror the changes somehow to a plane you create and manually render

#

if your tilemap's rectangular, that's a lot easier to find the tilemap XY from the transform and bounds at least.

misty wedge
#

I only need the Z position 😅

robust scaffold
#

hexagonal? You might be able to calculate it manually from LocalToWorld, center point, and bounds but it's gonna be rough.

misty wedge
#

No, the tilemap is square

#

I just have multiple layers

robust scaffold
#

Like different tile maps overlaid?

misty wedge
#

Yeah, I know I could use multiple tilemaps, but I'm not sure how that scales performance wise

robust scaffold
#

Tilemaps are giant planes. Extremely cheap.

#

Use that.

misty wedge
#

Basically I re-use a lot of sprites by passing a 1D texture to the material property block of the sprite and using it to re-color based on the sprites R channel.

I'd like to expand this to the tilemap (meaning I would probably pass a 2D "remap" texture, basically a lot of 1D textures"), then I need to pass another array to the shader which maps positions to remap colors, and then remap.

robust scaffold
#

recolor specific tile types or recolor specific locations

misty wedge
#

Specific tiles, basically all tiles belonging to a biome

robust scaffold
#

Use a series of swap tiles.

misty wedge
#

But then I would need to store the texture multiple times

#

(in recolored variants)

#

Or programatically create it on initialization and create a new texture internally

robust scaffold
#

Hrm, yea. You might want a shader for that. Hrm. The tile type itself is stored in TEXCOORD0 but I dont know what it's referencing.

misty wedge
#

I know the tiletype since it's procedurally generated, and I know what biome each tile belongs to

#

That's stuff I could write to arrays and pass to the shader

robust scaffold
#

do you use rule tiles?

misty wedge
#

No, I have a custom editor for creating auto tiling tiles, these are then converted to TileBase instances, and used inside a scheduled job to form arrays after the procedural generation part, and are then batch passed to the tilemap

robust scaffold
#

If you dont use rule tiles or are willing to implement it yourself, a tilemap is literally a giant quad with a RInt texture plastered on, then post processed on transparency queue to fill in sprites for each.

misty wedge
#

The most definitely easiest thing would be to just copy the tiles and re-color them to a new texture, and then set that to the TileBase's texture

robust scaffold
#

Easiest but not what I would recommend. Especially since recoloring dynamically is extremely easy on shaders.

misty wedge
#

Yeah, and it would also open up more effects, e.g. dynamic recoloring for snow or something

robust scaffold
#

The issue is that camera color buffer isnt exposed for custom rendering until post transparency queue on URP at least

misty wedge
#

I think it should work if I split up all layers into separate TileMap instances, and then pass the correct array to each one?

#

One performance "drop" in this case is that I would need to call SetTiles for each layer, but it should still be fine

robust scaffold
#

hrm, i dont know. Tilemaps arent hard to code, especially if you just render your own custom tilemap at Z coordinate -1 so it's behind all the sprite rendering earlier in Opaques.

#

And if you use your own custom tilemap editor, then rehooking it up to your own custom tilemap wont be difficult.

misty wedge
#

I have an editor for tiles, but not for tilemaps. The maps are all generated, so I never used the one from unity

robust scaffold
#

You can even offload the entire thing to GPU.

#

Oh hrm, still. It's very easy relatively. You dont even need to touch a single actual mesh other than a quad.

misty wedge
#

So how would that work conceptually? I've never done it. For each tile grab the UVs which correspond to the sheet it's on, set the UV array on the mesh to the correct ones?

#

iirc unity's tilemap doesn't even do more complex stuff like greedy meshing, and it's still pretty fast

robust scaffold
#

Nah, you have one massive quad with scale the size of the tilemap bounds. Then you have 1 render texture plastered on it with the same bounds. Each pixel on that render texture will be an int value that corresponds to a tile type and sprite. Then in a full screen camera render, you replace that single int index with the actual sprite of the tile.

misty wedge
#

See that seems like a lot of complex stuff for somebody that's never done it before 😅

robust scaffold
#

you calculate the UV of that sprite to sample in replacing the pixel on the screen with the local space UV / tilemap bounds to obtain the cell's UV.

#

very simple, 2 shaders at most. The hardest part of this will be making an editor for this tilemap.

misty wedge
#

I don't have any authoring time tilemaps, they're all generated

robust scaffold
#

ah, that's even better. Yea, all of this can be done on the GPU. Alternatively you can have an compute bufffer array of ints and then populate the camera screen with single sprite quads.

#

That's what I'm doing with my 2D lighting engine. 8000 "tiles" max in a single screen.

#

I take a single quad, scale it GPU side to the size of its radius, color it in with an appropriate inverse square circle falloff and light color, black out tiles in shadow, and then paste it onto the game view scene.

#

And do that for every light visible, up to 8000 times

misty wedge
#

Are the "lights" here actual unity lights?

robust scaffold
#

nope, just my own custom struct. A float for radius, a float2 for position, and a float for wall illumination. Then a float4 for light color.

misty wedge
#

Why the 8000 limit then?

robust scaffold
#

I color in a texture with the light's 1D depth map. Maximum texture size in unity is 8126 or something, which means thats the max amount of lights.

#

I could add extra channels for extra lights, for a total of ~24,000 lights if I want to (currently I only use the R channel, it can be expanded to G, B, and A if needed) but the lights start noticably laggin hard past 8000

#

And more if I enable more textures but at that point, the screen will be white.

misty wedge
#

Haha

#

Pretty cool way to do it

#

And seems to be pretty fast if it can do 8000

robust scaffold
#

That's what a depth texture looks like

misty wedge
#

modern art

robust scaffold
#

For these 4 lines of light

#

if you disperse those lights, the depth textures will look like complete noise.

#

but each row represents a single light's 360 view

#

If you jack up the light radius, thats what it'll look like for 500 lights

misty wedge
#

flashbang

robust scaffold
#

Yea. It's also chugging at 500 which is pain

misty wedge
#

How do I then render the actual sprite ("replace" the indices)?

#

As long as all the tiles on my sprite sheet are square and the same size I guess I can use the index to just index the sprite sheet directly

robust scaffold
# misty wedge How do I then render the actual sprite ("replace" the indices)?

You have a pixel coordinate in camera UV space in a frag shader. You can use some of the matrixes available to convert that to world space then, when using orthographic rendering, subtract the camera's Z position from the pixel's Z position to get tilemap's XY world space position. Then you use the tilemap's local to world to get local coordinate for the pixel on the screen. Then you use the tilemap's bounds to determine the cell's UV position that is then used to sample the target's sprite's UV.

#

using the camera's RGB, you can have a maximum of 4 billion tiles.

rotund token
#

riddle me this

{
    for (var index = 0; index < statValueBuffer.Length; index++)
    {
        StatEffect* effect = statValueBuffer[index].Effect;
        ref StatModifier modifier = ref this.statModifiers.ElementAt(effect->Type);
        modifier = modifier.Add(*effect);
    }
}```
effect->Type is 0-99 and by default randomly ordered
why is it if I pre-sort it on Type this chunk of code takes reliably longer every time
0.22-0.34ms vs 0.35-0.45ms tested a dozen times over a lot of frames switching between
I expected either no change or an improvement
rotund token
#

burst doesn't change

#

this job doesn't change

#

it's sorted outside of the job in oncreate

#

the only different is this.statModifiers buffer is ordered by Type

robust scaffold
#

I dont expect an improvement because a property access via pointer isnt detected by burst to be a constant for multiple iterations. But the reduction in performance is odd.

#

Yea, this is random access so no vectorization so it's not like the vectorized were replaced.

rotund token
#
    // ..
    foreach (var entity in entities)
    {
        // ..
        // values.AsNativeArray().Sort(new Sorter()); // This is only piece of code changed between tests
    }
}```
rotund token
#

i don't understand how it's significantly slower

robust scaffold
#

Is the profiler measuring the sorting?

rotund token
#

no it's in oncreate

rotund token
#

running every frame

robust scaffold
#

try mem copying the results of values into a new array and deleting the old sorted array?

misty wedge
#

How many entities is this and how large is statValueBuffer?

rotund token
#

values is just a DynamicBuffer

rotund token
misty wedge
#

So the data layout changed between your tests?

rotund token
#

no

#

it uses same seed

#

classic 1234

robust scaffold
rotund token
#

no idea

#

just trying to figure out how it's even possible to get this result

robust scaffold
#

does sort generate garbage?

rotund token
#

why would that matter

frosty siren
#

How would you design animation system? Say i have animation data which stored inside blob asset, and system which want to access to this data. What will you use? Enums/ids/String -> Hash/etc?

rotund token
#

the sort isn't part of the test

#

(and no there is no garbage it's native)

misty wedge
#

Did you try changing the seed? Maybe the data layout is just "randomly" much better for the way it's currently layed out

robust scaffold
#

If i remember correctly, sort requires use of burst discard due to the dynamic sorting function

rotund token
#

but it's completely irrelevant

#

even if i coped it to a List<T>

#

sorted it

#

wrote it back to the buffers

#

danced in circles

#

it has nothing to do with the profile

robust scaffold
#

and still bad performance?

#

Did the dynamic buffer leave the chunk?

rotund token
#

well yeah it has 0 size allocated

#

it's always out of the chunk

#
    [InternalBufferCapacity(0)]
    public unsafe struct StatValueBuffer : IBufferElementData
    {
        [NativeDisableUnsafePtrRestriction]
        internal StatEffect* Effect;
    }```
robust scaffold
#

And nothing else was running during this job

rotund token
#

there is the only piece of code running

#

even if i get rid of the markers thinking there's something wrong with that (and it does make the job go from 0.65->2.5ms) it's visually noticeable just profiling the actual job

robust scaffold
#

nothing initialized between the creation of the buffer and the execution of the job

robust scaffold
#

was the buffers initialized in sequence?

rotund token
#

yes

#

ok my code trick has broken =S

#

my entire job

#

that's all that is running

#

in the project when profile

robust scaffold
#

try instead initializing one, creating a native array with random length in temp memory, then initializing another entity and so on to break the sequence

rotund token
#

there are no native arrays

robust scaffold
#

because I think sorting the array is creating a new array of sorted values and replacing pointer of buffer and invalidating the old one

rotund token
#

there is no allocated memory

#

sort does not allocate anything

#

it just does a swap

#

moving sort out of the loop and doing all the sorts at once at the end does not change the result (just tested)

robust scaffold
#

It allocates something in temp buffer when merging the sorted segments with a custom comparable

#

It does memcopy it straight back into the original buffer though

rotund token
#

im not using the job to sort

#

that's SortJob()

#

Not Sort()

robust scaffold
#

Oh, same file. Just keep scrolling down. I dont know. If the pre-sorted at generation doesnt result in the performance drop, uh hrm

misty wedge
#

Result is the same even with a different seed?

viral sonnet
#

does the sort actually sort from 0-99 and not from 99-0 by accident?

#

I would have also guessed that it doesn't matter which order it actually is though. strange results that you're getting

devout prairie
#

wait what:

#

since when?

#

ah shit, typo

misty wedge
#

Why would you need it twice

robust scaffold
devout prairie
#

i'm an idiot

#

nm

#

😛

#

couldn't see the wood for the trees 😐

#

i thought they'd introduced a restriction of one dynamicbuffer for ForEach 😮

rotund token
#

regardless just going to ignore it as there's no benefit to sorting so no need to do it

safe lintel
#

havent tried this yet but think this would be a dumb idea to used a managed class component to pass around a nativestream to different systems?

rotund token
#

you are somewhat describing my popular event system (at least the 1.x version of it)

#

except without the need for a component

#

actually i guess using a component is a bit different than a system to manage it

#

it's not the worst idea, at least it handles safety for you

chilly crow
#

entities 0.51 Unity 2021.3.4

rotund token
#

yes it just doesn't work

chilly crow
#

oh thanks for the thread 🤩

#

hack doesn't seem to work but I'm probably doing it wrong

#

guess I'll just steal a config from somewhere for now

drowsy pagoda
#

Ever since Entities 0.50, I been getting the following issue. Everytime I make a successful build, as long as I had DOTS Hierarchy window open, it will fire off this error: The specified HierarchyNodeHandle(Scene:-119930:0) does not exist in the hierarchy. every editor frame. A simple script re-compile (right-click reimport) make this stop. Or if you close the DOTS Hierarchy and open it again it also stops.

This has been going on all the way through latest Entities 0.51 and latest 2020.3.36f (started from 2020.3.30ish). Anyone else run into this issue? It doesn't break the game or the editor in any way, just get's annoying to have to recompile after each build is all.

late mural
late mural
#

thank you so much!

#

wait no, that is the wrong way, sorry lol, is there anyway to go from float3 to vector3?

devout prairie
rotund token
#

the same thing in reverse?

#

dam beat by a second

late mural
#

oh thank you all so much!

#

im kind of an idiot sometimes lol

devout prairie
#

some values will cast directly like that and some won't

#

other ways in c# are like:

late mural
#

im just tryna set a position of a gameObject to the position of an entity, incase that helps

devout prairie
#
Vector3 v = Vector3.one;
float3 f = v as float3;

or

Vector3 v = Vector3.one;
float3 f = (float3)v;
#

but you don't need that in this case obviously

#

just in case it's helpful

late mural
#

thanks lol

#

also none of those ways you said up top are working for me, they all give me errors, perhaps im missing a library?

devout prairie
#

which way isn't working?

late mural
#

both

devout prairie
#

actually 'as' only works with reference or nullable types sorry, i forgot, so that method works with classes etc

devout prairie
late mural
#

sure, should i show with or without the methods in place?

devout prairie
#

just show a clip of what you have atm

late mural
#

ok,

#
doors[door_comp.door_id].transform.position = translation.Value;
#

this is inside a for each loop of entities btw

devout prairie
#

so what about it isn't working

late mural
#

well i need to convert the translation.value float3 thing to the vector3 thing, cause it does not do that automatically right?

#

or have i assumed something completely false accidentally?

devout prairie
#

what you've written is technically ok

late mural
#

ah so it will work?

devout prairie
#

the t.Value will convert directly to Vector3 and assign to transform.position

late mural
#

welp i feel like an idiot now

#

i kinda made a stupid assumption that it wouldnt lol, oh well, thank you so much!

devout prairie
#

we're all idiots, welcome to the club 😛

late mural
#

yay

devout prairie
#

except tertle, he's not

late mural
#

lol

rotund token
#

🤡

late mural
#

i saw tertle in the wild web answering a post about dots while googling stuff earlier

rotund token
#

i just hid my 2 years of stupidity while no one else was using dots

late mural
#

lol

late mural
#

also is it possible to use TransformPoint in a systembase, or is there some other way of converting from local space to everything space (i dont remember what it is called...)

devout prairie
#

so no methods from Transform or anything

late mural
#

i dont quite know what that all those things mean, but i vaguely understand, what should i do instead?

devout prairie
#

to get the world position of a position:

#

globalposition = parentposition*localposition;

late mural
#

oh ok cool!, how on earth do i get the parent of an entity?

mild meadow
#

hi, how do I get DOTS working on linux?
(entities packages are installed but entities dont get rendered and I get hybrid renderer V2 errors)

devout prairie
late mural
devout prairie
#

a child entity has a Parent component though, with a reference to the parent

late mural
#

aha, so i should probably use that get component thing that the entities own

devout prairie
#

there's a LocalToWorld component also, which holds the world position of an entity

late mural
#

oh that sounds nice! I'll check it out!

#

if i were to add and remove it every single frame, on a scale of 1 - 10 how terrible would performance be?

#

i realise i could do it only on the first frame, but eh i can do that later

devout prairie
#

uhh add and remove what, the ltw component?

late mural
#

probably

devout prairie
#

why would you want/need to do that

late mural
#

i dont really know, morbid curiosity combined with tiredness i suppose, i should really just not be lazy and do it first frame only, thank you so much!

devout prairie
#

ah ok

#

well adding and removing components are structural changes.. so doing that involves creating new archetypes and stuff..

#

so really it should be viewed as something to not do constantly

late mural
#

fascinating, so no burst, meaning ultra lag, how intriguing lol

devout prairie
#

well it doesn't affect burst running or not

#

and it won't lag

late mural
#

oh ok cool

devout prairie
#

but adding/removing components should really in an ideal world only be done when needed

late mural
#

lol, i probably will do that lol

devout prairie
#

hehe ok well have fun, you'll figure it out eventually, at least you're making the effort to learn

late mural
#

yay thanks lol

devout prairie
#

instantiating a prefab that consists of a hierarchy of physics joints in unnecessarily painful

#

at a specific position i mean.. because you have to manually position each physics object rather than just specify a position for the prefab to spawn and done

late mural
#

ok figuring out the whole localtoworld component thing, judging by googling stuff, guessing you gotta add it while looping through all the entities and then just add it to the right ones only, this is fun!

devout prairie
#

so you need to store the relative positions of all the physics bodies, then set translation of each relative to your 'spawn point'

#

annoying

#

same with rotation

devout prairie
#

just read the value when you need it

late mural
#

oh ok cool, thankyou!

#

yas now i have the exit doors actually have proper colission, now you cant just walk through them and skip the level, thank you so much!

#

although im gonna do more testing, cause i got a theory, i wanna see if it is more performant to have an if statement that checks if the positions are roughly the same then do nothing, cause i have a feeling it will be!

#

weird question, why is transform.position a variable, but tranform.position.z is not?

#

due to this i have to set all 3 axis at once, instead of only setting the 1 axis that moves

#

is there anyway to make transform.position.z a variable so that i can set only 1 axis instead of 3?

late mural
#

also the mathf approximately thing completely breaks sometimes for seemingly no reason, and it says stuff like 10 is approximately 15, so eh ill pass true, although this appears to be quite rare

devout prairie
late mural
#

oh ok thank you so mcuh!

late mural
devout prairie
#

There are equivalents for most of the mathf methods in math

late mural
#

oh ok, ill go do some research and report back, thanks so much!

#

oh from research it appers it is still being discussed on what to name it and how it should work, so currently there is no equivelant, according to the github issues page atleast

#

should i just round each of the floats to a certain amount and then just use == then?

#

from more research it does seem that i should just continue using mathf for the approx function, as there appears to be nothing better unfortunately, unless im missing something obvious

devout prairie
#

Ahh sorry I hadn't noticed u were using approximately, not at the pc atm so cant check :|

late mural
#

its ok lol

misty wedge
#

Mathf.Approximately is just abs(x1 - x2) < epsilon afaik

late mural
#

as such why bother reinventing the wheel, shouldnt i just use the mathf one then?

misty wedge
#

It uses Mathf functions internally, not math functions

devout prairie
#

If you're getting rounding problems could maybe multiply the float by 100 or so and compare the integer value

misty wedge
#

Just copy the Approximately code and replace the Mathf versions with math versions

misty wedge
#

This is the code: public static bool Approximately(float a, float b) => (double) Mathf.Abs(b - a) < (double) Mathf.Max(1E-06f * Mathf.Max(Mathf.Abs(a), Mathf.Abs(b)), Mathf.Epsilon * 8f);

misty wedge
#

Also, if you plan to use your new custom math.approximately function a lot, I would add a [MethodImpl(MethodImplOptions.AggressiveInlining)] above it for good measure

late mural
#

oh ok ye, i plan on using it every frame, so ill do that thanks!

late mural
misty wedge
devout prairie
misty wedge
#

I wish it was possible to add static functions to namespaces as extension methods, I hate naming stuff like this <existingstaticclass>Extensions

late mural
devout prairie
late mural
devout prairie
#

to make static just put static in front of the method return

late mural
devout prairie
#

Like 'static void myMethod()'

late mural
#

oh ok, i have to make this thing a method, i thought i just had it as a bool, this is cool lol

#

oh this is gonna be harder, apparrrently unity maths does not have any equivelent for epsilon, so imma have to create my own one then

#

ah this is really complex, when i wanted to make doors have collission as a goal for today, i did not realise how deep i would sink into math madness, oh well, onwards i go!

#

and do i use epsilon b or a when creating an epsilon?

misty wedge
late mural
#

making certain, did i do it all right: ```csharp
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool Approximately(float a, float b) => (double)math.abs(b - a) < (double)math.max(1E-06f * math.max(math.abs(a), math.abs(b)), math.FLT_MIN_NORMAL * 8f);

haughty rampart
#

math.FLT_MIN_NORMAL * 8.0f is likely still math.FLT_MIN_NORMAL

misty wedge
#

It's Unity's Mathf.Approximately implementation 🤷

late mural
#

oh ok, sorry, im just tryna follow the mathf implementation...

late mural
#

also due to how there is not much info on unity.mathematics, im going to ask a stupid question yet again! How do you round?

misty wedge
#

math.round

late mural
#

Thanks so much!

misty wedge
late mural
#

oh that will be very useful, thank you so much!

#

also i think "thank you so much" is becoming my catch phrase lol

misty wedge
#

It can just be a bit tricky to navigate since a lot of the code is auto-generated due to a lot of overlap between types

late mural
#

oh ok, thank you so much!

misty wedge
#

Although, again, a lot of overloads for many type combinations

late mural
#

makes sense, thank you so much yet again!

misty wedge
#

No worries

late mural
#

lol

#

aha, how do i round something to a specific decimal point, cause it appears that round() is with no decimal places, sorry lol for being vague earlier

misty wedge
#

I'm not sure what the fastest way to do it is, and Unity also does not have a round to digits function afaik, but this is the implementation in Math.Round

late mural
#

perhaps i could use the weird trick of multiplying the float by something then dividing it like i saw on an ancient post?

misty wedge
#

Why do you need to round to specific digits?

late mural
#

i want to use my approximately thing in combination with a less accurate position from a game object and an entity to save performance in a way that the player wont notice that the collission aint accurate

#

it is a little jank, but it should work in theory

misty wedge
#

Just a heads up, approximately will not tell you if two float values are close, it will tell you if two float values are functionally equal to one another

late mural
#

aha i got it!

#

so i multiply it by the amount of decimals i want expressed in the 1 with 0 the amount, if that makes sense, then round, then divide by the same

misty wedge
#

You can also just call System.Math.Round, since that's what math does already

late mural
late mural
#

woah ok than you so much!

misty wedge
#

But your version is probably fast if you don't need midpoint rounding

#

It skips the midpoint rounding check in the function I posted above

#

Which makes it equal to your version

late mural
#

i dont know what midpoint round is lol

late mural
#

ooh nice, thank you!

misty wedge
#

It doesn't really matter in your case though, you want performance, not accuracy. I think rounding approach is more important in a banking context and not in a video game 😅

late mural
#

good point, so overall which method you think is faster lol?

misty wedge
#

I think you are fine with calling System.Math.Round, but it's up to you. The compiler and CPU are pretty good at predicting branches that are never taken

late mural
#

oh ok, ill do the system math round thing for tonight, but on the weekend ill test both and see which one performs better

misty wedge
#

I don't think you'll be able to see a difference

late mural
#

and do i need to import System.Math im guessing?

late mural
misty wedge
late mural
#

oh so i dont need to import anything then? nice!

misty wedge
#

The System name space is part of the language, so no

late mural
#

yay!

#

ooh i do gotta convert from float to double though, this shall be fun to learn!

misty wedge
# late mural yay!

I just checked, you can't use System.Math.Round to round to a specific amount of digits. You'll need to write your own function. Burst converts it to vroundss and strips the parameters, and it is specifically stated as unsupported in the burst docs

#

It will just round your number to the nearest integer

#

Kind of odd that burst doesn't throw a compilation error in this case, maybe it's because I'm on an old version

coarse turtle
#

You can likely get away with math.round(float * 10^n) / 10^n to round to the nearest digit, where n is the digit you want to round to

devout prairie
#

is there a way to get thread index inside a system ForEach

late mural
#

ill try that!

devout prairie
#

But in ForEach rather than jobs

#

basically the method creates an array of Random structs, one for each possible thread

#

then each job can access and increment it's own random for it's own thread, in order to get true random

#

( using one single random struct across all threads will produce the same results )

#

wondering if there's something similar to ForEach (in int entityInQueryIndex) but for thread index

coarse turtle
devout prairie
#

Was getting zero results searching for it:

#

I hadn't realized not to use 'in' with entityInQueryIndex

frosty siren
#

why EntityCommandBufferSystem do GC alloc?

robust scaffold
#

In the recent 0.51 announcement (that they finally posted), they mentioned

A new simplified SystemBase type that allows for implicit job scheduling and the ability to schedule jobs to run both sequentially and in parallel"
Does anyone know what that means?

devout prairie
#

I think its just talking about .Schedule and .ScheduleParallel and SystemBase replacing the old EntityComponentJobSystem or whatever it was called, because I noticed there was a lot of mention of that in the 5.0 docs, maybe for the benefit of people who'd used the old way of doing it 🤷‍♂️

#

As well as emphasis on the Dependancy return for controlling scheduling order etc

viral sonnet
#

Any idea how this should be handled better? Like you have SystemA and SystemB. SystemA schedules jobA and SystemBs job needs the handle from jobA. In a SystemBase this isn't really a problem. You can just get the handle from the systemBase class. But how should we handle this in ISystem?

rotund token
#

Unitys built in dependency management!?

#

Ideally this hard dependency coupling is something you'd want to avoid

#

But if you really need it, my event system 2.0 branch can handle it

#

And works with ISystem if you want inspiration

solemn hollow
#

ive not run into a case yet where i had to pass handles between systems. i quite like the automatic management. most i do is order systems manually in some cases by creating them in a specific order

viral sonnet
#

I'm not aware that unitys built in can manage 2 systems. yeah trying to avoid it. what's the most reasonable then? schedule all the jobs from 1 system ao i can set the proper handles?

#

if i merge it all in 1 system it's gonna be huuuuge 😅

solemn hollow
#

Im refering to the Attributes (UpdateAfter etc.) that handle dependencies between jobs in those systems

#

i think tertle is too

viral sonnet
#

huh i thought this only manages the order of updates? so it puts the dependency jobhandle from the system in the attribute too?

solemn hollow
#

it makes sure that the dependencies between the systems are resolved correctly. each job in SystemB will indirectly have a dependency to each job in SystemA

#

atleast if you use the dependency of the System itself as a dependency in its jobs

viral sonnet
#

alright, i gotta try this then. could be a little crude though. but maybe I have to move dispose jobs somewhere else then

solemn hollow
#

i dont know how hard it will be for you to refactor but writing it like that from the getgo is really simple

#

And btw even if you dont use the attributes unity does some automatic dependency handling. it makes sure jobs are resolved in the order you scheduled the systems. so if 2 jobs in 2 different systems want to write to the same component those jobs are handled in System Order

#

I use this in my AI to schedule the systems in an order defined in a graph without having to know which systems actually will exist at runtime

viral sonnet
#

not too hard to refactor. I just need to know what I'm doing 🙂 So, having UpdateAfter(SystemA) on SystemB would also give me the dependency of the job scheduled in SystemA? I sadly have never quite figured out how the first state of Dependency in a SystemBase is formed.

#

i should debug it at some point to understand it better.

solemn hollow
#

the first dependency (Dependency of the System itself) in a systembase is formed by looking at the system order in the playerloop. Unity figures out dependencies on other systems for you based on the entityqueries the systems have

#

so if you tie all your jobs of a system to the systems dependency its all automatically resolved

viral sonnet
#

ah well, i have only a small amount of actual queries

solemn hollow
#

and only if you need to run it in a specific order u need to use the attributes

solemn hollow
viral sonnet
#

to be more specific. i have 3 systems that write to arrays. all 3 are not dependent and run in parallel. once one is done i run another data transformation job for each and when those 3 are done one job reads from all 3 finished data. so that's why i have the handles in place. easiest solution.

#

i don't think i can handle this just with update after

solemn hollow
#

i didnt fully understand the second step there. the last system could just have 3x the UpdateAfter Attribute

viral sonnet
#

ok i'll try this. thanks

solemn hollow
#

is that second step actually a step that could be merged into the first job of each system?

#

cause i found it improved performance alot to schedule less but bigger jobs

viral sonnet
#

yeah it could be moved without trouble

solemn hollow
#

maybe this is useful to you

viral sonnet
#

ah no it cant run in the same job. one is parallel, the other single

solemn hollow
#

ah i see

viral sonnet
#

The current implementation of inter-system dependency is fairly simple. Between systems, Dependency.Complete() is called. What?

solemn hollow
#

not true

viral sonnet
#

yeah ok 😄

solemn hollow
#

i think what Kmsxkuse saw had something to do with which components he used. if he always wrote into the same component he would see something like syncpoints because each system would have to wait for the previous system

#

thats why its so damn imortant to declare read and write dependency correctly for unitys automatic dependency management

viral sonnet
#

ah, right. i have the last system already in another systemgroup so that should mean i don't need any updateafter

solemn hollow
#

if you made sure the systemgroup is executed later in the frame you dont

#

im still not certain about what happens if you'd not use any queries and no attributes. it might be possible that your last system then updates after the first few systems but before the first jobs are finished.

#

Since the system has no clue that it has any dependency

viral sonnet
#

i expect it to crash and burn 😄

#

yep, it's crashing and burning. seems it doesn't figure it out (as expected)

solemn hollow
#

then use the attribute and it should work

viral sonnet
#

i already do

solemn hollow
#

0.o must work then

#

do you Update the System dependencies when you schedule the jobs?

#

like : Dependency = job.Schedule(Dependency);

rotund token
solemn hollow
#

yah i worded that badly :S

rotund token
#

Individual jobs do not get their own handle, the system just has s single dependency which is based off all queries and GetX operational used it

solemn hollow
#

thats why you need to do this "Dependency = job.Schedule(Dependency);" too

rotund token
#

As for the attributes, update before /after they actually do nothing except choose the order the systems update

solemn hollow
#

thanks for clarifing tertle. im bad at explaining stuff ^^

rotund token
#

Unless you're using simple dependency mode, a system that updates later is only passed a previous dependency if it needs it because of a component

#

And this is what makes read and read write definitions important

#

But yeah you covered that 👍

solemn hollow
#

i hope poor enzi isnt too confused now 🙂

rotund token
#

His problem is sharing containers right

#

Which is just not handled by dependency system automatically without some magic

solemn hollow
#

i understood it more as a job dependency problem. i think he got the containers covered

#

if he needs to manually pass the containers between systems then it wouldnt rly matter much to also pass the handles i guess

solemn hollow
viral sonnet
rotund token
#

Systems have no inherit dependency from order, just that the jobs scheduled first

#

Dependency is driven by queries

rotund token
solemn hollow
#

okay so [UpdateAfter] wont work for enzi. i see...

#

im just lucky all my systems have queries i guess

viral sonnet
#

i have to say, even ifit woukd work with just updateaftet and Dependency. the code gets horrible and loses a lot if intent that is visible through jobhandles. like I would be the only one who knew the real dependencies.

#

thanks! and you never share handles between systems tertle? i know of your dislike of systems being dependent on each other. maybe i just need to merge them all i to 1

rotund token
#

I don't mind systems within its own library being dependent on each other

solemn hollow
viral sonnet
#

i actually wanted to write a tool for that some time ago 😃

solemn hollow
#

i think i read somewhere that unity had done this in an internal hackathon. just never released it :S

drowsy pagoda
#

I just realized I'm still on Burst 1.6.6 (default dependency when setting up DOTS). I see latest stable release is 1.7.3, I would like to update, but before I do, can I get some input on whether I should[n't] do it and why?

rotund token
#

1.6.6 is actually reasonably new

#

but you should upgrade to 1.7.2+ as it fixes some critical issues

#

its mostly stability and compiling performance improvements

solemn hollow
#

i updated to 1.7.2 2 days ago and can confirm its faster for me

drowsy pagoda
#

Ok Awesome, thanks for tip

viral sonnet
#

i heard 1.8 has a caching bug. am i misremembering or did 1.7 had the same bug?

rotund token
#

its fixed in 1.7.2

viral sonnet
#

very cool, need to update myself then

rotund token
#

1.8 was out before 1.7.2

#

so it hasnt been fixed in that yet

#

i really dislike writing code that works with simd

#

makes it all so much more gross

#

but the benefits...

viral sonnet
#

yep, i can relate

#

its like putting your hands behind your back to scratch your nose. but yeah the benefits are just massive

rotund token
#
[ReadOnly] 
public NativeArray<StatSchema> StatSchemas;

[NativeDisableContainerSafetyRestriction] 
private NativeArray<StatModifier> statModifiers;

using (new ProfilerMarker("CalculateModifiedValue").Auto())
{
    for (var index = 0; index < stats.Length; index++)
    {
        var schema = this.StatSchemas[index];
        var modifier = this.statModifiers[index];
        var value = schema.CalculateModifiedValue(modifier);

        stats[index] = new Stat { Value = value };
    }
}```
#
[ReadOnly]
public NativeArray<float> Mins;
 
[ReadOnly]
public NativeArray<float> Maxs;
 
[ReadOnly]
public NativeArray<int> BaseValues;
 
[NativeDisableContainerSafetyRestriction] 
private NativeArray<int> added;

[NativeDisableContainerSafetyRestriction] 
private NativeArray<float> increased;

[NativeDisableContainerSafetyRestriction]
 private NativeArray<float> reduced;
 
[NativeDisableContainerSafetyRestriction] 
private NativeArray<float> more;

[NativeDisableContainerSafetyRestriction] 
private NativeArray<float> less;

var mins = this.Mins.Reinterpret<float4>(UnsafeUtility.SizeOf<float>());
var maxs = this.Maxs.Reinterpret<float4>(UnsafeUtility.SizeOf<float>());
var baseValues = this.BaseValues.Reinterpret<int4>(UnsafeUtility.SizeOf<int>());

var addeds = this.added.Reinterpret<int4>(UnsafeUtility.SizeOf<int>());
var increaseds = this.increased.Reinterpret<float4>(UnsafeUtility.SizeOf<float>());
var reduceds = this.reduced.Reinterpret<float4>(UnsafeUtility.SizeOf<float>());
var mores = this.more.Reinterpret<float4>(UnsafeUtility.SizeOf<float>());
var lesss = this.less.Reinterpret<float4>(UnsafeUtility.SizeOf<float>());

var stats4 = stats.Reinterpret<float4>(UnsafeUtility.SizeOf<Stat>());

using (new ProfilerMarker("CalculateModifiedValue2").Auto())
{
    for (var index = 0; index < baseValues.Length; index++)
    {
        var min = mins[index];
        var max = maxs[index];
        var baseValue = baseValues[index];

        var added = baseValue + addeds[index];
        var additive = 1 + increaseds[index] - reduceds[index];
        var multiplicative = mores[index] * lesss[index];

        var value = math.clamp(added * additive * multiplicative, min, max);

        stats4[index] = value;
    }
}```
#

but the benefits 😦

#

0.74 -> 0.21

viral sonnet
#

ah yeah, the expected 4x speedup

#

total clusterfuck to read. no wonder simd experts say, write the algorithm until it's stable, then vecorize.

#

well, it's much better on desktop to read. was on mobile before haha

#

oh, cool you did something I wanted to test some time ago. pack all into type4 but I missed that reinterpret exists so the code was a mess. pretty cool that this works!

rotund token
#

reformatted before/after

viral sonnet
#

ah you did the other way around. reinterpret from float to float4. even better

rotund token
#

3.11x the lines of code for a 3.52x performance increase

#

code to performance value

viral sonnet
#

nearl 1:1! haha

#

now I'm back at my desktop, taking another stab at the jobhandles. are you sharing any jobhandles for ISystem in your events repo? Was for something different, right?

rotund token
#

it shares the handle

#

let me show you the magic

#

again this is likely way more complex than you need

#
public struct Writing : ISystem
{
    private EventProducer<int> producer;

    public void OnCreate(ref SystemState state)
    {
        this.producer = state.World.GetExistingSystem<EventSystem>().RegisterProducer<int>();
    }

    [BurstCompile]
    public void OnUpdate(ref SystemState state)
    {
        var writer = this.producer.CreateWriter();
        // pass to job, do stuff
        this.producer.AddJobHandle(state.Dependency);
    }```
#
public struct Reading : ISystem
{
    private EventConsumer<int> consumer;

    public void OnCreate(ref SystemState state)
    {
        this.consumer = state.World.GetExistingSystem<EventSystem>().RegisterConsumer<int>();
    }

    [BurstCompile]
    public void OnUpdate(ref SystemState state)
    {
        state.Dependency = this.consumer.GetReaders(state.Dependency, out UnsafeReadArray<NativeEventStream.Reader> readers);
        // pass to job, do stuff
        this.consumer.AddJobHandle(state.Dependency);
    }```
#

pass in the handle at end of writing, and read it beginning of reading

#

(its returning UnsafeReadArray because you can have multiple writers, this is an event system after all)

viral sonnet
#

cool thanks! i can figure out the rest

rotund token
#

are you passing from ISystem to ISystem?

#

if so you can just access the other system in the OnUpdate

viral sonnet
#

that's the plan. oh really? i thought i can't get an isystem

rotund token
#

SystemRef<Writing> writing = state.WorldUnmanaged.GetExistingUnmanagedSystem<Writing>();

rustic rain
#

Oof

#

Black magic happening here I see

viral sonnet
#

ohhhh 😄

#

this is what I've been looking for

rustic rain
#

What's the purpose of all that low lvl stuff?

rotund token
#

that basically gets you the pointer to the system

viral sonnet
#

in my case i want to share some jobhandles around

rustic rain
#

Sometimes I wish we could just have publicizer for production

#

So many annoying internals privates protected...

viral sonnet
#

can the SystemRef be cached too in OnCreate?

rotund token
#

never tried

#

i've never used this api actually i just know it exists

#

i'm only really heavily using ISystem for my current library i'm working on

#

I love how pure it makes my code

gentle harness
#

I'm trying to use material overrides with Hybrid v2 but the MaterialProperty attribute doesn't exist for me

#

These attributes do not exist

#

Namespaces:

using Unity.Burst;
using Unity.Collections;
using Unity.Entities;
using Unity.Jobs;
using Unity.Mathematics;
using Unity.Transforms;
using UnityEngine.InputSystem;
using Unity.Rendering.HybridV2;```
devout prairie
rotund token
#

Nope

#

From memory it won't/can't simd slices but I was going to confirm this shortly anyway, just have no power atm due to electrical work

devout prairie
#

ie it won't pack everything into float4's etc

#

?

rotund token
#

How could it?

#

I'm giving it float float int structs

#

Not like it can magically jump out of my job and rewrite my code for me

#

Best it could do is use slice

#

Now it's not certain I need to reinterpret to float4 etc

#

I could maybe keep it in float and burst would figure that out - it's just easier to confirm I haven't missed something if I convert it myself.

#

But yeah the big issue is the original struct layout

#

And breaking the struct into seperate arrays

devout prairie
#

yeah that's interesting.. i guess i thought maybe when it compiles, it would break up the struct and maybe even reinterpret as float4's etc

rotund token
#

It can do the reinterpret bit itself under certain circumstances

devout prairie
#

i didn't realise Reinterpret actually did that btw, nice bit of code 🙂

#

You've achieved a 3x speedup which is pretty significant on top of what burst&ecs can already do

rotund token
gentle harness
viral sonnet
misty wedge
#

I'm still training my transformer network so that one day it can tell me what line of code I should type next...

viral sonnet
#

does ecb already work in ISystem?

misty wedge
#

Why wouldn't it?

rotund token
#

ecb works

#

ecbs does not

misty wedge
#

Have any of the existing "default" ECS systems been converted to use ISystem?

viral sonnet
#

wait, I don't know what you mean with the plural 🙂 ecb from EndSimulationEntityCommandBufferSystem doesn't seem to work, correct?

misty wedge
#

I think he meant EntityCommandBufferSystem, not the plural of ECB

viral sonnet
#

ok 🙂 hm, that makes things a bit more difficult

#

it's pretty nice that packages as dependency now show up but is there also a way to update them to a newer version without editing the manifest file?

rotund token
viral sonnet
#

nah, I mean showing up like that

#

that wasn't the case in 2020.3 but I didn't find a way to change the version. (wanted to update burst and had to do it through manifest)

rotund token
#

oh yep

#

hmm, i could always update dependencies though

#

it didnt have that nice text there though

#

yeah 2020.3, mathematics is only a dependency and not in manifest but could be updated separately

#

i'm not going insane

viral sonnet
#

haha, sorry 🙂 so this is a regression because the ability to change versions is now gone :/

rotund token
#

oh yeah in 2021 just completely hides most package updates

#

it's super annoying

#

even when show preview packages is selected a lot don't show

#

there needs to be a new, show super preview packages option

misty wedge
#

Did you try the konami code yet? I think that's where the packages are hiding...

viral sonnet
rotund token
#

that test it was all 512 elements

#

on 10,000 entities

viral sonnet
#

huh, what's your underlying data structure? buffers?