Ghost - Rendermesh only on Client

When looking through the manual Ghost snapshots | Unity NetCode | 0.6.0-preview.7

It states under “Ghost snapshots”

How does one actually accomplish this?

If Ghost Authoring Component could be edited it would be as easy as unchecking a checkbox, but it doesn’t work.
7480786--919931--upload_2021-9-8_15-29-36.png

Next thing I tried was creating a ghostVariant for the type RenderMesh.

[GhostComponentVariation(typeof(RenderMesh), "ClientOnlyRender")]
[GhostComponent(PrefabType = GhostPrefabType.Client, OwnerPredictedSendType = GhostSendType.All, SendDataForChildEntity = true)]
public struct RenderMeshClientOnly
{
    [GhostField] public Mesh mesh;
    [GhostField] public Material material;
    [GhostField] public int subMesh;
    [GhostField] public int layer;
    [GhostField] public ShadowCastingMode castShadows;
    [GhostField] public bool receiveShadows;
    [GhostField] public bool needMotionVectorPass;
}

But when compiling it throws an error that GhostVariationComponents need to be a struct and implement IComponentData, however, RenderMesh is an ISharedComponentData, so I can’t seem to create a variation either?

ArgumentException: Invalid component type {type}. Must be a struct and implements IComponentData. System.MonoCustomAttrs.GetCustomAttributesBase (System.Reflection.ICustomAttributeProvider obj, System.Type attributeType, System.Boolean inheritedOnly) (at <9577ac7a62ef43179789031239ba8798>:0) System.MonoCustomAttrs.GetCustomAttributes (System.Reflection.ICustomAttributeProvider obj, System.Type attributeType, System.Boolean inherit) (at <9577ac7a62ef43179789031239ba8798>:0) System.RuntimeType.GetCustomAttributes (System.Type attributeType, System.Boolean inherit) (at <9577ac7a62ef43179789031239ba8798>:0) System.Attribute.GetCustomAttributes (System.Reflection.MemberInfo element, System.Type type, System.Boolean inherit) (at <9577ac7a62ef43179789031239ba8798>:0) System.Attribute.GetCustomAttribute (System.Reflection.MemberInfo element, System.Type attributeType, System.Boolean inherit) (at <9577ac7a62ef43179789031239ba8798>:0) System.Attribute.GetCustomAttribute (System.Reflection.MemberInfo element, System.Type attributeType) (at <9577ac7a62ef43179789031239ba8798>:0) System.Reflection.CustomAttributeExtensions.GetCustomAttribute (System.Reflection.MemberInfo element, System.Type attributeType) (at <9577ac7a62ef43179789031239ba8798>:0) System.Reflection.CustomAttributeExtensions.GetCustomAttribute[T] (System.Reflection.MemberInfo element) (at <9577ac7a62ef43179789031239ba8798>:0) Unity.NetCode.GhostAuthoringModifiers.InitVariantCache () (at Library/PackageCache/com.unity.netcode@0.6.0-preview.7/Runtime/Authoring/Hybrid/GhostAuthoringModifiers.cs:99) Unity.NetCode.GhostAuthoringModifiers…cctor () (at Library/PackageCache/com.unity.netcode@0.6.0-preview.7/Runtime/Authoring/Hybrid/GhostAuthoringModifiers.cs:43) Rethrow as TypeInitializationException: The type initializer for ‘Unity.NetCode.GhostAuthoringModifiers’ threw an exception.

Am I supposed to pull the HDRP Package in locally, so that I can add [GhostComponent(PrefabType=GhostPrefabType.Client)] to the actual definition itself?

Am I just missing the easy solution? How would one go about not rendering the ghost’s visuals on the server?

I don’t think there is an easy solution for it right now. Unchecking the checkbox would be the easy solution - but there is a bug with the checkboxes.

I would like to point out two things though:

  1. The server will not render anything even if those components are there because we are not running the rendering systems. You could of cause save some memory and/or binary size by removing them so it might still be useful, but it will not save CPU time and it will not change the funcitonallity.
  2. Those checkboxes will only remove the meshes from ghosts. What you actually want to do is to remove all rendering resources from your server build for everything, gosts and non-ghosts alike. We have been looking at doing that by preventing conversion systems from the rendering assemblies to run when building server. I cannot say right now when that will be available in a public version though.
1 Like

Thank you for the reply! @CMarastoni mentioned in this thread : https://discussions.unity.com/t/848941 that we are able to strip the RenderMesh by using the IGhostDefaultOverrides? Do you happen to have any samples for this regarding the RenderMesh?

In that thread he also mentioned that exluding the Hybrid renderer assemblies from the Server build configuration will not generate dependencies for hybrid rendering related entities for the server build. Is this equal to point 2 you made? or is that just a part of it?

It might be possible to get something working with IGhostDefaultOverrides (Interface IGhostDefaultOverridesModifier | Unity NetCode | 0.6.0-preview.7) by registering the component in void Modify(Dictionary<string, GhostComponentModifier> overrides) setting overrides["Unity.Rendering.RenderMesh"] to a GhostComponentModifier which has the attribute you want. I have not actually checked if that works with shared components though.
Be aware that if you use that the code will break in a future as our internal versions no longer have that override system.

exluding the Hybrid renderer assemblies from the Server build

yes, that’s what I was talking about in 2

@timjohansson Do u mean the ability to strip specified assemblies from build? I would like to able to strip some assemblies from client build and another assemblies from server build.

Hi, is there / will there be a replacement for IGhostDefaultOverrides (or a way to achieve similar results)? I find this feature useful.

I’m talking about skipping the data conversion for some assemblies, not skipping the assemblies themselves. The goal is to remove meshes and textures.
For assemblies you control you can add define constraints to the asmdef files to remove the assemblies, assemblies with define constraint !UNITY_SERVER will be excluded from server build for example. You have to use the negative versions otherwise nothing gets built in the editor or client & server builds.

Yes, we are aiming to keep the functionality, but the way you express it will be completely different. I am not sure if the feature set will be 100% identical, but the replacement has at least covered what we use it for internally.

1 Like

Hey @timjohansson , sorry for hijacking this thread but you still seem to be active here.
Can you tell us what’s going on with DOTS / or why nobody can speak about DOTS?

A lot of us who got into DOTS were left hanging in limbo,
not knowing if we should spend more time on our DOTS projects or not.

I’ve been an early adopter too, convincing quite a lot of people of the benefits of DOTS/ECS.
Nobody is sure anymore.

You guys make it a bit difficult for us to trust in the tech if nobody is willing to talk to the community anymore, and the community is not allowed to ask anymore :slight_smile:

3 Likes

@mischa2k Just out of curiosity, did you see the March 2022 update in the parent channel? https://discussions.unity.com/t/874964
Highly recommend it to maybe help alleviate concerns.

This really resonated with me, as I joined Unity because I share your excitement for DOTS. I can say that active development continues, and we fully believe in the mission, objectives, and promises (and are seeing more and more concrete success stories). We unfortunately can’t share too much, and we acknowledge and agree with you in regards to the difficulties we’ve had with communication.

Feel free to ping these DOTS forums with specific queries too.

Already did, but it’s always the same :slight_smile:

At Unite, all the Unity folks go out of their way to answer questions, everyone is super polite and nice.
Yet on the internet, it seems we are annoying you with questions about the tech that you asked us to adopt.