Ejemplo n.º 1
0
        protected override void Draw(DrawState state)
        {
            //update some of the text before drawing..

            //get the camera position
            Vector3 cameraPosition;

            camera.GetCameraPosition(out cameraPosition);

            //Set the position text to the camera position
            positionDisplay.Text.Clear();

            positionDisplay.Text.Append(cameraPosition.X);
            positionDisplay.Text.Append(", ");
            positionDisplay.Text.Append(cameraPosition.Y);
            positionDisplay.Text.Append(", ");
            positionDisplay.Text.Append(cameraPosition.Z);

            //fade the embedded element in and out with a Sine pattern
            Color colour = embeddedElement.Colour;

            colour.A = (byte)(Math.Sin(state.TotalTimeSeconds * 4) * 128 + 127);
            embeddedElement.Colour = colour;



            //draw everything
            drawToScreen.Draw(state);
        }
Ejemplo n.º 2
0
        //This is the main application draw method. All drawing code should go in here.
        //
        //Any drawing should be done through, or using the DrawState object.
        //Do not store a reference to a DrawState - if a method doesn't give access to it, you shouldn't be drawing in that method.
        //The most useful GraphicsDevice functionality is covered by the DrawState or other objects in Xen/Xen.Ex
        //The vast majority of applications shouldn't need to directly access the graphics device.
        protected override void Draw(DrawState state)
        {
            //perform the draw to the screen.
            drawToScreen.Draw(state);

            //at this point the screen has been drawn...
        }
Ejemplo n.º 3
0
        protected override void Draw(DrawState state)
        {
            //rotate the camera around the ground plane
            RotateCamera(state);

            //draw everything
            drawToScreen.Draw(state);
        }
Ejemplo n.º 4
0
        protected override void Draw(DrawState state)
        {
            //rotate the camera around the scene (similar to tutorial 14)
            RotateCamera(state);

            //draw the scene
            drawToScreen.Draw(state);
        }
Ejemplo n.º 5
0
        //main application draw method
        protected override void Draw(DrawState state)
        {
            //NEW CODE
            //set the global colour float4 value to 1,0,0,1, which is bright red with an alpha of 1.
            state.SetShaderGlobal("colour", new Vector4(1, 0, 0, 1));

            //draw to the screen.
            drawToScreen.Draw(state);
        }
Ejemplo n.º 6
0
        //main application draw method
        protected override void Draw(DrawState state)
        {
            //move the sphere from left to right
            sphere.position = new Vector3((float)Math.Sin(state.TotalTimeSeconds) * 6, 0, 0);
            //and make sure the bounding box matches it
            sphereBoundingBox.position = sphere.position;


            //draw to the screen.
            drawToScreen.Draw(state);
        }
Ejemplo n.º 7
0
        //main application draw method
        protected override void Draw(DrawState state)
        {
            //required by Tutorial03 shader
            state.SetShaderGlobal("colour", new Vector4(1, 0, 0, 1));

            //Draw the off screen texture (the texture cannot be used until after the first time it's drawn!)
            //In this tutorial, the texture is drawn every frame
            drawToTexture.Draw(state);

            //draw to the screen.
            drawToScreen.Draw(state);
        }
Ejemplo n.º 8
0
        //main application draw method
        protected override void Draw(DrawState state)
        {
            //used by Tutorial03 shader
            state.SetShaderGlobal("colour", new Vector4(1, 0, 0, 1));

            //NEW CODE
            //Draw the off screen texture (the texture should not be used until after it's been drawn!)
            //In this example, the texture is drawn every frame
            drawToTexture.Draw(state);

            //draw to the screen.
            //(drawing to the screen should almost always be last, and only happen once per frame)
            drawToScreen.Draw(state);
        }
Ejemplo n.º 9
0
        protected override void Draw(DrawState state)
        {
            //draw the shadow map texture first,
            drawShadowDepth.Draw(state);

            //apply the blur filter to the shadow texture
            shadowDepthBlurFilter.Draw(state);


            //set a global light collection (that all models will use)
            state.PushDrawFlag(new MaterialLightCollection.LightCollectionFlag(ambientLight));

            //draw the scene to the screen
            drawToScreen.Draw(state);

            //reset the flag
            state.PopDrawFlag <MaterialLightCollection.LightCollectionFlag>();
        }
Ejemplo n.º 10
0
        protected override void Draw(DrawState state)
        {
            //store the global colour
            state.SetShaderGlobal("colour", Color.Red.ToVector4());

            //set the on screen text
            statusText.Text.Clear();
            //framerate
            statusText.Text += (int)state.ApproximateFrameRate;
            statusText.Text += " fps";

#if DEBUG
            //display some statistics about the render
            DrawStatistics stats;
            state.GetPreviousFrameStatistics(out stats);

            statusText.Text += ", ";
            statusText.Text += stats.DefaultCullerTestBoxCount + stats.DefaultCullerTestSphereCount;
            statusText.Text += " cull tests performed, ";
            if (state.SupportsHardwareInstancing)
            {
                statusText.Text += stats.InstancesDrawn;
                statusText.Text += stats.InstancesDrawn == 1 ? " instance" : " instances";
                statusText.Text += " drawn (hardware instancing)";
            }
            else
            {
                statusText.Text += stats.DrawIndexedPrimitiveCallCount;
                statusText.Text += stats.DrawIndexedPrimitiveCallCount == 1 ? " instance" : " instances";
                statusText.Text += " drawn";
            }
#endif
            statusText.Text.AppendLine();
            statusText.Text += cullButtonText;

            //draw everything
            drawToScreen.Draw(state);
        }
