예제 #1
0
        public void *       equalsFunc;//Func<K, K, bool>
        private void Resize(int targetSize)
        {
            K **newData = (K **)MUnsafeUtility.Malloc(targetSize * 8, data->alloc);

            UnsafeUtility.MemClear(newData, targetSize * 8);
            K **oldPtr = (K **)data->start;

            for (int i = 0; i < data->capacity; ++i)
            {
                K *currentPtr = oldPtr[i];
                while (currentPtr != null)
                {
                    AddTo(*currentPtr, *GetV(currentPtr), targetSize, newData);
                    currentPtr = *GetNextPtr(currentPtr);
                }
                currentPtr = oldPtr[i];
                while (currentPtr != null)
                {
                    K *next = *GetNextPtr(currentPtr);
                    UnsafeUtility.Free(currentPtr, data->alloc);

                    currentPtr = next;
                }
            }
            UnsafeUtility.Free(data->start, data->alloc);
            data->start    = newData;
            data->capacity = targetSize;
        }
예제 #2
0
 public FileGUID(string guid, Allocator alloc)
 {
     this.alloc = alloc;
     char[] charArray = guid.ToCharArray();
     ptr = MUnsafeUtility.Malloc <ulong>(sizeof(ulong) * PTR_LENGTH, alloc);
     UnsafeUtility.MemCpy(ptr, charArray.Ptr(), sizeof(ulong) * PTR_LENGTH);
 }
        private void PointLight(PipelineCamera cam, ref PipelineCommandData data)
        {
            CommandBuffer buffer = data.buffer;

            VoxelLightCommonData(buffer, cam.cam);
            lightingHandle.Complete();
            foreach (var i in addMLightCommandList)
            {
                MLight.AddMLight(i);
            }
            addMLightCommandList.Clear();
            int count = Mathf.Min(cubemapVPMatrices.Length, CBDRSharedData.MAXIMUMPOINTLIGHTCOUNT);

            cbdr.pointshadowCount = count;
            if (LightFilter.pointLightCount > 0)
            {
                if (count > 0)
                {
                    var cullShader = data.resources.shaders.gpuFrustumCulling;
                    buffer.SetGlobalTexture(ShaderIDs._CubeShadowMapArray, cbdr.cubeArrayMap);
                    NativeArray <VisibleLight> allLights     = data.cullResults.visibleLights;
                    PointLightStruct *         pointLightPtr = pointLightArray.Ptr();

                    for (int i = 0; i < count; ++i)
                    {
                        ref CubemapViewProjMatrix vpMatrices = ref cubemapVPMatrices[i];
                        int2   lightIndex = vpMatrices.index;
                        Light  lt         = allLights[lightIndex.y].light;
                        MLight light      = MUnsafeUtility.GetObject <MLight>(vpMatrices.mLightPtr);
                        if (light.useShadowCache)
                        {
                            light.UpdateShadowCacheType(true);
                            if (light.updateShadowCache)
                            {
                                light.updateShadowCache = false;
                                SceneController.DrawPointLight(light, shadowLayer, ref pointLightPtr[lightIndex.x], cubeDepthMaterial, buffer, cullShader, i, ref data, cubemapVPMatrices.unsafePtr, cbdr.cubeArrayMap, cam.inverseRender);
                                int offset = i * 6;
                                for (int a = 0; a < 6; ++a)
                                {
                                    buffer.CopyTexture(cbdr.cubeArrayMap, offset + a, light.shadowMap, a);
                                }
                            }
                            else
                            {
                                PipelineFunctions.CopyToCubeMap(cbdr.cubeArrayMap, light.shadowMap, buffer, i);
                            }
                        }
                        else
                        {
                            SceneController.DrawPointLight(light, shadowLayer, ref pointLightPtr[lightIndex.x], cubeDepthMaterial, buffer, cullShader, i, ref data, cubemapVPMatrices.unsafePtr, cbdr.cubeArrayMap, cam.inverseRender);
                        }

                        //TODO
                        //Multi frame shadowmap
                    }
                }
                SetPointLightBuffer(pointLightArray, LightFilter.pointLightCount);
                buffer.EnableShaderKeyword("POINTLIGHT");
                cbdr.lightFlag |= 1;
            }
 private void Separate()
 {
     if (lodLevel >= setting->allLodLevles.Length - 1)
     {
         EnableSelfRendering();
     }
     else
     {
         DisableSelfRendering();
         if (leftDown == null)
         {
             leftDown  = MUnsafeUtility.Malloc <TerrainQuadTree>(sizeof(TerrainQuadTree) * 4, Allocator.Persistent);
             leftUp    = leftDown + 1;
             rightDown = leftDown + 2;
             rightUp   = leftDown + 3;
             *leftDown  = new TerrainQuadTree(lodLevel, setting, LocalPos.LeftDown, localPosition, rootPosition);
             *leftUp    = new TerrainQuadTree(lodLevel, setting, LocalPos.LeftUp, localPosition, rootPosition);
             *rightDown = new TerrainQuadTree(lodLevel, setting, LocalPos.RightDown, localPosition, rootPosition);
             *rightUp   = new TerrainQuadTree(lodLevel, setting, LocalPos.RightUp, localPosition, rootPosition);
         }
         leftDown->EnableSelfRendering();
         leftUp->EnableSelfRendering();
         rightDown->EnableSelfRendering();
         rightUp->EnableSelfRendering();
     }
 }
예제 #5
0
        public RenderPipeline(PipelineResources resources)
        {
            eventsGuideBook = new NativeDictionary <UIntPtr, int, PtrEqual>(resources.availiableEvents.Length, Allocator.Persistent, new PtrEqual());
            resources.SetRenderingPath();
            var allEvents = resources.allEvents;

            GraphicsUtility.UpdatePlatform();
            MLight.ClearLightDict();
            this.resources = resources;
            current        = this;
            data.buffer    = new CommandBuffer();
            for (int i = 0; i < resources.availiableEvents.Length; ++i)
            {
                resources.availiableEvents[i].InitDependEventsList();
            }
            for (int i = 0; i < resources.availiableEvents.Length; ++i)
            {
                eventsGuideBook.Add(new UIntPtr(MUnsafeUtility.GetManagedPtr(resources.availiableEvents[i].GetType())), i);
                resources.availiableEvents[i].Prepare();
            }
            for (int i = 0; i < resources.availiableEvents.Length; ++i)
            {
                resources.availiableEvents[i].InitEvent(resources);
            }
            waitReleaseRT = new NativeList <int>(20, Allocator.Persistent);
        }
        private void OnEnable()
        {
            if (!allVolumes.isCreated)
            {
                allVolumes = new NativeList <FogVolumeContainer>(30, Allocator.Persistent);
            }

            FogVolumeContainer currentcon;

            currentcon.light = MUnsafeUtility.GetManagedPtr(this);
            float3x3 localToWorld = new float3x3
            {
                c0 = transform.right,
                c1 = transform.up,
                c2 = transform.forward
            };
            float4x4  worldToLocal = transform.worldToLocalMatrix;
            FogVolume volume       = new FogVolume
            {
                extent        = transform.localScale * 0.5f,
                localToWorld  = localToWorld,
                position      = transform.position,
                worldToLocal  = float3x4(worldToLocal.c0.xyz, worldToLocal.c1.xyz, worldToLocal.c2.xyz, worldToLocal.c3.xyz),
                targetVolume  = this.volume,
                color         = float3(fogColor.r, fogColor.g, fogColor.b),
                emissionColor = float3(emissionColor.r, emissionColor.g, emissionColor.b)
            };

            currentcon.volume = volume;
            allVolumes.Add(currentcon);
            index = allVolumes.Length - 1;
        }
예제 #7
0
        protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);
            if (current != this)
            {
                return;
            }
            current = null;
            data.buffer.Dispose();
            var allEvents = resources.allEvents;

            foreach (var i in allEvents)
            {
                if (i != null)
                {
                    foreach (var j in i)
                    {
                        j.DisposeEvent();
                    }
                }
            }
            foreach (var i in PipelineCamera.allCamera)
            {
                PipelineCamera cam    = MUnsafeUtility.GetObject <PipelineCamera>(i.ToPointer());
                var            values = cam.allDatas.Values;
                foreach (var j in values)
                {
                    j.DisposeProperty();
                }
                cam.allDatas.Clear();
            }
        }
