Open unitycoder opened 3 years ago
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()
{
}
}
Just tested this with Unity XR + Oculus, works with HDRP+VR also.
for Unity 2020.3.21f1 + HDRP 10.6.0 and V3 tiles viewer:
// 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
}
}
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!
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.
Ok, some progress:
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.
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))
public static PointCloudViewerDX11 instance;
instance = this;
Custom pass script: