Exemplo n.º 1
0
        public void Execute(int index) //row major
        {
            int3           tileIndex;
            TileLightIndex tileLightIndex = m_lightIndices[index];

            tileLightIndex.Reset();
            tileIndex.x = index % m_TileCount.x;
            tileIndex.y = index / m_TileCount.x;
            m_TileLightIndicesMinMax[index] = new uint2(1024, 0);
            var lightCount = 0;

            for (int i = 0; i < m_LightPos.Length; i++)
            {
                float3 lightPosition = m_LightPos[i];
                var    range         = m_LightRange[i];
                var    tileIsLit     = PlaneCircleCollision(m_ClusterInfo.ClusterXPlaneNormal[tileIndex.x],
                                                            m_ClusterInfo.ClusterXPlanePoints[tileIndex.x], lightPosition, range) && // plane left
                                       PlaneCircleCollision(-m_ClusterInfo.ClusterXPlaneNormal[tileIndex.x + 1],
                                                            m_ClusterInfo.ClusterXPlanePoints[tileIndex.x + 1], lightPosition, range) &&// plane right
                                       PlaneCircleCollision(m_ClusterInfo.ClusterYPlaneNormal[tileIndex.y],
                                                            m_ClusterInfo.ClusterYPlanePoints[tileIndex.y], lightPosition, range) && // plane top
                                       PlaneCircleCollision(-m_ClusterInfo.ClusterYPlaneNormal[tileIndex.y + 1],
                                                            m_ClusterInfo.ClusterYPlanePoints[tileIndex.y + 1], lightPosition, range);
                uint unsignedi = (uint)i;
                if (tileIsLit)
                {
                    tileLightIndex.SetIndex(i);
                    m_TileLightIndicesMinMax[index] = new uint2(min(unsignedi, m_TileLightIndicesMinMax[index].x),
                                                                max(unsignedi, m_TileLightIndicesMinMax[index].y));
                    lightCount += 1;
                }
            }
            m_lightIndices[index]   = tileLightIndex;
            m_TileLightCount[index] = lightCount;
        }
Exemplo n.º 2
0
        public void Execute(int zBinningIndex) //16 by default
        {
            int3           tileIndex;
            TileLightIndex tileLightIndex = m_lightIndices[zBinningIndex];

            tileLightIndex.Reset();
            for (int i = 0; i < m_LightList.Length; i++)
            {
                float3 lightPosition = m_LightList[i].light.transform.position;
                var    range         = m_LightList[i].light.range;
                var    tileIsLit     = PlaneCircleCollision(-m_ZBinningInfo.CameraNormal[0],
                                                            m_ZBinningInfo.ZBinningPoints[0][i], lightPosition, range) && // plane left
                                       PlaneCircleCollision(m_ZBinningInfo.CameraNormal[0],
                                                            m_ZBinningInfo.ZBinningPoints[0][i + 1], lightPosition, range); // plane right

                if (tileIsLit)
                {
                    tileLightIndex.SetIndex(i);
                }
            }
            m_lightIndices[zBinningIndex] = tileLightIndex;
        }