예제 #8
0
 public AlignedArray(int count, int alignedSize, Allocator alloc)
 {
     stride     = (sizeof(T) % alignedSize > 0) ? (sizeof(T) / alignedSize + 1) * alignedSize : sizeof(T);
     ptr        = MUnsafeUtility.Malloc <T>(stride * count, alloc);
     constAlloc = alloc;
     Length     = count;
 }
예제 #9
0
        public void Enqueue(T value)
        {
            if (!isCreated)
            {
                return;
            }
            if (nodes.Length <= 0)
            {
                for (int i = 0; i < capacity; ++i)
                {
                    void *ptr = MUnsafeUtility.Malloc(sizeof(T) + sizeof(ulong), queueData->alloc);
                    UnsafeUtility.MemClear(ptr, sizeof(T) + sizeof(ulong));
                    nodes.Add((ulong)ptr);
                }
            }

            void *nodePtr = (void *)nodes[nodes.Length - 1];

            *(T *)nodePtr = value;
            nodes.RemoveLast();
            if (queueData->length <= 0)
            {
                queueData->startNode = nodePtr;
                queueData->endNode   = nodePtr;
            }
            else
            {
                ref void *lastNodeNextPos = ref Node.GetNext(queueData->endNode);
                lastNodeNextPos    = nodePtr;
                queueData->endNode = nodePtr;
            }
예제 #10
0
 public MaskBuffer(long offset, long size)
 {
     this.offset = offset;
     bytesData   = MUnsafeUtility.Malloc <byte>((long)size + 1, Allocator.Persistent);
     isFinished  = (bool *)(bytesData + size);
     *isFinished = false;
 }
예제 #11
0
        public int ConcurrentAdd(ref int value, object lockerObj)
        {
            int last = Interlocked.Increment(ref data->count);

            //Concurrent Resize
            if (last > data->capacity)
            {
                lock (lockerObj)
                {
                    if (last > data->capacity)
                    {
                        int   newCapacity = data->capacity * 2;
                        void *newPtr      = MUnsafeUtility.Malloc <int>(sizeof(int) * newCapacity, data->allocator);
                        UnsafeUtility.MemCpy(newPtr, data->ptr, sizeof(int) * data->count);
                        UnsafeUtility.Free(data->ptr, data->allocator);
                        data->ptr      = newPtr;
                        data->capacity = newCapacity;
                    }
                }
            }

            last--;
            int *ptr = (int *)data->ptr;

            *(ptr + last) = value;
            return(last);
        }
 private void Separate()
 {
     if (!isRendering)
     {
         return;
     }
     isRendering = false;
     DisableSelfRendering();
     if (leftDown == null)
     {
         leftDown  = MUnsafeUtility.Malloc <TerrainQuadTree>(sizeof(TerrainQuadTree) * 4, Allocator.Persistent);
         leftUp    = leftDown + 1;
         rightDown = leftDown + 2;
         rightUp   = leftDown + 3;
     }
     *leftDown = new TerrainQuadTree(this.Ptr(), lodLevel, setting, LocalPos.LeftDown, localPosition, rootPosition)
     {
         isRendering = true
     };
     *leftUp = new TerrainQuadTree(this.Ptr(), lodLevel, setting, LocalPos.LeftUp, localPosition, rootPosition)
     {
         isRendering = true
     };
     *rightDown = new TerrainQuadTree(this.Ptr(), lodLevel, setting, LocalPos.RightDown, localPosition, rootPosition)
     {
         isRendering = true
     };
     *rightUp = new TerrainQuadTree(this.Ptr(), lodLevel, setting, LocalPos.RightUp, localPosition, rootPosition)
     {
         isRendering = true
     };
     //TODO
     //Enable Children's rendering
 }
예제 #13
0
        private void OnEnable()
        {
            if (!decalDatas.isCreated)
            {
                decalDatas = new NativeList <DecalData>(10, Unity.Collections.Allocator.Persistent);
            }
            index = decalDatas.Length;
            float4x4 worldToLocal = transform.worldToLocalMatrix;
            float4x4 localToWorld = transform.localToWorldMatrix;

            decalDatas.Add(
                new DecalData
            {
                localToWorld        = float3x4(localToWorld.c0.xyz, localToWorld.c1.xyz, localToWorld.c2.xyz, localToWorld.c3.xyz),
                worldToLocal        = float3x4(worldToLocal.c0.xyz, worldToLocal.c1.xyz, worldToLocal.c2.xyz, worldToLocal.c3.xyz),
                albedoScaleOffset   = albedoScaleOffset,
                normalScaleOffset   = normalScaleOffset,
                specularScaleOffset = specularScaleOffset,
                importance          = importance,
                comp              = MUnsafeUtility.GetManagedPtr(this),
                texIndex          = int3(albedoIndex, normalIndex, specularIndex),
                avaliableDistance = avaliableDistance,
                opacity           = float3(albedoOpacity, normalOpacity, specularOpacity),
                layer             = (uint)layer
            });
        }
 public override void PreRenderFrame(PipelineCamera cam, ref PipelineCommandData data)
 {
     reflectProbes  = proper.cullResults.visibleReflectionProbes;
     reflectionData = new NativeArray <ReflectionData>(reflectProbes.Length, Allocator.Temp, NativeArrayOptions.UninitializedMemory);
     storeRef       = new StoreReflectionData
     {
         data            = reflectionData.Ptr(),
         allProbes       = reflectProbes.Ptr(),
         count           = reflectProbes.Length,
         camPos          = cam.cam.transform.position,
         dist            = availiableDistance,
         localToWorldMat = MUnsafeUtility.Malloc <Matrix4x4>(sizeof(Matrix4x4) * reflectProbes.Length, Allocator.Temp)
     };
     storeDataHandler = storeRef.ScheduleRefBurst();
     if (ssrEvents.enabled && !RenderPipeline.renderingEditor)
     {
         ssrEvents.PreRender(cam);
     }
     if (!preintDefaultRT)
     {
         preintDefaultRT            = new RenderTexture(512, 512, 0, RenderTextureFormat.RG16, RenderTextureReadWrite.Linear);
         preintDefaultRT.filterMode = FilterMode.Bilinear;
         preintDefaultRT.Create();
         data.buffer.BlitSRT(preintDefaultRT, preintMat, 0);
     }
 }
예제 #15
0
        public static ComputeBuffer GetTempPropertyBuffer(int length, int stride, ComputeBufferType type = ComputeBufferType.Default)
        {
            if (!allTempBuffers.isCreated)
            {
                allTempBuffers = new NativeDictionary <BufferKey, int, BufferKey.Equal>(11, Allocator.Persistent, new BufferKey.Equal());
            }
            ComputeBuffer target;
            int           targetIndex;

            if (allTempBuffers.Get(new BufferKey {
                size = stride, type = type
            }, out targetIndex))
            {
                target = MUnsafeUtility.GetHookedObject(targetIndex) as ComputeBuffer;
                if (target.count < length)
                {
                    target.Dispose();
                    target = new ComputeBuffer(length, stride, type);
                    MUnsafeUtility.SetHookedObject(targetIndex, target);
                }
                return(target);
            }
            else
            {
                target            = new ComputeBuffer(length, stride);
                allTempBuffers[new BufferKey {
                                   size = stride, type = type
                               }] = MUnsafeUtility.HookObject(target);
                return(target);
            }
        }
예제 #16
0
        protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);
            if (current == this)
            {
                current = null;
            }
            iRunnableObjects.Dispose();
            CustomDrawRequest.Dispose();
            if (m_afterFrameBuffer != null)
            {
                m_afterFrameBuffer.Dispose();
                m_afterFrameBuffer = null;
            }
            if (m_beforeFrameBuffer != null)
            {
                m_beforeFrameBuffer.Dispose();
                m_beforeFrameBuffer = null;
            }

            try
            {
                eventsGuideBook.Dispose();
                waitReleaseRT.Dispose();
            }
            catch { }
            SceneController.Dispose(resources);
            resources.loadingThread.Dispose();
            data.buffer.Dispose();
            var allEvents = resources.allEvents;

            for (int i = 0; i < resources.availiableEvents.Length; ++i)
            {
                resources.availiableEvents[i].DisposeEvent();
            }
            for (int i = 0; i < resources.availiableEvents.Length; ++i)
            {
                resources.availiableEvents[i].DisposeDependEventsList();
            }

            foreach (var camPtr in PipelineCamera.CameraSearchDict)
            {
                PipelineCamera cam = MUnsafeUtility.GetObject <PipelineCamera>((void *)camPtr.value);
                if (cam.allDatas.isCreated)
                {
                    foreach (var i in cam.allDatas)
                    {
                        IPerCameraData data = ((IPerCameraData)MUnsafeUtility.GetHookedObject(i.value));
                        data.DisposeProperty();
                        MUnsafeUtility.RemoveHookedObject(i.value);
                    }
                    cam.allDatas.Dispose();
                }
            }
            if (motionVectorMatricesBuffer != null)
            {
                motionVectorMatricesBuffer.Dispose();
            }
            MotionVectorDrawer.Dispose();
        }
