Esempio n. 1
0
        private void CustomRender(ScriptableRenderContext context, HDCamera hd)
        {
            var cmd = CommandBufferPool.Get();

            void RenderPointCloud(CubemapFace face)
            {
                PointCloudManager.RenderLidar(context, cmd, hd, renderTarget.ColorHandle, renderTarget.DepthHandle, face);
            }

            RenderMarker.Begin();
            SensorPassRenderer.Render(context, cmd, hd, renderTarget, passId, Color.clear, RenderPointCloud);
            RenderMarker.End();

            ComputeMarker.Begin();
            var kernel = cs.FindKernel(Compensated ? "CubeComputeComp" : "CubeCompute");

            cmd.SetComputeTextureParam(cs, kernel, Properties.InputCubemapTexture, renderTarget.ColorHandle);
            cmd.SetComputeBufferParam(cs, kernel, Properties.Output, PointCloudBuffer);
            cmd.SetComputeBufferParam(cs, kernel, Properties.LatitudeAngles, LatitudeAnglesBuffer);
            cmd.SetComputeIntParam(cs, Properties.LaserCount, LaserCount);
            cmd.SetComputeIntParam(cs, Properties.MeasuresPerRotation, UsedMeasurementsPerRotation);
            cmd.SetComputeFloatParam(cs, Properties.AntialiasingThreshold, AntialiasingThreshold);
            cmd.SetComputeVectorParam(cs, Properties.Origin, SensorCamera.transform.position);
            cmd.SetComputeMatrixParam(cs, Properties.RotMatrix, Matrix4x4.Rotate(transform.rotation));
            cmd.SetComputeMatrixParam(cs, Properties.Transform, transform.worldToLocalMatrix);
            cmd.SetComputeVectorParam(cs, Properties.PackedVec, new Vector4(MaxDistance, DeltaLongitudeAngle, MinDistance, StartLongitudeOffset));
            cmd.DispatchCompute(cs, kernel, HDRPUtilities.GetGroupSize(UsedMeasurementsPerRotation, 8), HDRPUtilities.GetGroupSize(LaserCount, 8), 1);
            ComputeMarker.End();

            context.ExecuteCommandBuffer(cmd);
            cmd.Clear();
            CommandBufferPool.Release(cmd);
        }
Esempio n. 2
0
        public void CustomRender(ScriptableRenderContext context, HDCamera hd)
        {
            var camera = hd.camera;

            var cmd = CommandBufferPool.Get();

            // NOTE: Target setting is done in BeginReadRequest through Camera.SetTargetBuffers. Doing it through
            //       the command queue changes output slightly, probably should be debugged eventually (low priority).
            // CoreUtils.SetRenderTarget(cmd, activeTarget.colorTexture, activeTarget.depthTexture);
            hd.SetupGlobalParams(cmd, 0);

            ScriptableCullingParameters culling;

            if (camera.TryGetCullingParameters(out culling))
            {
                var cull = context.Cull(ref culling);

                context.SetupCameraProperties(camera);
                CoreUtils.ClearRenderTarget(cmd, ClearFlag.All, Color.clear);
                context.ExecuteCommandBuffer(cmd);
                cmd.Clear();

                var sorting = new SortingSettings(camera);
                var drawing = new DrawingSettings(new ShaderTagId("SimulatorLidarPass"), sorting);
                var filter  = new FilteringSettings(RenderQueueRange.all);

                context.DrawRenderers(cull, ref drawing, ref filter);
            }

            PointCloudManager.RenderLidar(context, cmd, hd, activeTarget.colorTexture, activeTarget.depthTexture);
            CommandBufferPool.Release(cmd);
        }
    public void Stamp(Frame frame, PointCloudManager points, float cameraDistance, float focalLength, bool forceSet = false)
    {
        // position cheat camera
        camera.transform.eulerAngles = new Vector3(frame.rotX, frame.rotY, frame.rotZ);
        camera.transform.position    = new Vector3(frame.posX, frame.posY, frame.posZ) + (camera.transform.up * cameraDistance);
        camera.focalLength           = focalLength;

        // load frame texture
        Texture2D texture = new Texture2D(1, 1);

        texture.LoadImage(frame.img);

        foreach (GameObject point in points.PointObjects)
        {
            Vector3 cameraPos = camera.WorldToScreenPoint(point.transform.position);
            // if a point is in view of the camera, calc where it is on the screen
            if (cameraPos.x >= 0 && cameraPos.x <= 1 && cameraPos.z >= 0 && cameraPos.z <= 0)
            {
                // assign color to point from texture
                Point pointController = point.GetComponent <Point>();
                pointController.TextureColor = texture.GetPixel(Mathf.RoundToInt(cameraPos.x * texture.width), Mathf.RoundToInt(cameraPos.y * texture.height));
                if (forceSet)
                {
                    pointController.SetColor(pointController.TextureColor);
                }
            }
        }
    }
