Example #1
0
 public void Update()
 {
     if (RuntimeServices.EqualityOperator(Status.menuMode, "on"))
     {
         DepthOfFieldEffect depthOfFieldEffect = (DepthOfFieldEffect)this.GetComponent(typeof(DepthOfFieldEffect));
         float deltaTime = Time.get_deltaTime();
         if (Input.GetKey("1"))
         {
             depthOfFieldEffect.focalDistance -= (float)5 * deltaTime;
         }
         if (Input.GetKey("2"))
         {
             depthOfFieldEffect.focalDistance += (float)5 * deltaTime;
         }
         if (Input.GetKey("3"))
         {
             depthOfFieldEffect.focalRange -= (float)50 * deltaTime;
         }
         if (Input.GetKey("4"))
         {
             depthOfFieldEffect.focalRange += (float)50 * deltaTime;
         }
         depthOfFieldEffect.focalDistance = Mathf.Clamp(depthOfFieldEffect.focalDistance, 1f, 50f);
         depthOfFieldEffect.focalRange    = Mathf.Clamp(depthOfFieldEffect.focalRange, 1f, 1000f);
     }
 }
Example #2
0
 public void OnGUI()
 {
     if (RuntimeServices.EqualityOperator(Status.menuMode, "on"))
     {
         DepthOfFieldEffect depthOfFieldEffect = (DepthOfFieldEffect)this.GetComponent(typeof(DepthOfFieldEffect));
         GUILayout.BeginArea(new Rect((float)10, (float)280, (float)250, (float)100), GUI.get_skin().get_window());
         GUILayout.Label("[focal distance]: 1,2:\n Focal distance = " + depthOfFieldEffect.focalDistance.ToString("f1"), new GUILayoutOption[0]);
         GUILayout.Label("[focal range]: 3,4:\n Focal range = " + depthOfFieldEffect.focalRange.ToString("f1"), new GUILayoutOption[0]);
         GUILayout.EndArea();
     }
 }
Example #3
0
    private static void Render4TapQuad(RenderTexture dest, float offsetX, float offsetY)
    {
        GL.Begin(7);
        Vector2 vector = Vector2.get_zero();

        if (dest != null)
        {
            vector = dest.GetTexelOffset() * 0.75f;
        }
        DepthOfFieldEffect.Set4TexCoords(vector.x, vector.y, offsetX, offsetY);
        GL.Vertex3((float)0, (float)0, 0.1f);
        DepthOfFieldEffect.Set4TexCoords(1f + vector.x, vector.y, offsetX, offsetY);
        GL.Vertex3((float)1, (float)0, 0.1f);
        DepthOfFieldEffect.Set4TexCoords(1f + vector.x, 1f + vector.y, offsetX, offsetY);
        GL.Vertex3((float)1, (float)1, 0.1f);
        DepthOfFieldEffect.Set4TexCoords(vector.x, 1f + vector.y, offsetX, offsetY);
        GL.Vertex3((float)0, (float)1, 0.1f);
        GL.End();
    }
Example #4
0
    private void DownSample4x(RenderTexture source, RenderTexture dest)
    {
        RenderTexture.set_active(dest);
        source.SetGlobalShaderProperty("__RenderTex");
        float offsetX = 1f / (float)source.get_width();
        float offsetY = 1f / (float)source.get_height();

        GL.PushMatrix();
        GL.LoadOrtho();
        Material material = this.GetMaterial();

        checked
        {
            for (int i = 0; i < material.get_passCount(); i++)
            {
                material.SetPass(i);
                DepthOfFieldEffect.Render4TapQuad(dest, offsetX, offsetY);
            }
            GL.PopMatrix();
        }
    }
