public void Init(MCRScene scene)
        {
            clusterStride = Marshal.SizeOf <ClusterInfo>();
            vertexStride  = Marshal.SizeOf <VertexInfo>();

            clusterList   = new Unity.Collections.NativeArray <ClusterInfo>(ClusterCount, Unity.Collections.Allocator.Persistent);
            vertexList    = new Unity.Collections.NativeArray <VertexInfo>(VertexCount, Unity.Collections.Allocator.Persistent);
            instanceCount = new uint[1];

            indirectArgs = new List <uint> {
                0, 0, 0, 0, 0
            };
            vertexBuffer            = ComputeBufferPool.GetTempBuffer(VertexCount, vertexStride);
            clusterBuffer           = ComputeBufferPool.GetTempBuffer(ClusterCount, clusterStride);
            cullResultBuffer        = ComputeBufferPool.GetTempBuffer(ClusterCount, 4);
            cullInstanceCountBuffer = ComputeBufferPool.GetTempBuffer(1, 4);
            cullInstanceCountBuffer.SetData(instanceCount);
            inDirectBuffer = ComputeBufferPool.GetIndirectBuffer();

            ClusterInfoAssetsPath = MCRConstant.BakeAssetSavePath + "/" + ClusterInfoAssetsPath;
            if (Application.platform == RuntimePlatform.WindowsEditor || Application.platform == RuntimePlatform.WindowsPlayer)
            {
                //ClusterInfoAssetsPath = MCRConstant.BakeAssetSavePath + "/" + ClusterInfoAssetsPath;
            }
            else
            {
                scene.StartCoroutine(LoadingBytes());
            }


            bLoadFinish = false;
            bDestroyed  = false;
        }
Esempio n. 2
0
    public VoxSRP()
    {
        _cb                 = new CommandBuffer();
        _matPropBlock       = new MaterialPropertyBlock();
        _colorProp          = Shader.PropertyToID("colorBuffer");
        _positionBufferProp = Shader.PropertyToID("positionBuffer");
        _positionBufferPool = new ComputeBufferPool(BatchSize, sizeof(float) * 4 * 4, ComputeBufferType.Structured, "Position Buffer");
        _colorBufferPool    = new ComputeBufferPool(BatchSize, sizeof(float) * 4, ComputeBufferType.Structured, "Color Buffer");
        _voxMesh            = CreateMesh();
        _voxMat             = GraphicsSettings.renderPipelineAsset?.defaultMaterial;

        #if UNITY_EDITOR
        SupportedRenderingFeatures.active = new SupportedRenderingFeatures
        {
            defaultMixedLightingModes   = SupportedRenderingFeatures.LightmapMixedBakeModes.None,
            editableMaterialRenderQueue = true,
            enlighten                      = false,
            lightmapBakeTypes              = 0,
            lightmapsModes                 = 0,
            lightProbeProxyVolumes         = false,
            mixedLightingModes             = SupportedRenderingFeatures.LightmapMixedBakeModes.None,
            motionVectors                  = false,
            overridesEnvironmentLighting   = true,
            overridesFog                   = true,
            overridesLODBias               = true,
            overridesMaximumLODLevel       = true,
            overridesOtherLightingSettings = true,
            receiveShadows                 = false,
            reflectionProbeModes           = SupportedRenderingFeatures.ReflectionProbeModes.None,
            reflectionProbes               = false,
            rendererPriority               = false
        };
        #endif
    }
Esempio n. 3
0
    public static ComputeBufferPool GetShared(ComputeBufferType type = ComputeBufferType.Default)
    {
        Pools = Pools ?? new Dictionary <ComputeBufferType, ComputeBufferPool> ();
        ComputeBufferPool pool;

        if (!Pools.TryGetValue(type, out pool))
        {
            pool = new ComputeBufferPool(type);
            Pools.Add(type, pool);
        }
        return(pool);
    }
        public void Destroy()
        {
            bDestroyed = true;
            ComputeBuffer temp = vertexBuffer;

            ComputeBufferPool.ReleaseTempBuffer(ref temp);
            temp = clusterBuffer;
            ComputeBufferPool.ReleaseTempBuffer(ref temp);
            temp = inDirectBuffer;
            ComputeBufferPool.ReleaseTempBuffer(ref temp);
            temp = cullResultBuffer;
            ComputeBufferPool.ReleaseTempBuffer(ref temp);
            temp = cullInstanceCountBuffer;
            ComputeBufferPool.ReleaseTempBuffer(ref temp);

            clusterList.Dispose();
            vertexList.Dispose();

            instanceCount = null;
            indirectArgs  = null;
            bLoadFinish   = false;
        }
Esempio n. 5
0
 public Context(ComputeBufferPool pool)
 {
     Pool        = pool;
     usedBuffers = new Queue <ComputeBuffer> ();
 }