Esempio n. 4
0
        public void CustomRender(ScriptableRenderContext context, HDCamera hd)
        {
            var cmd = CommandBufferPool.Get();

            SensorPassRenderer.Render(context, cmd, hd, activeTarget, passId, Color.clear);
            PointCloudManager.RenderLidar(context, cmd, hd, activeTarget.ColorHandle, activeTarget.DepthHandle);
            CommandBufferPool.Release(cmd);
        }
Esempio n. 5
0
    public Mesh GenerateMesh(PointCloudManager pointManager)
    {
        List <Vector3> points = new List <Vector3>();

        foreach (GameObject point in pointManager.PointObjects)
        {
            points.Add(point.transform.position);
        }
        return(GenerateMesh(points.ToArray()));
    }
        private void Start()
        {
            // use singleton from manager
            pointCloudManager = PointCloudManager.instance;

            // check separate viewer, needed if use separate cloud to show selected points
            if (createSeparateCloudFromSelection == true && tempPointCloudViewerDX11 == null)
            {
                Debug.LogError("Missing tempPointCloudViewerDX11 reference at " + gameObject.name, gameObject);
            }
        }
        void CustomRender(ScriptableRenderContext context, HDCamera hd)
        {
            var cmd = CommandBufferPool.Get();

            SensorPassRenderer.Render(context, cmd, hd, renderTarget, passId, Color.clear);
            if (!Fisheye)
            {
                PointCloudManager.RenderDepth(context, cmd, hd, renderTarget.ColorHandle, renderTarget.DepthHandle);
            }
            CommandBufferPool.Release(cmd);
        }