Example #5
0
    private void FourTapCone(RenderTexture source, RenderTexture dest, int iteration)
    {
        RenderTexture.set_active(dest);
        source.SetGlobalShaderProperty("__RenderTex");
        float offsetX = (0.5f + (float)iteration * this.blurSpread) / (float)source.get_width();
        float offsetY = (0.5f + (float)iteration * this.blurSpread) / (float)source.get_height();

        GL.PushMatrix();
        GL.LoadOrtho();
        Material material = this.GetMaterial();

        checked
        {
            for (int i = 0; i < material.get_passCount(); i++)
            {
                material.SetPass(i);
                DepthOfFieldEffect.Render4TapQuad(dest, offsetX, offsetY);
            }
            GL.PopMatrix();
        }
    }
Example #6
0
        public BaseDeferredRenderGame() : base()
        {
            graphics = new GraphicsDeviceManager(this);

            graphics.PreparingDeviceSettings += new EventHandler <PreparingDeviceSettingsEventArgs>(graphics_PreparingDeviceSettings);
            Content.RootDirectory             = "Content";

            inputHandler = new InputHandlerService(this);

            assetManager = new AssetManager(this);

            renderer = new DeferredRender(this);

            rnd = new Random(DateTime.Now.Millisecond);

            //ggr = new GeographicGridRegistrationSystem(this, new Vector3(10, 5, 20), new BoundingBox(-Vector3.One * 2f, Vector3.One * 2f));

            ppManager = new PostProcessingManager(this);

            test         = new TesterEffect(this);
            test.Enabled = false;
            ppManager.AddEffect(test);

            SSAO         = new SSAOEffect(this, .1f, 1f, .5f, 1f);
            SSAO.Enabled = false;
            ppManager.AddEffect(SSAO);

            //stHPe = new STHardPointEffect(this, 25, 30, new Color(48, 89, 122));
            stHPe         = new STHardPointEffect(this, 25, 30, new Color(41, 77, 107), new Color(.125f, .125f, .125f, 1.0f));
            stHPe.Enabled = false;
            ppManager.AddEffect(stHPe);

            sun         = new SunEffect(this, SunPosition);
            sun.Enabled = false;
            ppManager.AddEffect(sun);

            water             = new WaterEffect(this);
            water.waterHeight = -25f;
            water.Enabled     = false;
            ppManager.AddEffect(water);

            dof         = new DepthOfFieldEffect(this, 5, 30);
            dof.Enabled = false;
            ppManager.AddEffect(dof);

            bloom         = new BloomEffect(this, 1.25f, 1f, 1f, 1f, .25f, 4f);
            bloom.Enabled = false;
            ppManager.AddEffect(bloom);

            haze         = new HeatHazeEffect(this, "Textures/bumpmap", false);
            haze.Enabled = false;
            ppManager.AddEffect(haze);

            radialBlur         = new RadialBlurEffect(this, 0.009f);
            radialBlur.Enabled = false;
            ppManager.AddEffect(radialBlur);

            ripple         = new RippleEffect(this);
            ripple.Enabled = false;
            ppManager.AddEffect(ripple);

            fog         = new FogEffect(this, 50, 100, Color.DarkSlateGray);
            fog.Enabled = false;
            ppManager.AddEffect(fog);

            godRays = new CrepuscularRays(this, SunPosition, "Textures/flare", 1500, 1f, .99f, 1f, .15f, .25f);
            //godRays = new CrepuscularRays(this, SunPosition, "Textures/flare", 1500, 1f, .99f, .1f, 0.12f, .25f);
            godRays.Enabled = false;
            ppManager.AddEffect(godRays);
        }
        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";

            graphics.GraphicsProfile = GraphicsProfile.HiDef;

            graphics.PreferredBackBufferWidth  = 1920;
            graphics.PreferredBackBufferHeight = 1080;

            IsMouseVisible = true;

            kbm = new KeyboardStateManager(this);

            camera          = new Base3DCamera(this, .5f, 20000);
            camera.Position = new Vector3(0, 0, 0);
            Components.Add(camera);
            Services.AddService(typeof(Base3DCamera), camera);

            skyBox = new BaseSkyBox(this, "Textures/SkyBox/NebulaBlue");
            Components.Add(skyBox);

            bunny               = new Base3DObject(this, "Models/bunny", "Shaders/RenderObjectNotTangentsOrTexCoords");
            bunny.Position      = new Vector3(2, -1.5f, -20);
            bunny.LightPosition = LightPosition;
            Components.Add(bunny);

            cube               = new Base3DObject(this, "Models/cube");
            cube.Position      = new Vector3(0, 0, -10);
            cube.ColorAsset    = "Textures/h2mcpCube";
            cube.BumpAsset     = "Textures/h2mcpCubeNormal";
            cube.LightPosition = LightPosition;
            Components.Add(cube);

            bunnies = new Base3DObject[10];
            for (int s = 0; s < 10; s++)
            {
                bunnies[s]               = new Base3DObject(this, "Models/Bunny");
                bunnies[s].Position      = new Vector3(20 + (s * 12), -1.5f, -10 - (s * 12));
                bunnies[s].ColorAsset    = "Textures/WindmillTopColor";
                bunnies[s].BumpAsset     = "Textures/WindmillTopNormal";
                bunnies[s].LightPosition = LightPosition;
                Components.Add(bunnies[s]);
            }

            landShark          = new Base3DObject(this, "Models/landShark");
            landShark.Position = new Vector3(-20, 0, -10);

            landShark.ColorAsset    = "Textures/Speeder_diff";
            landShark.BumpAsset     = "Textures/Speeder_bump";
            landShark.LightPosition = LightPosition;
            Components.Add(landShark);

            earth               = new Base3DObject(this, "Models/sphere");
            earth.Position      = new Vector3(0, 0, -200);
            earth.ColorAsset    = "Textures/Earth_Diffuse";
            earth.BumpAsset     = "Textures/Earth_NormalMap";
            earth.LightPosition = LightPosition;
            Components.Add(earth);

            ppManager = new PostProcessingManager(this);

            fog         = new FogEffect(this, 50, 100, Color.DarkSlateGray);
            fog.Enabled = false;
            ppManager.AddEffect(fog);

            GodRays         = new CrepuscularRays(this, LightPosition, "Textures/flare", 1500, .99f, .99f, .5f, .12f, .25f);
            GodRays.Enabled = false;
            ppManager.AddEffect(GodRays);

            sun         = new SunEffect(this, LightPosition);
            sun.Enabled = false;
            ppManager.AddEffect(sun);

            bloom         = new BloomEffect(this, 1.25f, 1f, 1f, 1f, .25f, 4f);
            bloom.Enabled = false;
            ppManager.AddEffect(bloom);

            dof         = new DepthOfFieldEffect(this, 5, 30);
            dof.Enabled = false;
            ppManager.AddEffect(dof);

            haze         = new HeatHazeEffect(this, "Textures/bumpmap", false);
            haze.Enabled = false;
            ppManager.AddEffect(haze);

            radialBlur         = new RadialBlurEffect(this, 0.009f);
            radialBlur.Enabled = false;
            ppManager.AddEffect(radialBlur);

            ripple         = new RippleEffect(this);
            ripple.Enabled = false;
            ppManager.AddEffect(ripple);

            sepia         = new SepiaEffect(this);
            sepia.Enabled = false;
            ppManager.AddEffect(sepia);

            greyScale         = new GreyScaleEffect(this);
            greyScale.Enabled = false;
            ppManager.AddEffect(greyScale);

            invert         = new InvertColorEffect(this);
            invert.Enabled = false;
            ppManager.AddEffect(invert);

            colorFilter         = new ColorFilterEffect(this, Color.White, .5f, .5f, .5f);
            colorFilter.Enabled = false;
            ppManager.AddEffect(colorFilter);

            bleach         = new BleachEffect(this, 1);
            bleach.Enabled = false;
            ppManager.AddEffect(bleach);

            scanLines         = new ScanLinesEffect(this, .001f, .001f, 128);
            scanLines.Enabled = false;
            ppManager.AddEffect(scanLines);

            deRezed         = new DeRezedEffect(this, 128);
            deRezed.Enabled = false;
            ppManager.AddEffect(deRezed);
        }