Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice

Question Trying to get DOTS occlusion working, sample won't work as described

Discussion in 'Data Oriented Technology Stack' started by aganm, Apr 6, 2022.

  1. aganm

    aganm

    Joined:
    Sep 25, 2019
    Posts:
    114
  2. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,415
    mentioned on discord but you might miss that
    I loaded it up and it seemed to work fine


    Unity: 2020.3.30f1
    Entities: 0.50.0-p24
    Hybrid Renderer: 0.50.0-p24
    HDRP: 10.8.1

    I did not try URP
     
    Last edited: Apr 6, 2022
  3. aganm

    aganm

    Joined:
    Sep 25, 2019
    Posts:
    114
    Thanks, opening the scene in a new project worked for both URP and HDRP.

    Now the issue is getting occlusion to work in my own scenes, and I'm getting out of range exception errors when I put more than 1529 mesh objects in my scene (subscene or not, same problem) :


    IndexOutOfRangeException: Index -82 is out of range of '33' Length.
    Unity.Collections.NativeArray`1[T].FailOutOfRangeError (System.Int32 index) (at <3be1a7ff939c43f181c0a10b5a0189ac>:0)
    Unity.Collections.NativeArray`1[T].CheckElementReadAccess (System.Int32 index) (at <3be1a7ff939c43f181c0a10b5a0189ac>:0)
    Unity.Collections.NativeArray`1[T].get_Item (System.Int32 index) (at <3be1a7ff939c43f181c0a10b5a0189ac>:0)
    Unity.Rendering.Occlusion.MOCTestJob.Execute (Unity.Entities.ArchetypeChunk chunk, System.Int32 chunkIndex, System.Int32 firstEntityIndex) (at Library/PackageCache/com.unity.rendering.hybrid@0.50.0-preview.24/Unity.Rendering.Hybrid/Occlusion/BurstIntrinsics/MOCTestJob.cs:83)
    Unity.Entities.JobChunkExtensions+JobChunkProducer`1[T].ExecuteInternal (Unity.Entities.JobChunkExtensions+JobChunkWrapper`1[T]& jobWrapper, System.IntPtr bufferRangePatchData, Unity.Jobs.LowLevel.Unsafe.JobRanges& ranges, System.Int32 jobIndex) (at Library/PackageCache/com.unity.entities@0.50.0-preview.24/Unity.Entities/IJobChunk.cs:401)
    Unity.Entities.JobChunkExtensions+JobChunkProducer`1[T].Execute (Unity.Entities.JobChunkExtensions+JobChunkWrapper`1[T]& jobWrapper, System.IntPtr additionalPtr, System.IntPtr bufferRangePatchData, Unity.Jobs.LowLevel.Unsafe.JobRanges& ranges, System.Int32 jobIndex) (at Library/PackageCache/com.unity.entities@0.50.0-preview.24/Unity.Entities/IJobChunk.cs:368)
     
  4. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    1,576
  5. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,415
    If anyone is interested, I debugged the the above error.

    HybridV2Culling can give StartIndex a negative value



    Fix

    HybridV2Culling - line 419 remove the cast to short
    HybridV2RenderSystem - line 827 change StartIndex to int

    I do not know if there will be consequences I haven't tested it enough to be certain but it seems to work. (At the very least this struct should be reordered for memory)

    250k cubes


    Performance is great
     
    Last edited: Apr 6, 2022
  6. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    1,576
    That borg cube! :D
     
    apkdev likes this.
  7. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    1,576
    So, I got culling enabled in my voxel test scenes and played around with it. Given a hollow cube with quad meshes on all 6 sides it doesn't actually occlude that much even though it could exclude at least all of the backsides. Perhaps the algorithm is very conservative, or was simply seeing through my meshes which are essentially a front and a back quad some distance apart - maybe the system was "seeing through the gaps" despite the meshes perfectly aligning visually.

    I also made a test with an occluder wall, hiding the entire cube. It did occlude it entirely, but nevertheless I see a significant drop in framerate due to the number of occlusion tests alone. It simply doesn't matter if a couple more or less meshes are rendered.

    I conclude that for occlusion to make sense you have to be able to occlude rather complex meshes, as opposed to my tests where I have thousands of extremely simple meshes, each of which also acts as occluder too.

    Also, for a voxel world it's fairly trivial to write your own occlusion system that does far fewer computations due to the numerous assumptions you can make about the world and the sizes and orientation of meshes and so on.
     
  8. linfuqing

    linfuqing

    Joined:
    May 11, 2015
    Posts:
    155
    Will support android arm in 0.50.1?
     
  9. BigRookGames

    BigRookGames

    Joined:
    Nov 24, 2014
    Posts:
    325
    Tertle, you are a godsend. You know everything about everything. The patch works great for now. Thank you