protected override void Init(PipelineResources resources)
        {
            proper            = RenderPipeline.GetEvent <PropertySetEvent>();
            probeBuffer       = new ComputeBuffer(maximumProbe, sizeof(ReflectionData));
            lightingEvents    = RenderPipeline.GetEvent <LightingEvent>();
            reflectionIndices = new ComputeBuffer(CBDRSharedData.XRES * CBDRSharedData.YRES * CBDRSharedData.ZRES * (maximumProbe + 1), sizeof(int));
            string old    = "_ReflectionCubeMap";
            string newStr = new string(' ', old.Length + 1);

            reflectionCubemapIDs = new NativeList <int>(maximumProbe, maximumProbe, Allocator.Persistent);
            fixed(char *ctr = old)
            {
                fixed(char *newCtr = newStr)
                {
                    for (int i = 0; i < old.Length; ++i)
                    {
                        newCtr[i] = ctr[i];
                    }
                    for (int i = 0; i < reflectionCubemapIDs.Length; ++i)
                    {
                        newCtr[old.Length]      = (char)(i + 48);
                        reflectionCubemapIDs[i] = Shader.PropertyToID(newStr);
                    }
                }
            }

            reflectionMat = new Material(resources.shaders.reflectionShader);
            ssrEvents.Init(resources);
        }
 protected override void Dispose()
 {
     decalBuffer.Dispose();
     decalBuffer = null;
     decalCountBuffer.Dispose();
     decalCountBuffer = null;
     lightingEvt      = null;
 }
Ejemplo n.º 3
0
 public void Init(PipelineResources res)
 {
     cbdrShader  = res.shaders.cbdrShader;
     proper      = RenderPipeline.GetEvent <PropertySetEvent>();
     lightingEvt = RenderPipeline.GetEvent <LightingEvent>();
     decalBuffer = new ComputeBuffer(INITCOUNT, sizeof(DecalStrct));
     sortJob.sortedDecalDatas = new NativeList <DecalStrct>(INITCOUNT, Allocator.Persistent);
     minMaxBoundMat           = new Material(res.shaders.minMaxDepthBounding);
 }
Ejemplo n.º 4
0
        public void Init(PipelineResources res)
        {
            cbdrShader       = res.shaders.cbdrShader;
            copyMat          = new Material(res.shaders.copyShader);
            proper           = RenderPipeline.GetEvent <PropertySetEvent>();
            lightingEvt      = RenderPipeline.GetEvent <LightingEvent>();
            decalBuffer      = new ComputeBuffer(INITCOUNT, sizeof(DecalStrct));
            decalIndexBuffer = new ComputeBuffer(CBDRSharedData.XRES * CBDRSharedData.YRES * CBDRSharedData.ZRES * (CBDRSharedData.MAXLIGHTPERCLUSTER + 1), sizeof(int));
            if (decalAlbedoAtlasNames.Length > 0)
            {
                decalAlbedoAtlas = new RenderTexture(new RenderTextureDescriptor
                {
                    width       = atlasWidth,
                    height      = atlasHeight,
                    volumeDepth = decalAlbedoAtlasNames.Length,
                    dimension   = TextureDimension.Tex2DArray,
                    msaaSamples = 1,
                    colorFormat = RenderTextureFormat.ARGB32
                });
            }
            if (decalNormalAtlasNames.Length > 0)
            {
                decalNormalAtlas = new RenderTexture(new RenderTextureDescriptor
                {
                    width       = atlasWidth,
                    height      = atlasHeight,
                    volumeDepth = decalAlbedoAtlasNames.Length,
                    dimension   = TextureDimension.Tex2DArray,
                    msaaSamples = 1,
                    colorFormat = RenderTextureFormat.RGHalf
                });
            }
            for (int i = 0; i < decalAlbedoAtlasNames.Length; ++i)
            {
                Graphics.SetRenderTarget(decalAlbedoAtlas.colorBuffer, decalAlbedoAtlas.depthBuffer, 0, CubemapFace.Unknown, i);
                Texture tex = Resources.Load <Texture>(decalAlbedoAtlasNames[i]);
                copyMat.SetTexture(ShaderIDs._MainTex, tex);
                copyMat.SetPass(0);
                Graphics.DrawMeshNow(GraphicsUtility.mesh, Matrix4x4.identity);
                Resources.UnloadAsset(tex);
            }
            for (int i = 0; i < decalNormalAtlasNames.Length; ++i)
            {
                Graphics.SetRenderTarget(decalNormalAtlas.colorBuffer, decalNormalAtlas.depthBuffer, 0, CubemapFace.Unknown, i);
                Texture tex = Resources.Load <Texture>(decalNormalAtlasNames[i]);
                copyMat.SetTexture(ShaderIDs._MainTex, tex);
                copyMat.SetPass(1);
                Graphics.DrawMeshNow(GraphicsUtility.mesh, Matrix4x4.identity);
                Resources.UnloadAsset(tex);
            }

            Object.DestroyImmediate(copyMat);
        }
