Hybrid Renderer doesn't render objects past ~ - 32785 units in X direction

Hi,

I found a very weird issue with the Hybrid Renderer. It will not render objects that are more than ~ -32785 units away from the center of the scene on the X-axis. There are no problems with any other axis.

Here are the scripts that I used:

Script for making prefab entities:

using Unity.Entities;

namespace UnityTemplateProjects
{
    [GenerateAuthoringComponent]
    public struct PrefabsEntityComponent:IComponentData
    {
        public Entity Prefab;
    }
}

Script for spawning entities:
```csharp
*using Unity.Collections;
using Unity.Entities;
using Unity.Mathematics;
using Unity.Transforms;

namespace UnityTemplateProjects
{
public class PrefabSpawnerSystem:ComponentSystem
{
private bool _spawned = false;

    protected override void OnUpdate()
    {
        if (_spawned) return;
        var treesPrefabs = GetSingleton<PrefabsEntityComponent>();
        var objects = EntityManager.Instantiate(treesPrefabs.Prefab, 128 * 128, Allocator.TempJob);


        for (int y = 0; y < 128; y++)
        {
            for (int x = 0; x < 128; x++)
            {
                EntityManager.SetComponentData(objects[ y * 128  + x], 

new Translation{Value = new float3(-(y * 128 + x) * 5, 0, 0)}); //Here is a problem at ~ -32785
//EntityManager.SetComponentData(objects[ y * 128 + x], new Translation{Value = new float3((y * 128 + x) * 5, 0, 0)}); // X Right - Fine
//EntityManager.SetComponentData(objects[ y * 128 + x], new Translation{Value = new float3(0, 0, (y * 128 + x) * 5)}); // Z Forward - Fine
//EntityManager.SetComponentData(objects[ y * 128 + x], new Translation{Value = new float3(0, 0, -(y * 128 + x) * 5)}); // Z Backward - Fine
//EntityManager.SetComponentData(objects[ y * 128 + x], new Translation{Value = new float3(0, -(y * 128 + x) * 5, 0)}); //Y Down - Fine
//EntityManager.SetComponentData(objects[ y * 128 + x], new Translation{Value = new float3(0, (y * 128 + x) * 5, 0)}); //Y Up - Fine
}
}

        objects.Dispose();
        _spawned = true;
    }
}

}*
```

6685822--766648--Screenshot_3.png

Does anyone know how to fix this?

Thank you in advance.

Aren't you supposed to set positions inside a ForEach using the Entities-loop approach?

[edit] Also 32-bit float imprecision at longer distances from the origo could be an issue.

The position is set only during the instancing phase and irrelevant in this case.

32-bit precision could result in shaking behavior or blinking or anything else. In this case, it just stops rendering past a certain point and only in the negative direction of the X-axis.

In the code, there are commented lines which I checked for other directions and they are fine for more than 80000 in each direction. And from the project that I am working on, I can tell with confidence that up to 100000 units in each direction there is no problem with floating-point precision.

There has to be some sort of bug with the Hybrid Renderer.

1 Like

I am not arguing against the potential bugs in the Hybrid Renderer, but I have tested it myself as well now for the Parametric Object Creator I posted in another thread, and after tweaking the shaders a bit I never had any issues with things not being rendered (within +/- 9999 units of origo). It's so far seemingly only been a shader-issue for me unless I goof'd with the generation code and forgot to write the correct data to the meshes.


So you haven't tested placing objects at Vector3(32785,0,0) position and checking if they are rendered by the Hybrid Renderer?


No, I only place within +/-9999 units from Origo because I am rather paranoid about floating point imprecision.

(Sorry it seems I left that out.)

Would it be possible for you to submit a bug report with a repro project about this?

Already did, the ticket number is: 1303485

May I ask, why you trying to render something beyond 10k distance?

This is a range where loosing precision start causing issues as mentioned earlier.
Camera and physics can become jittery and things start glithing out.

You should bring anything visually related, below 10k range (abs).
If you must, use shift origin approach.

As mentioned before, there are no issues with precision loss at those distances. And I am telling this based on my experience. There is no physics in my game, so I don't have to worry about that. As to everything else I don't see any problems so far.

The shift origin approach results in frame rate stuttering, the moment origin shifts is quite noticeable as you have to move every object in the scene in one frame.

As to "Why?" - this is irrelevant in this case. I expect the Renderer to behave the same regardless of where the object is placed. Think of this example: You can place objects in any position in the scene but not at (-500, 0, 0) as there it would not be rendered - would such behavior would be ok or this would be a bug?

3 Likes

I have also come across this issue using hybrid renderer version 0.10.0-preview.21

It looks like a fix is in review for version 0.12.0-preview.36 :)
https://issuetracker.unity3d.com/issues/hybrid-renderer-does-not-render-entities-past-32785-units-on-the-x-axis

This issue should be fixed in the latest published version of Hybrid Renderer, 0.11.0-preview.44


Confirming, the issue is fixed.

But a serious bug about LOD in 0.11.0-preview.44,see https://discussions.unity.com/t/842495
Recommended keep 0.11.0-preview.42

[quote=“linfuqing”, post:14, topic: 822983]
But a serious bug about LOD in 0.11.0-preview.44,see https://discussions.unity.com/t/842495
Recommended keep 0.11.0-preview.42
[/quote]
True, that bug is killing me.