コード例 #1
0
    public static void pushGameObjects(ComputeShader RayTracingShader)
    {
        var renders = RayTracingMeshRenderer.getObjectsToRender();

        var packs = new List <transformPack>();

        foreach (var obj in renders)
        {
            transformPack pack = new transformPack(obj.data.id, obj.transform.position, obj.transform.rotation, obj.transform.localScale);
            packs.Add(pack);
        }
        int s = System.Runtime.InteropServices.Marshal.SizeOf(typeof(transformPack));

        if (_static_transforms != null)
        {
            _static_transforms.Release();
        }
        //_static_transforms = new ComputeBuffer(0, s);
        if (packs.Count > 0)
        {
            _static_transforms = new ComputeBuffer(packs.Count, s);
            _static_transforms.SetData(packs);
            RayTracingShader.SetBuffer(0, "_static_transforms", _static_transforms);
        }
    }
コード例 #2
0
    // Start is called before the first frame update
    void Start()
    {
        RayTracingMeshRenderer.pushStaticMeshes(RayTracingShader);
        RayTracingMeshRenderer.pushTextures(RayTracingShader);

        var obs_ = RayTracingMeshRenderer.getObjectsToRender();

        foreach (var ele in obs_)
        {
            _transformsToWatch.Add(ele.transform);
        }
        var m = FindObjectsOfType <Mass>();

        bh_t.Clear();
        foreach (var ele in m)
        {
            bh_t.Add(ele.gameObject);
            _transformsToWatch.Add(ele.transform);
        }
    }