Ejemplo n.º 5
0
        protected override void Init(PipelineResources resources)
        {
            lightingData = RenderPipeline.GetEvent <LightingEvent>();
            randomBuffer = new ComputeBuffer(downSampledSize.x * downSampledSize.y * downSampledSize.z, sizeof(uint));
            NativeArray <uint> randomArray = new NativeArray <uint>(randomBuffer.count, Allocator.Temp, NativeArrayOptions.UninitializedMemory);
            uint *randPtr = randomArray.Ptr();

            for (int i = 0; i < randomArray.Length; ++i)
            {
                randPtr[i] = (uint)-System.Guid.NewGuid().GetHashCode();
            }
            randomBuffer.SetData(randomArray);
            randomArray.Dispose();
        }
Ejemplo n.º 6
0
 protected override void Init(PipelineResources resources)
 {
     proper = RenderPipeline.GetEvent <PropertySetEvent>();
     if (useEmissionGeometry)
     {
         geometry.Init();
     }
     if (useNoiseEvents)
     {
         noiseEvents.Init(resources);
     }
     lightingData       = RenderPipeline.GetEvent <LightingEvent>();
     reflectData        = RenderPipeline.GetEvent <ReflectionEvent>();
     lightingMat        = new Material(resources.shaders.volumetricShader);
     cameraNormalBuffer = new ComputeBuffer(3, sizeof(float3));
 }
Ejemplo n.º 7
0
 protected override void Init(PipelineResources resources)
 {
     proper = RenderPipeline.GetEvent <PropertySetEvent>();
     if (useEmissionGeometry)
     {
         geometry.Init();
     }
     if (useNoiseEvents)
     {
         noiseEvents.Init(resources);
     }
     lightingData       = RenderPipeline.GetEvent <LightingEvent>();
     reflectData        = RenderPipeline.GetEvent <ReflectionEvent>();
     lightingMat        = new Material(resources.shaders.volumetricShader);
     cameraNormalBuffer = new ComputeBuffer(3, sizeof(float3));
     blackCB            = new Cubemap(1, TextureFormat.ARGB32, false);
     blackCB.SetPixel(CubemapFace.NegativeX, 0, 0, Color.black);
     blackCB.SetPixel(CubemapFace.NegativeY, 0, 0, Color.black);
     blackCB.SetPixel(CubemapFace.NegativeZ, 0, 0, Color.black);
     blackCB.SetPixel(CubemapFace.PositiveX, 0, 0, Color.black);
     blackCB.SetPixel(CubemapFace.PositiveX, 0, 0, Color.black);
     blackCB.SetPixel(CubemapFace.PositiveX, 0, 0, Color.black);
     volumeDesc = new RenderTextureDescriptor
     {
         autoGenerateMips   = false,
         bindMS             = false,
         colorFormat        = RenderTextureFormat.ARGBHalf,
         depthBufferBits    = 0,
         dimension          = TextureDimension.Tex3D,
         enableRandomWrite  = true,
         height             = downSampledSize.y,
         width              = downSampledSize.x,
         memoryless         = RenderTextureMemoryless.None,
         msaaSamples        = 1,
         shadowSamplingMode = ShadowSamplingMode.None,
         sRGB        = false,
         useMipMap   = false,
         volumeDepth = downSampledSize.z,
         vrUsage     = VRTextureUsage.None
     };
     volumeTex            = new RenderTexture(volumeDesc);
     volumeTex.filterMode = FilterMode.Bilinear;
     volumeTex.wrapMode   = TextureWrapMode.Clamp;
     volumeTex.Create();
 }
 protected override void Init(PipelineResources resources)
 {
     proper = RenderPipeline.GetEvent <PropertySetEvent>();
     if (useEmissionGeometry)
     {
         geometry.Init();
     }
     if (useNoiseEvents)
     {
         noiseEvents.Init(resources);
     }
     lightingData       = RenderPipeline.GetEvent <LightingEvent>();
     reflectData        = RenderPipeline.GetEvent <ReflectionEvent>();
     lightingMat        = new Material(resources.shaders.volumetricShader);
     cameraNormalBuffer = new ComputeBuffer(3, sizeof(float3));
     blackCB            = new Cubemap(1, TextureFormat.ARGB32, false);
     blackCB.SetPixel(CubemapFace.NegativeX, 0, 0, Color.black);
     blackCB.SetPixel(CubemapFace.NegativeY, 0, 0, Color.black);
     blackCB.SetPixel(CubemapFace.NegativeZ, 0, 0, Color.black);
     blackCB.SetPixel(CubemapFace.PositiveX, 0, 0, Color.black);
     blackCB.SetPixel(CubemapFace.PositiveX, 0, 0, Color.black);
     blackCB.SetPixel(CubemapFace.PositiveX, 0, 0, Color.black);
 }
Ejemplo n.º 9
0
 protected override void Init(PipelineResources resources)
 {
     lightingData = RenderPipeline.GetEvent <LightingEvent>();
 }
 protected override void Init(PipelineResources resources)
 {
     lightingData = RenderPipeline.GetEvent <LightingEvent>();
     reflectData  = RenderPipeline.GetEvent <ReflectionEvent>();
     lightingMat  = new Material(resources.shaders.lightingShader);
 }
 protected override void Init(PipelineResources resources)
 {
     lightingEvt      = RenderPipeline.GetEvent <LightingEvent>();
     decalCountBuffer = new ComputeBuffer(CBDRSharedData.XRES * CBDRSharedData.YRES * CBDRSharedData.ZRES * (maxDecalPerCluster + 1), sizeof(uint));
     decalBuffer      = new ComputeBuffer(decalInitCount, sizeof(DecalData));
 }