#Set Entity to semi-transparent

1 messages · Page 1 of 1 (latest)

manic ledge
#

Is that very easy now to set entity to become semi-transparent and then back to original opaque back and forth that I can just set a Entities Graphics built-in component to achieve it? At game object land it's not easy to achieve it that require quite amount of code and setup

little sluice
#

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.

manic ledge
little sluice
#

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.

manic ledge
little sluice
#

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 RenderMeshArray shared component, you can use an array index that selects the corresponding Material from that array.
  • You can put a BatchMaterialID directly inside the MaterialMeshInfo component. You can get one by calling EntitiesGraphicsSystem.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.

manic ledge
little sluice
#

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.

elfin falcon
#

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.

little sluice
#

Sorting Layers are currently not supported with BatchRendererGroup, which Entities Graphics uses. Layers and Rendering Layers should be supported though.

elfin falcon
#

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.

little sluice
#

DepthSorted_Tag should be automatically added during baking to Entities with a Material whose Surface Type is Transparent.

elfin falcon
#

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

little sluice
#

That is definitely odd, it might be some kind of bug.

elfin falcon
#

Where is the recommended channel to report something like this, discord/forum/other?