Skip to content

HDRP support #105

Open
Open

Description

@unitycoder

not included in the asset store package yet, but can try this: (2019.4.19f1 + HDRP 7.1.8, for V1/V2 viewer (not v3 tiles viewer))

  • project window right click, Create/Rendering/C# Custom pass
  • main camera: Add Component, Custom Pass Volume
  • Select some injection point (try which one works the best)
  • Add your Custom pass with + button
  • image
  • Modify PointCloudViewerDX11.cs
  • Add line: public static PointCloudViewerDX11 instance;
  • Add line inside Awake(): instance = this;
  • Use custom pass script below
  • Test!

Custom pass script:

using UnityEngine;
using UnityEngine.Rendering.HighDefinition;
using UnityEngine.Rendering;

class NewCustomPass : CustomPass
{
    protected override void Setup(ScriptableRenderContext renderContext, CommandBuffer cmd)
    {
        // Setup code here
    }

    protected override void Execute(ScriptableRenderContext renderContext, CommandBuffer cmd, HDCamera camera, CullingResults cullingResult)
    {
        if (unitycodercom_PointCloudBinaryViewer.PointCloudViewerDX11.instance == null) return;
        cmd.DrawProcedural(Matrix4x4.identity, unitycodercom_PointCloudBinaryViewer.PointCloudViewerDX11.instance.cloudMaterial, 0, MeshTopology.Points, unitycodercom_PointCloudBinaryViewer.PointCloudViewerDX11.instance.points.Length);
        renderContext.ExecuteCommandBuffer(cmd);
    }

    protected override void Cleanup()
    {
        // Cleanup code
    }
}

Activity

  1. unitycoder commented on Feb 7, 2021

    @unitycoder
    OwnerAuthor

    for 2020.2.2f1 + HDRP 10.2.2
    same process as above, custom pass script is bit different:

    New Custom Pass.cs

    using UnityEngine;
    using UnityEngine.Rendering.HighDefinition;
    using UnityEngine.Rendering;
    
    class NewCustomPass : CustomPass
    {
        protected override void Setup(ScriptableRenderContext renderContext, CommandBuffer cmd)
        {
        }
    
        protected override void Execute(CustomPassContext ctx)
        {
            if (unitycodercom_PointCloudBinaryViewer.PointCloudViewerDX11.instance == null) return;
            ctx.cmd.DrawProcedural(Matrix4x4.identity, unitycodercom_PointCloudBinaryViewer.PointCloudViewerDX11.instance.cloudMaterial, 0, MeshTopology.Points, unitycodercom_PointCloudBinaryViewer.PointCloudViewerDX11.instance.points.Length);
        }
    
        protected override void Cleanup()
        {
        }
    }
    
  2. unitycoder commented on Oct 21, 2021

    @unitycoder
    OwnerAuthor

    Just tested this with Unity XR + Oculus, works with HDRP+VR also.

  3. unitycoder commented on Mar 10, 2022

    @unitycoder
    OwnerAuthor

    for Unity 2020.3.21f1 + HDRP 10.6.0 and V3 tiles viewer:

    • project window right click, Create/Rendering/C# Custom pass
    • main camera: Add Component, Custom Pass Volume
    • Select some injection point (try which one works the best)
    • Add your Custom pass with + button (its listed on that drop down menu)
    • Modify PointCloudViewerTilesDX11.cs, add these changes:
    // BEFORE
    PointCloudTile[] tiles;
    // AFTER
    internal PointCloudTile[] tiles;
    // BEFORE
    int tilesCount = 0;
    // AFTER
    internal int tilesCount = 0;
    // BEFORE
            void Awake()
            {
                applicationStreamingAssetsPath = Application.streamingAssetsPath;
                FixMainThreadHelper();
            }
    // AFTER
            public static PointCloudViewerTilesDX11 instance;
            void Awake()
            {
                instance = this;
                applicationStreamingAssetsPath = Application.streamingAssetsPath;
                FixMainThreadHelper();
            }
    // BEFORE
    public void OnRenderObject()
    // AFTER
    public void DisabledOnRenderObject()
    

    New Custom PassV3.cs: (or which ever you named it)

    using UnityEngine;
    using UnityEngine.Rendering.HighDefinition;
    using UnityEngine.Rendering;
    using UnityEngine.Experimental.Rendering;
    using unitycodercom_PointCloudBinaryViewer;
    
    class NewCustomPassV3 : CustomPass
    {
        // It can be used to configure render targets and their clear state. Also to create temporary render target textures.
        // When empty this render pass will render to the active camera render target.
        // You should never call CommandBuffer.SetRenderTarget. Instead call <c>ConfigureTarget</c> and <c>ConfigureClear</c>.
        // The render pipeline will ensure target setup and clearing happens in an performance manner.
        protected override void Setup(ScriptableRenderContext renderContext, CommandBuffer cmd)
        {
            // Setup code here
        }
    
        protected override void Execute(CustomPassContext ctx)
        {
            // Executed every frame for all the camera inside the pass volume.
            // The context contains the command buffer to use to enqueue graphics commands.
            if (PointCloudViewerTilesDX11.instance == null) return;
    
            for (int i = 0, len = PointCloudViewerTilesDX11.instance.tilesCount; i < len; i++)
            {
                if (PointCloudViewerTilesDX11.instance.tiles[i].isReady == false || PointCloudViewerTilesDX11.instance.tiles[i].isLoading == true || PointCloudViewerTilesDX11.instance.tiles[i].visiblePoints == 0) continue;
                ctx.cmd.DrawProcedural(Matrix4x4.identity, PointCloudViewerTilesDX11.instance.tiles[i].material, 0, MeshTopology.Points, PointCloudViewerTilesDX11.instance.tiles[i].visiblePoints);
            }
        }
    
        protected override void Cleanup()
        {
            // Cleanup code
        }
    }
    
  4. PascalRunde commented on Oct 31, 2022

    @PascalRunde

    Will there be a version of the shader that works with instanced singlepass rendering for VR?
    Or does it already exist and I missed it somehow?
    Thanks in advance!

  5. unitycoder commented on Nov 1, 2022

    @unitycoder
    OwnerAuthor

    Ok that doesnt seem to be working.
    just tested in V3 viewer in hdrp+single pass instanced+oculus : no points rendered (multipass works).
    I'll look into it.

  6. unitycoder commented on Nov 2, 2022

    @unitycoder
    OwnerAuthor

    Ok, some progress:

    • converted PointCloudColorDX11.shader to vr+singlepass : Seems to work (tested on quest+link, hdrp 12.x)

    if you can test it, pm me in forums or send email, i'll send the shader.

    The main v2 billboard shader almost works,
    right eye has some distortion (probably related to using direct camera xyz values in shader..), still looking into that.

    *ok v2 billboard shader works also, i'll include these in the next asset store update too, hopefully later this month.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions