#Set Entity to semi-transparent
1 messages · Page 1 of 1 (latest)
The semi-transparent-ness of Entities is determined based on the Material's "Surface Type" setting, just as with GameObjects. In addition, with Entities, semi-transparent Entities should have the DepthSorted_Tag tag component to ensure that they are sorted by depth when rendering, unless the user explicitly wishes to disable this behavior. Entities Graphics automatically adds DepthSorted_Tag when baking Entities, if the source Material is transparent.
The easiest way to toggle an Entity between opaque and semi-transparent is to change its Material by changing its MaterialMeshInfo component. Optionally, the DepthSorted_Tag can be added or removed when switching. This causes a structural change to happen when adding or removing the tag, but opaque Entities will render faster if they don't have the tag.
Change material do u mean create 1 semi-transparent material and 1 opaque material and then swap it back and forth? For DepthSorted_Tag, can u make it as Enableable component at next new release?
Yes, that's right. We will definitely consider implementing Enableable support for DepthSorted_Tag, but I can't promise that it will be in the next new release.
🤔 If I understand I still need to use Material which is managed component to do it? Did official have any plan to implement a dots Material unmanaged component?
MaterialMeshInfo is an unmanaged component. It uses integers to refer to Materials, so that you don't need to use managed Materials.
Specifically, it supports two kinds of integers:
- If the Entity also has a
RenderMeshArrayshared component, you can use an array index that selects the corresponding Material from that array. - You can put a
BatchMaterialIDdirectly inside theMaterialMeshInfocomponent. You can get one by callingEntitiesGraphicsSystem.RegisterMaterial(Material material).
So it's possible to modify the material using unmanaged Burst code, but setting up the RenderMeshArray or calling RegisterMaterial still needs to happen from managed code. However, this can typically be done up front and doesn't have to be done all the time.
I see but is there any plan to make setting up the RenderMeshArray or calling RegisterMaterial burst conpatible in future?
This is definitely something that we would like to support in the future, but there are no current plans when that would be.
If you have a use case where the current approach is not feasible, I would be very interested to hear about it so we can make sure to take it into account in the future.
What's odd, is that I asked about this multiple times in #archived-dots , in particular about how sorting layers and layers don't seem to matter in a 2D world at all, and results are seemingly random. Just today I was looking through the library trying to find a solution to this as Z index stopped mattering in 1.0 release for transparency. I found that it appears DepthSorted_Tag is supposed to be added if material is transparent, but hadn't been. So I manually added it and everything was working as intended again. Came here to post comment on my previous posts so anyone with a similar issue can find the solution, and I see this post created earlier today. Weird timing.
Sorting Layers are currently not supported with BatchRendererGroup, which Entities Graphics uses. Layers and Rendering Layers should be supported though.
I haven't found it to consistently work, only thing that I was able to use as a workaround previously was altering a materials RenderQueue/sorting priority. This DepthSorted_Tag though, has allowed me to at least sort layers by Z index again.
DepthSorted_Tag should be automatically added during baking to Entities with a Material whose Surface Type is Transparent.
It should, but it does not
{
list.Add(ComponentType.ReadWrite<DepthSorted_Tag>());
}```
I have made a few different attempts and verified that it is seeing the material as Shader.PropertyToID("_Surface"); to be true, but it appears to not automatically add
That is definitely odd, it might be some kind of bug.
Where is the recommended channel to report something like this, discord/forum/other?