コード例 #1
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);
        }
コード例 #2
0
ファイル: Content 01.cs プロジェクト: ARLM-Attic/xna-xen
        //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);
        }
コード例 #3
0
ファイル: Draw to texture.cs プロジェクト: ARLM-Attic/xna-xen
        //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);
        }
コード例 #4
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);
        }
コード例 #5
0
ファイル: HDR Lighting.cs プロジェクト: ARLM-Attic/xna-xen
        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);
        }