void OnPostRender() { foreach (PriorityCallback cb in cbPostGBuffer) { cb.callback.Invoke(); SetRenderTargetsGBuffer(); } SetRenderTargetsComposite(); GL.Clear(true, true, Color.black); SetRenderTargetsCompositeWithDepth(); foreach (PriorityCallback cb in cbPreLighting) { cb.callback.Invoke(); } DSLight.RenderLights(this); matCombineEmission.SetTexture("g_emission_buffer", rtEmissionBuffer); matCombineEmission.SetPass(0); DrawFullscreenQuad(); foreach (PriorityCallback cb in cbPostLighting) { cb.callback.Invoke(); } foreach (PriorityCallback cb in cbTransparent) { cb.callback.Invoke(); } foreach (PriorityCallback cb in cbPostEffect) { cb.callback.Invoke(); } foreach (PriorityCallback cb in cbHUD) { cb.callback.Invoke(); } //// debug //if (Time.frameCount % 60 == 0) //{ // Debug.Log("cbPreLighting: " + cbPreLighting.Count); // Debug.Log("cbPostLighting: " + cbPostLighting.Count); // Debug.Log("cbTransparent: " + cbTransparent.Count); // Debug.Log("cbPostEffect: " + cbPostEffect.Count); //} Graphics.SetRenderTarget(null); matCombine.SetTexture("_MainTex", rtComposite); matCombine.SetPass(1); DrawFullscreenQuad(); }
void OnPostRender() { Graphics.SetRenderTarget(rtComposite[0]); GL.Clear(true, true, Color.black); Graphics.SetRenderTarget(rtComposite[0].colorBuffer, mrtTex[0].depthBuffer); DSLight.sphereMesh = sphereMeshObject.GetComponent <MeshFilter>().mesh; DSLight.matPointLight = matPointLight; DSLight.matDirectionalLight = matDirectionalLight; DSLight.RenderLights(this); if (voronoiGlowline) { mrtRB2[0] = rtComposite[0].colorBuffer; mrtRB2[1] = mrtTex[3].colorBuffer; Graphics.SetRenderTarget(mrtRB2, mrtTex[0].depthBuffer); matGlowLine.SetPass(0); DrawFullscreenQuad(); Graphics.SetRenderTarget(rtComposite[0]); } if (normalGlow) { matGlowNormal.SetPass(0); DrawFullscreenQuad(); } if (bloom) { Vector4 hscreen = new Vector4(rtBloomH[0].width, rtBloomH[0].height, 1.0f / rtBloomH[0].width, 1.0f / rtBloomH[0].height); Vector4 qscreen = new Vector4(rtBloomQ[0].width, rtBloomQ[0].height, 1.0f / rtBloomQ[0].width, 1.0f / rtBloomQ[0].height); matBloomHBlur.SetVector("_Screen", hscreen); matBloomVBlur.SetVector("_Screen", hscreen); Graphics.SetRenderTarget(rtBloomH[0]); matBloomHBlur.SetTexture("_GlowBuffer", mrtTex[3]); matBloomHBlur.SetPass(0); DrawFullscreenQuad(); Graphics.SetRenderTarget(rtBloomH[1]); matBloomHBlur.SetTexture("_GlowBuffer", rtBloomH[0]); matBloomHBlur.SetPass(0); DrawFullscreenQuad(); Graphics.SetRenderTarget(rtBloomH[0]); matBloomHBlur.SetTexture("_GlowBuffer", rtBloomH[1]); matBloomHBlur.SetPass(0); DrawFullscreenQuad(); Graphics.SetRenderTarget(rtBloomH[1]); matBloomVBlur.SetTexture("_GlowBuffer", rtBloomH[0]); matBloomVBlur.SetPass(0); DrawFullscreenQuad(); matBloomHBlur.SetVector("_Screen", qscreen); matBloomVBlur.SetVector("_Screen", qscreen); Graphics.SetRenderTarget(rtBloomQ[0]); matBloomHBlur.SetTexture("_GlowBuffer", mrtTex[3]); matBloomHBlur.SetPass(0); DrawFullscreenQuad(); Graphics.SetRenderTarget(rtBloomQ[1]); matBloomHBlur.SetTexture("_GlowBuffer", rtBloomQ[0]); matBloomHBlur.SetPass(0); DrawFullscreenQuad(); Graphics.SetRenderTarget(rtBloomQ[0]); matBloomHBlur.SetTexture("_GlowBuffer", rtBloomQ[1]); matBloomHBlur.SetPass(0); DrawFullscreenQuad(); Graphics.SetRenderTarget(rtBloomQ[1]); matBloomVBlur.SetTexture("_GlowBuffer", rtBloomQ[0]); matBloomVBlur.SetPass(0); DrawFullscreenQuad(); Graphics.SetRenderTarget(rtComposite[0]); matBloom.SetTexture("_GlowBuffer", mrtTex[3]); matBloom.SetTexture("_HalfGlowBuffer", rtBloomH[1]); matBloom.SetTexture("_QuarterGlowBuffer", rtBloomQ[1]); matBloom.SetPass(0); DrawFullscreenQuad(); } Graphics.SetRenderTarget(null); GL.Clear(false, true, Color.black); matReflection.SetPass(0); DrawFullscreenQuad(); Graphics.SetRenderTarget(null); }