예제 #17
0
        private void OnDisable()
        {
            allProbe[index] = allProbe[allProbe.Length - 1];
            AOProbe prb = MUnsafeUtility.GetObject <AOProbe>(allProbe[index].ToPointer());

            prb.index = index;
        }
 public Native2DArray(int2 len, Allocator alloc)
 {
     ptr       = MUnsafeUtility.Malloc <T>(len.x * len.y * sizeof(T), alloc);
     isCreated = true;
     allocator = alloc;
     Length    = len;
 }
예제 #19
0
        protected override void Dispose(bool disposing)
        {
            eventsGuideBook.Dispose();
            waitReleaseRT.Dispose();
            base.Dispose(disposing);
            if (current == this)
            {
                current = null;
            }
            data.buffer.Dispose();
            var allEvents = resources.allEvents;

            for (int i = 0; i < resources.availiableEvents.Length; ++i)
            {
                resources.availiableEvents[i].DisposeEvent();
            }
            for (int i = 0; i < resources.availiableEvents.Length; ++i)
            {
                resources.availiableEvents[i].DisposeDependEventsList();
            }
            if (PipelineCamera.allCamera.isCreated)
            {
                foreach (var i in PipelineCamera.allCamera)
                {
                    PipelineCamera cam    = MUnsafeUtility.GetObject <PipelineCamera>(i.value.ToPointer());
                    var            values = cam.allDatas.Values;
                    foreach (var j in values)
                    {
                        j.DisposeProperty();
                    }
                    cam.allDatas.Clear();
                }
            }
        }