Esempio n. 8
0
        void Start()
        {
            // Setting User information

            WidthRes /= NrOfCameras;

            float lidarVerticalAngle = VerticalAngle;

            HeightRes     = (int)(WidthRes * Mathf.Tan(lidarVerticalAngle * Mathf.Deg2Rad / 2) / Mathf.Sin(Mathf.PI / NrOfCameras));
            VerticalAngle = Mathf.Rad2Deg * 2 * Mathf.Atan(Mathf.Tan(lidarVerticalAngle * Mathf.Deg2Rad / 2) / Mathf.Cos(Mathf.PI / NrOfCameras));

            NumberOfDepthPixels = (uint)WidthRes * (uint)HeightRes * (uint)NrOfCameras;
            NumberOfLidarPoints = (uint)NrOfLasers * (uint)LidarHorisontalRes * (uint)NrOfCameras;

            // Settup Game objects

            pointCloud = GetComponent <PointCloudManager>();
            pointCloud.SetupPointCloud((int)NumberOfLidarPoints);

            var frustum = new CameraFrustum(WidthRes, MaxDistance, MinDistance, 2 * Mathf.PI / NrOfCameras, lidarVerticalAngle * Mathf.Deg2Rad);

            depthCameras = new DepthCameras(NrOfCameras, frustum, this.transform, lidarShader, "CSMain");
            lidarCameras = depthCameras.cameras;

            projectionFilter = GetComponent <SphericalProjectionFilter>();
            projectionFilter.SetupSphericalProjectionFilter(LidarHorisontalRes, NrOfLasers, frustum);
            pixelCoordinatesBuffer = projectionFilter.filterCoordinates.buffer;

            // Setting up Compute Buffers

            kernelHandle = lidarShader.FindKernel("CSMain");

            lidarShader.SetBuffer(kernelHandle, "sphericalPixelCoordinates", pixelCoordinatesBuffer);
            lidarShader.SetInt("N_theta", LidarHorisontalRes);
            lidarShader.SetInt("N_phi", NrOfLasers);
            lidarShader.SetFloat("rayDropProbability", rayDropProbability);

            UnifiedArray <uint> RandomStateVector = new UnifiedArray <uint>(NrOfCameras * NrOfLasers * LidarHorisontalRes, sizeof(float), "_state_xorshift");

            RandomStateVector.SetBuffer(lidarShader, "CSMain");
            RandomStateVector.SetBuffer(lidarShader, "RNG_Initialize");
            RandomStateVector.SynchUpdate(lidarShader, "RNG_Initialize");

            particleUnifiedArray = new UnifiedArray <Vector3>(NrOfCameras * NrOfLasers * LidarHorisontalRes, sizeof(float) * 3, "lines");
            particleUnifiedArray.SetBuffer(lidarShader, "CSMain");

            lidarDataByte = new UnifiedArray <byte>(NrOfCameras * NrOfLasers * LidarHorisontalRes, sizeof(float) * 6, "LidarData");
            lidarDataByte.SetBuffer(lidarShader, "CSMain");
        }
 public GroundTruthGenerator(DepthRenderingManager drm, ViewManager vm, PointCloudManager pcm, OccupancyGridManager ogm, StudyObjectMamanger som, float requiredAccuracy = 0.99f)
 {
     // Save function messes up executable file, must make due without it
     _path = _basePath + "_" + vm.Count().ToString() + ".txt";
     _drm  = drm;
     _vm   = vm;
     _pcm  = pcm;
     _ogm  = ogm;
     _som  = som;
     this.requiredAccuracy = requiredAccuracy;
     //Generate(false); // Do not count tallies
     //Save();
     _grids = Load();
     CountGrids();
 }
Esempio n. 10
0
    public SystemInterface(Camera depthCamera)
    {
        //Prepare depth rendering texture
        _depthCamera = depthCamera;
        RenderTexture rTex = _depthCamera.targetTexture;

        rTex.width  = _textureResolution;
        rTex.height = _textureResolution;

        //Setup Managers
        _vm  = new ViewManager(_viewGridLayers, _sphereRadius, _numberViews);
        _som = new StudyObjectMamanger(_objectPosition);
        _drm = new DepthRenderingManager(_depthCamera, _nearClipPlane, _farClipPlane);
        _pcm = new PointCloudManager(rTex, _depthSawOff, _depthCamera);
        _ogm = new OccupancyGridManager(_occupancyGridCount, _studyGridSize, _gridPosition);
        _gtg = new GroundTruthGenerator(_drm, _vm, _pcm, _ogm, _som);
        _rm  = new RewardManager(_gtg, _ogm, _som, _vm, _requiredAccuracy);

        Reset();
    }