Ejemplo n.º 11
0
 protected override void Draw(DrawState state)
 {
     drawToScreen.Draw(state);
 }
Ejemplo n.º 12
0
 //main application draw method
 protected override void Draw(DrawState state)
 {
     //draw to the screen.
     //This causes the sphere to be drawn (because it was added to the screen)
     drawToScreen.Draw(state);
 }
Ejemplo n.º 13
0
 //main application draw method
 protected override void Draw(DrawState state)
 {
     //draw to the screen.
     drawToScreen.Draw(state);
 }
Ejemplo n.º 14
0
        protected override void Draw(DrawState state)
        {
            //setup the shadow map direction
            shadowCamera.LookAt(this.sceneConfig.SunDirection, new Vector3(), new Vector3(0, 1, 0));

            //bind the cubemap and it's SH

            //get the background Spherical Harmonic in GPU format
            this.sceneConfig.BackgroundScene.SphericalHarmonic.CopyToGpuArray(this.cubeMapGpuSH);

            //setup various shader globals
            state.SetShaderGlobal("CubeRgbmTexture", this.sceneConfig.BackgroundScene.CubeMap);
            state.SetShaderGlobal("EnvironmentSH", this.cubeMapGpuSH);

            state.SetShaderGlobal("RgbmImageRenderScale", new Vector2(this.sceneConfig.RgbmImageScale, this.sceneConfig.RgbmRenderScale));

            //setup shader specific values:
            state.SetShaderGlobal("BloomScaleThreshold", new Vector2(this.sceneConfig.BloomScale, this.sceneConfig.BloomThreshold));
            state.SetShaderGlobal("LensExposure", this.renderConfig.LensExposure);

            //output specific constants
            outputShader.UseExposureTonemapping   = this.renderConfig.UseExposureTonemapping ? 1 : 0;
            outputShader.UseFilmApproxTonemapping = this.renderConfig.UseFilmApproximationTonemapping ? 1 : 0;
            outputShader.UseInverseOneTonemapping = this.renderConfig.UseInverseOneTonemapping ? 1 : 0;
            outputShader.UseGammaCorrection       = this.renderConfig.UseGammaCorrection ? 1 : 0;

            //setup constants specific to the model display shader.
            //These are shared between the two character shaders, so for simplicity they are global.
            state.SetShaderGlobal("SkinLightScatter", this.sceneConfig.SkinLightScattering * this.renderConfig.SkinLightScatteringScale);
            state.SetShaderGlobal("SunRgbIntensity", new Vector4(this.sceneConfig.SunColour, this.sceneConfig.SunIntensity));
            state.SetShaderGlobal("SunDirection", this.sceneConfig.SunDirection);
            state.SetShaderGlobal("SunSpecularPowerIntensity", new Vector2(this.sceneConfig.SunSpecularPower, this.sceneConfig.SunSpecularIntensity));

            state.SetShaderGlobal("AmbientDiffuseSpecularScale", new Vector3(this.renderConfig.AmbientSphericalHarmonicScale, this.renderConfig.DiffuseLightingScale, this.renderConfig.SpecularLightingScale));
            state.SetShaderGlobal("UseAlbedoOcclusionShadow", new Vector3(this.renderConfig.AlbedoTextureScale, this.renderConfig.AmbientOcclusionTextureScale, this.renderConfig.ShadowMapTermScale));


            //Ok, now get on with drawing.


            //set the shadow scene
            shadowDrawer.Scene = this.modelRotation;

            //draw the shadow map first
            if (this.renderConfig.ShadowMapTermScale > 0)
            {
                shadowMap.Draw(state);
            }


            //Set the shadow map projection shader globals:

            //Get the ICamera interface to the shadow camera
            //(ICamera exposes a lot of internally used methods, that are otherwise rarely needed)
            ICamera shadowCameraInterface = this.shadowCamera;

            //get the view*projection matrix of the shadow map
            Matrix view, projection, viewProjection;

            shadowCameraInterface.GetViewMatrix(out view);
            shadowCameraInterface.GetProjectionMatrix(out projection, shadowMap.Size);

            Matrix.Multiply(ref view, ref projection, out viewProjection);

            //set the shader globals
            state.SetShaderGlobal("ShadowMapProjection", ref viewProjection);
            state.SetShaderGlobal("ShadowMapSize", shadowMap.Size);
            state.SetShaderGlobal("ShadowTexture", shadowMap.GetTexture());



            //draw the main render target
            drawToRenderTarget.Draw(state);

            //setup and draw the bloom pass
            bloomPassShader.InputTexture = drawToRenderTarget.GetTexture();
            bloomRenderTarget.Draw(state);

            //blur the bloom pass once
            bloomBlurPass.Draw(state);


            //setup the debug render views
            this.rgmbTextureAlphaShader.DisplayTexture = this.drawToRenderTarget.GetTexture();
            this.bloomTextureDisplay.Visible           = this.renderConfig.ShowBloomRenderTarget;
            this.rgbmTextureDisplay.Visible            = this.renderConfig.ShowEncodedRgbmRenderTarget;
            this.rgbmTextureAlphaDisplay.Visible       = this.renderConfig.ShowEncodedRgbmRenderTarget;

            //setup the output shader
            outputShader.InputTexture = drawToRenderTarget.GetTexture();
            outputShader.BloomTexture = bloomRenderTarget.GetTexture();

            //draw everything else to the screen
            drawToScreen.Draw(state);
        }
Ejemplo n.º 15
0
 protected override void Draw(DrawState state)
 {
     //draw everything
     drawToScreen.Draw(state);
 }