Пример #1
0
    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();
    }
Пример #2
0
    void OnGUI()
    {
        float lineheight = 22.0f;
        float margin = 0.0f;
        float labelWidth = 130.0f;
        float x = 10.0f;
        float y = 10.0f;

        if (!showGUI) { return; }

        DSLight[] dslights = new DSLight[3] {
            lights[0].GetComponent<DSLight>(),
            lights[1].GetComponent<DSLight>(),
            lights[2].GetComponent<DSLight>(),
        };
        DSPEGlowline glowline = cam.GetComponentInChildren<DSPEGlowline>();
        DSPEGlowNormal glownormal = cam.GetComponentInChildren<DSPEGlowNormal>();
        DSPEReflection reflection = cam.GetComponentInChildren<DSPEReflection>();
        DSPEBloom bloom = cam.GetComponentInChildren<DSPEBloom>();

        dslights[0].castShadow = GUI.Toggle(new Rect(x, y, 150, lineheight), dslights[0].castShadow, "shadow");
        foreach(var dsl in dslights) {
            dsl.castShadow = dslights[0].castShadow;
        }
        y += lineheight + margin;

        glownormal.enabled = GUI.Toggle(new Rect(x, y, 150, lineheight), glownormal.enabled, "glownormal");
        y += lineheight + margin;

        glowline.enabled = GUI.Toggle(new Rect(x, y, 150, lineheight), glowline.enabled, "glowline");
        y += lineheight + margin;

        bloom.enabled = GUI.Toggle(new Rect(x, y, 150, lineheight), bloom.enabled, "bloom");
        y += lineheight + margin;

        reflection.enabled = GUI.Toggle(new Rect(x, y, 150, lineheight), reflection.enabled, "reflection");
        y += lineheight + margin;
        x += 15.0f;
        GUI.Label(new Rect(x, y, labelWidth, lineheight), "intensity:");
        GUI.TextField(new Rect(x + labelWidth, y, 50, lineheight), reflection.m_intensity.ToString());
        reflection.m_intensity = (float)GUI.HorizontalSlider(new Rect(x + labelWidth + 55, y, 100, lineheight), reflection.m_intensity, 0.0f, 1.0f);
        y += lineheight + margin;

        GUI.Label(new Rect(x, y, labelWidth, lineheight), "march distance:");
        GUI.TextField(new Rect(x + labelWidth, y, 50, lineheight), reflection.m_raymarch_distance.ToString());
        reflection.m_raymarch_distance = (float)GUI.HorizontalSlider(new Rect(x + labelWidth + 55, y, 100, lineheight), reflection.m_raymarch_distance, 0.0f, 1.0f);
        y += lineheight + margin;

        GUI.Label(new Rect(x, y, labelWidth, lineheight), "ray diffusion:");
        GUI.TextField(new Rect(x + labelWidth, y, 50, lineheight), reflection.m_ray_diffusion.ToString());
        reflection.m_ray_diffusion = (float)GUI.HorizontalSlider(new Rect(x + labelWidth + 55, y, 100, lineheight), reflection.m_ray_diffusion, 0.0f, 0.2f);
        y += lineheight + margin;

        GUI.Label(new Rect(x, y, labelWidth, lineheight), "falloff distance:");
        GUI.TextField(new Rect(x + labelWidth, y, 50, lineheight), reflection.m_falloff_distance.ToString());
        reflection.m_falloff_distance = (float)GUI.HorizontalSlider(new Rect(x + labelWidth + 55, y, 100, lineheight), reflection.m_falloff_distance, 0.0f, 50.0f);
        y += lineheight + margin;

        GUI.Label(new Rect(x, y, labelWidth, lineheight), "max accumulation:");
        GUI.TextField(new Rect(x + labelWidth, y, 50, lineheight), reflection.m_max_accumulation.ToString());
        reflection.m_max_accumulation = (float)GUI.HorizontalSlider(new Rect(x + labelWidth + 55, y, 100, lineheight), reflection.m_max_accumulation, 1.0f, 100.0f);
        y += lineheight + margin;
        x -= 15.0f;

        y += 10.0f;

        GUI.Label(new Rect(x, y, 300, lineheight), "mouse drag & wheel: move camera");
        y += lineheight + margin;

        GUI.Label(new Rect(x, y, 300, lineheight), "space: show / hide GUI");
        y += lineheight + margin;

        GUI.Label(new Rect(x, y, 300, lineheight), "R: rotation on / off");
        y += lineheight + margin;

        //cbGridPatterns.Show();
    }