Esempio n. 11
0
        void CustomRender(ScriptableRenderContext context, HDCamera hd)
        {
            var camera = hd.camera;

            var cmd = CommandBufferPool.Get();

            hd.SetupGlobalParams(cmd, 0);

            if (!Fisheye)
            {
                CoreUtils.SetRenderTarget(cmd, renderTarget.ColorHandle, renderTarget.DepthHandle);
            }

            CoreUtils.ClearRenderTarget(cmd, ClearFlag.All, Color.clear);

            ScriptableCullingParameters culling;

            if (camera.TryGetCullingParameters(out culling))
            {
                var cull = context.Cull(ref culling);

                context.SetupCameraProperties(camera);
                context.ExecuteCommandBuffer(cmd);
                cmd.Clear();

                var sorting = new SortingSettings(camera);
                var drawing = new DrawingSettings(new ShaderTagId("SimulatorDepthPass"), sorting);
                var filter  = new FilteringSettings(RenderQueueRange.all);

                context.DrawRenderers(cull, ref drawing, ref filter);
            }

            if (!Fisheye)
            {
                PointCloudManager.RenderDepth(context, cmd, hd, renderTarget.ColorHandle, renderTarget.DepthHandle);
            }

            CommandBufferPool.Release(cmd);
        }
Esempio n. 12
0
    void Start()
    {
        _PointCloudManager = _ViveCtrl.PointCloudManagerGet();
        _VRCamera          = _ViveCtrl.GetVRCamera();

        _LeftHand        = _ViveCtrl.GetLeftHand();
        _RightController = _ViveCtrl.GetRightHand();

        GameObject leftCollider = Instantiate(_ColliderPrefab);

        leftCollider.name                       = "StartView_LeftCollider";
        leftCollider.transform.parent           = _LeftHand.transform;
        leftCollider.transform.localPosition    = new Vector3(-0.0015f, -0.0372f, 0.0073f);
        leftCollider.transform.localEulerAngles = new Vector3(57.497f, 19.942f, 12.817f);

        GameObject rightCollider = Instantiate(_ColliderPrefab);

        rightCollider.name                       = "StartView_RightCollider";
        rightCollider.transform.parent           = _RightController.transform;
        rightCollider.transform.localPosition    = new Vector3(-0.0015f, -0.0372f, 0.0073f);
        rightCollider.transform.localEulerAngles = new Vector3(57.497f, 19.942f, 12.817f);

        transform.localPosition    = new Vector3(0f, 1.5f, 0f);
        transform.localEulerAngles = new Vector3(0.0f, 0f, 0.0f);

        _ImportStart.OnTransitionDoneEvent += OnTransitionDone;
        _LoadStart.OnTransitionDoneEvent   += OnTransitionDone;

        _ImportStart.SetPointCloudManager(_PointCloudManager);
        _LoadStart.SetPointCloudManager(_PointCloudManager);

        _PointCloudManager.OnProgress       += OnProgressEvent;
        _PointCloudManager.OnGPUSetDataDone += OnLoadComplete;

        _SpinnerCtrl.SetActive(false);

        SetComponentsActive(true);
    }
Esempio n. 13
0
    private void Start()
    {
        _timer = new Stopwatch();


        RenderTexture rTex = _depthCamera.targetTexture;

        rTex.width  = _textureResolution;
        rTex.height = _textureResolution;

        //Setup Managers
        _vm  = new ViewManager(_viewGridLayers, _sphereRadius, _numberViews);
        _som = new StudyObjectMamanger(_objectPosition);
        _drm = new DepthRenderingManager(_depthCamera, _nearClipPlane, _farClipPlane);
        _pcm = new PointCloudManager(rTex, _depthSawOff, _depthCamera);
        _ogm = new OccupancyGridManager(_occupancyGridCount, _studyGridSize, _gridPosition);
        _gtg = new GroundTruthGenerator(_drm, _vm, _pcm, _ogm, _som);
        _rm  = new RewardManager(_gtg, _ogm, _som, _vm, 0.95f);

        Vector3 v = _vm.GetView(0);

        _drm.SetCameraView(v);
    }
 private void Awake()
 {
     pcm = this;
 }
    //private bool isLoaded = false;

    void Start()
    {
        instance = this;
    }
Esempio n. 16
0
 public void SetPointCloudManager(PointCloudManager pcm)
 {
     _PointCloudManager = pcm;
 }