예제 #20
0
        public void Execute()
        {
            List <MLight> allSpotLight  = MLight.avaliableSpotShadowIndices;
            List <MLight> allPointLight = MLight.avaliableCubemapIndices;
            UIntPtr *     allPtr        = stackalloc UIntPtr[max(spotExists ? allSpotLight.Count : 0, pointExists ? allPointLight.Count : 0)];
            int           ptrCount      = 0;

            if (spotExists)
            {
                for (int i = 0; i < allSpotLight.Count; ++i)
                {
                    ref Cone c   = ref allSpotLightPosition[i];
                    float3   dir = c.vertex - cameraPos;
                    if (!MathLib.ConeIntersect(allSpotLightPosition[i], MathLib.GetPlane(dir, cameraPos + dir * shadowDistance)))
                    {
                        allPtr[ptrCount] = new UIntPtr(MUnsafeUtility.GetManagedPtr(allSpotLight[i]));
                        ptrCount++;
                    }
                }
                for (int i = 0; i < ptrCount; ++i)
                {
                    MLight ml = MUnsafeUtility.GetObject <MLight>(allPtr[i].ToPointer());
                    ml.RemoveLightFromAtlas(false);
                    ml.updateShadowCache = true;
                }
            }
 public LoadingHandler(int2 position, int mipLevel)
 {
     this.position = position;
     this.mipLevel = mipLevel;
     allBytes      = MUnsafeUtility.Malloc <byte>(CHUNK_SIZE + 1, Allocator.Persistent);
     isComplete    = (bool *)(allBytes + CHUNK_SIZE);
     *isComplete = false;
 }
예제 #22
0
        private void OnDestroy()
        {
            Decal lastDec = MUnsafeUtility.GetObject <Decal>(decalDatas[decalDatas.Length - 1].comp);

            lastDec.index     = index;
            decalDatas[index] = decalDatas[decalDatas.Length - 1];
            decalDatas.RemoveLast();
        }
예제 #23
0
 public static void AddRunnableObject(int id, IPipelineRunnable func)
 {
     if (!iRunnableObjects.isCreated)
     {
         iRunnableObjects = new NativeDictionary <int, ulong, IntEqual>(10, Allocator.Persistent, new IntEqual());
     }
     iRunnableObjects.Add(id, (ulong)MUnsafeUtility.GetManagedPtr(func));
 }
예제 #24
0
 public PtrList(int initCapacity, int stride, Allocator alloc)
 {
     length      = 0;
     capacity    = initCapacity;
     this.stride = stride;
     this.alloc  = alloc;
     dataPtr     = new UIntPtr(MUnsafeUtility.Malloc(stride * capacity, alloc));
 }
예제 #25
0
        private void OnDisable()
        {
            AreaVolumeProbe lastProbe = MUnsafeUtility.GetObject <AreaVolumeProbe>(allAreaLight[allAreaLight.Length - 1].componentPtr);

            lastProbe.index     = index;
            allAreaLight[index] = allAreaLight[allAreaLight.Length - 1];
            allAreaLight.RemoveLast();
        }
        private void OnDisable()
        {
            allVolumes[index] = allVolumes[allVolumes.Length - 1];
            FogVolumeComponent lastComp = MUnsafeUtility.GetObject <FogVolumeComponent>(allVolumes[index].light);

            lastComp.index = index;
            allVolumes.RemoveLast();
        }
 private void OnEnable()
 {
     if (!allCamera.isCreated)
     {
         allCamera = new NativeDictionary <int, UIntPtr>(17, Unity.Collections.Allocator.Persistent, (i, j) => i == j);
     }
     allCamera.Add(gameObject.GetInstanceID(), new UIntPtr(MUnsafeUtility.GetManagedPtr(this)));
 }
예제 #28
0
        private void OnDisable()
        {
            *container = allVolumes[allVolumes.Length - 1];
            FogVolumeComponent lastComp = MUnsafeUtility.GetObject <FogVolumeComponent>(container->light);

            lastComp.container = container;
            allVolumes.RemoveLast();
        }
        public override void PreRenderFrame(PipelineCamera cam, ref PipelineCommandData data)
        {
            if (SunLight.current && SunLight.current.enabled && SunLight.current.gameObject.activeSelf)
            {
                data.buffer.EnableShaderKeyword("ENABLE_SUN");
                data.buffer.SetKeyword("ENABLE_SUNSHADOW", SunLight.current.enableShadow);
            }
            else
            {
                data.buffer.DisableShaderKeyword("ENABLE_SUN");
            }
            var visLights = data.cullResults.visibleLights;

            LightFilter.allVisibleLight = visLights.Ptr();
            allLights.Clear();
            foreach (var i in visLights)
            {
                allLights.Add(i.light);
            }
            addMLightCommandList.Clear();
            LightFilter.allMLightCommandList = addMLightCommandList;
            pointLightArray               = new NativeArray <PointLightStruct>(visLights.Length, Allocator.Temp, NativeArrayOptions.UninitializedMemory);
            spotLightArray                = new NativeArray <SpotLight>(visLights.Length, Allocator.Temp, NativeArrayOptions.UninitializedMemory);
            cubemapVPMatrices             = new NativeList <CubemapViewProjMatrix>(CBDRSharedData.MAXIMUMPOINTLIGHTCOUNT, Allocator.Temp);
            spotLightMatrices             = new NativeList <SpotLightMatrix>(CBDRSharedData.MAXIMUMSPOTLIGHTCOUNT, Allocator.Temp);
            LightFilter.allLights         = allLights;
            LightFilter.pointLightArray   = pointLightArray;
            LightFilter.spotLightArray    = spotLightArray;
            LightFilter.cubemapVPMatrices = cubemapVPMatrices;
            LightFilter.spotLightMatrices = spotLightMatrices;
            Transform camTrans = cam.cam.transform;

            lightingHandle = (new LightFilter {
                camPos = cam.cam.transform.position,
                lightDist = localLightDistance
            }).Schedule(allLights.Count, 1);
            if (SunLight.current != null && SunLight.current.enabled && SunLight.current.enableShadow)
            {
                clipDistances = (float *)UnsafeUtility.Malloc(SunLight.CASCADECLIPSIZE * sizeof(float), 16, Allocator.Temp);
                staticFit     = DirectionalShadowStaticFit(cam.cam, SunLight.current, clipDistances);
                sunShadowCams = MUnsafeUtility.Malloc <OrthoCam>(SunLight.CASCADELEVELCOUNT * sizeof(OrthoCam), Allocator.Temp);
                Matrix4x4 proj = cam.cam.projectionMatrix;
                cam.cam.projectionMatrix = cam.cam.nonJitteredProjectionMatrix;
                PipelineFunctions.GetfrustumCorners(clipDistances, SunLight.CASCADELEVELCOUNT + 1, cam.cam, staticFit.frustumCorners.Ptr());
                cam.cam.projectionMatrix = proj;
                csmStruct = new CascadeShadowmap
                {
                    cascadeShadowmapVPs = (float4x4 *)cascadeShadowMapVP.Ptr(),
                    results             = sunShadowCams,
                    orthoCam            = (OrthoCam *)UnsafeUtility.AddressOf(ref SunLight.current.shadCam),
                    farClipPlane        = SunLight.current.farestZ,
                    frustumCorners      = staticFit.frustumCorners.Ptr(),
                    resolution          = staticFit.resolution,
                    isD3D = GraphicsUtility.platformIsD3D
                };
                csmHandle = csmStruct.ScheduleRefBurst(SunLight.CASCADELEVELCOUNT, 1);
            }
        }
예제 #30
0
 public NativeList_Int(int count, int capacity, Allocator alloc)
 {
     isCreated       = true;
     data            = MUnsafeUtility.Malloc <NativeListData>(sizeof(NativeListData), alloc);
     data->count     = count;
     data->capacity  = capacity;
     data->allocator = alloc;
     data->ptr       = MUnsafeUtility.Malloc <int>(sizeof(int) * capacity, alloc);
 }