Пример #3
0
    void OnGUI()
    {
        float lineheight = 22.0f;
        float margin     = 0.0f;
        float labelWidth = 130.0f;
        float x          = 10.0f;
        float y          = 10.0f;

        if (!showGUI)
        {
            return;
        }

        DSLight[] dslights = new DSLight[3] {
            lights[0].GetComponent <DSLight>(),
            lights[1].GetComponent <DSLight>(),
            lights[2].GetComponent <DSLight>(),
        };
        DSPEGlowline   glowline   = cam.GetComponentInChildren <DSPEGlowline>();
        DSPEGlowNormal glownormal = cam.GetComponentInChildren <DSPEGlowNormal>();
        DSPEReflection reflection = cam.GetComponentInChildren <DSPEReflection>();
        DSPEBloom      bloom      = cam.GetComponentInChildren <DSPEBloom>();


        dslights[0].castShadow = GUI.Toggle(new Rect(x, y, 150, lineheight), dslights[0].castShadow, "shadow");
        foreach (var dsl in dslights)
        {
            dsl.castShadow = dslights[0].castShadow;
        }
        y += lineheight + margin;

        glownormal.enabled = GUI.Toggle(new Rect(x, y, 150, lineheight), glownormal.enabled, "glownormal");
        y += lineheight + margin;

        glowline.enabled = GUI.Toggle(new Rect(x, y, 150, lineheight), glowline.enabled, "glowline");
        y += lineheight + margin;

        bloom.enabled = GUI.Toggle(new Rect(x, y, 150, lineheight), bloom.enabled, "bloom");
        y            += lineheight + margin;

        reflection.enabled = GUI.Toggle(new Rect(x, y, 150, lineheight), reflection.enabled, "reflection");
        y += lineheight + margin;
        x += 15.0f;
        GUI.Label(new Rect(x, y, labelWidth, lineheight), "intensity:");
        GUI.TextField(new Rect(x + labelWidth, y, 50, lineheight), reflection.m_intensity.ToString());
        reflection.m_intensity = (float)GUI.HorizontalSlider(new Rect(x + labelWidth + 55, y, 100, lineheight), reflection.m_intensity, 0.0f, 1.0f);
        y += lineheight + margin;

        GUI.Label(new Rect(x, y, labelWidth, lineheight), "march distance:");
        GUI.TextField(new Rect(x + labelWidth, y, 50, lineheight), reflection.m_raymarch_distance.ToString());
        reflection.m_raymarch_distance = (float)GUI.HorizontalSlider(new Rect(x + labelWidth + 55, y, 100, lineheight), reflection.m_raymarch_distance, 0.0f, 1.0f);
        y += lineheight + margin;

        GUI.Label(new Rect(x, y, labelWidth, lineheight), "ray diffusion:");
        GUI.TextField(new Rect(x + labelWidth, y, 50, lineheight), reflection.m_ray_diffusion.ToString());
        reflection.m_ray_diffusion = (float)GUI.HorizontalSlider(new Rect(x + labelWidth + 55, y, 100, lineheight), reflection.m_ray_diffusion, 0.0f, 0.2f);
        y += lineheight + margin;

        GUI.Label(new Rect(x, y, labelWidth, lineheight), "falloff distance:");
        GUI.TextField(new Rect(x + labelWidth, y, 50, lineheight), reflection.m_falloff_distance.ToString());
        reflection.m_falloff_distance = (float)GUI.HorizontalSlider(new Rect(x + labelWidth + 55, y, 100, lineheight), reflection.m_falloff_distance, 0.0f, 50.0f);
        y += lineheight + margin;

        GUI.Label(new Rect(x, y, labelWidth, lineheight), "max accumulation:");
        GUI.TextField(new Rect(x + labelWidth, y, 50, lineheight), reflection.m_max_accumulation.ToString());
        reflection.m_max_accumulation = (float)GUI.HorizontalSlider(new Rect(x + labelWidth + 55, y, 100, lineheight), reflection.m_max_accumulation, 1.0f, 100.0f);
        y += lineheight + margin;
        x -= 15.0f;

        y += 10.0f;

        GUI.Label(new Rect(x, y, 300, lineheight), "mouse drag & wheel: move camera");
        y += lineheight + margin;

        GUI.Label(new Rect(x, y, 300, lineheight), "space: show / hide GUI");
        y += lineheight + margin;

        GUI.Label(new Rect(x, y, 300, lineheight), "R: rotation on / off");
        y += lineheight + margin;

        //cbGridPatterns.Show();
    }
Пример #4
0
    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);
    }