コード例 #1
0
 protected override void OnDisable()
 {
     RenderPipeline.ExecuteBufferAtFrameEnding((buffer) =>
     {
         buffer.DisableShaderKeyword("ENABLE_REFLECTION");
     });
 }
コード例 #2
0
 protected override void OnDisable()
 {
     RenderPipeline.ExecuteBufferAtFrameEnding((buffer) =>
     {
         buffer.DisableShaderKeyword("ENABLE_SUN");
         buffer.DisableShaderKeyword("SPOTLIGHT");
         buffer.DisableShaderKeyword("POINTLIGHT");
     });
 }
コード例 #3
0
 public void DebugTry()
 {
     if (!SceneController.gpurpEnabled)
     {
         Debug.Log("Cluster Rendering not enabled!");
         return;
     }
     BakeMap(0);
     RenderPipeline.ExecuteBufferAtFrameEnding(cbuffer);
 }
コード例 #4
0
        private IEnumerator FinishLoading()
        {
            coeff.SetData(bytes);
            yield return(null);

            RenderPipeline.ExecuteBufferAtFrameEnding(cubeToCoeff);
            yield return(null);

            yield return(null);

            coeffTextures.Add(currentTexture);
            loadedIrradiance.Add(currentIrr);
            isLoading = false;
        }
コード例 #5
0
        private IEnumerator BakeOcclusion()
        {
            float3 left  = transform.position - transform.localScale * 0.5f;
            float3 right = transform.position + transform.localScale * 0.5f;

            for (int x = 0; x < resolution.x; ++x)
            {
                for (int y = 0; y < resolution.y; ++y)
                {
                    for (int z = 0; z < resolution.z; ++z)
                    {
                        float3 uv = (float3(x, y, z) + 0.5f) / float3(resolution.x, resolution.y, resolution.z);
                        currentPos = lerp(left, right, uv);
                        NativeList <float4x4> view, proj;
                        CalculateCubemapMatrix(currentPos, radius, 0.01f, out view, out proj);
                        RenderPipeline.AddRenderingMissionInEditor(view, proj, bakeCamera, cameraTarget, buffer);
                        RenderPipeline.ExecuteBufferAtFrameEnding(bakeAction);
                        yield return(null);
                    }
                }
            }
        }
コード例 #6
0
 protected override void OnDisable()
 {
     RenderPipeline.ExecuteBufferAtFrameEnding((cb) => cb.DisableShaderKeyword("EnableGTAO"));
 }
コード例 #7
0
 private void Update()
 {
     RenderPipeline.ExecuteBufferAtFrameEnding(updateFunc);
 }
コード例 #8
0
        public IEnumerator BakeLightmap()
        {
            RenderTextureDescriptor texArrayDescriptor = new RenderTextureDescriptor
            {
                autoGenerateMips   = false,
                bindMS             = false,
                colorFormat        = RenderTextureFormat.ARGB32,
                depthBufferBits    = 16,
                dimension          = TextureDimension.Tex2DArray,
                enableRandomWrite  = false,
                height             = RESOLUTION,
                width              = RESOLUTION,
                memoryless         = RenderTextureMemoryless.None,
                msaaSamples        = 1,
                shadowSamplingMode = ShadowSamplingMode.None,
                sRGB        = false,
                useMipMap   = true,
                volumeDepth = 6,
                vrUsage     = VRTextureUsage.None
            };

            RenderTexture rt = RenderTexture.GetTemporary(texArrayDescriptor); rt.filterMode = FilterMode.Trilinear;

            rt.Create();
            texArrayDescriptor.volumeDepth = 1;
            texArrayDescriptor.dimension   = TextureDimension.Tex2D;
            RenderTexture tempRT = RenderTexture.GetTemporary(texArrayDescriptor);

            tempRT.Create();
            ComputeShader          shader = resources.shaders.probeCoeffShader;
            Action <CommandBuffer> func   = (cb) =>
            {
                cb.SetComputeBufferParam(shader, 0, "_CoeffTemp", coeffTemp);
                cb.SetComputeBufferParam(shader, 1, "_CoeffTemp", coeffTemp);
                cb.SetComputeBufferParam(shader, 1, "_Coeff", coeff);
                cb.SetComputeTextureParam(shader, 0, "_SourceCubemap", rt);
                cb.SetGlobalVector("_Tex3DSize", new Vector4(probeCount.x + 0.01f, probeCount.y + 0.01f, probeCount.z + 0.01f));
                cb.SetGlobalVector("_SHSize", transform.localScale);
                cb.SetGlobalVector("_LeftDownBack", transform.position - transform.localScale * 0.5f);
            };

            RenderPipeline.ExecuteBufferAtFrameEnding(func);
            yield return(null);

            yield return(null);

            int target = probeCount.x * probeCount.y * probeCount.z;

            for (int x = 0; x < probeCount.x; ++x)
            {
                for (int y = 0; y < probeCount.y; ++y)
                {
                    for (int z = 0; z < probeCount.z; ++z)
                    {
                        BakeMap(int3(x, y, z), rt, tempRT);
                        cbuffer.GenerateMips(rt);
                        cbuffer.SetComputeIntParam(shader, "_OffsetIndex", PipelineFunctions.DownDimension(int3(x, y, z), probeCount.xy));
                        cbuffer.DispatchCompute(shader, 0, RESOLUTION / 32, RESOLUTION / 32, 6);
                        cbuffer.DispatchCompute(shader, 1, 1, 1, 1);
                        yield return(null);
                    }
                }
            }
            isRendering = false;
            yield return(null);

            isRendered = true;
            byte[] byteArray = new byte[coeff.count * coeff.stride];
            coeff.GetData(byteArray);
            string path = "Assets/BinaryData/Irradiance/" + volumeName + ".mpipe";

            File.WriteAllBytes(path, byteArray);
            float4x4 localToWorld = transform.localToWorldMatrix;

            IrradianceResources.Volume volume = new IrradianceResources.Volume
            {
                position     = transform.position,
                localToWorld = float3x3(localToWorld.c0.xyz, localToWorld.c1.xyz, localToWorld.c2.xyz),
                resolution   = (uint3)probeCount,
                volumeName   = volumeName,
                path         = path
            };
            Debug.Log(volume.volumeName);
            saveTarget.allVolume[indexInList] = volume;
            EditorUtility.SetDirty(saveTarget);
            RenderTexture.ReleaseTemporary(rt);
            RenderTexture.ReleaseTemporary(tempRT);
            yield return(null);

            Dispose();
        }