コード例 #1
0
        /// <summary>
        ///
        /// </summary>
        private void StartD3D()
        {
#if DX11
            var adapter = GetBestAdapter();
            if (adapter == null)
            {
                System.Windows.MessageBox.Show("No DirectX 10 or higher adapter found, a software adapter will be used!", "Warning");
                this.device = new Direct3D11.Device(DriverType.Warp, DeviceCreationFlags.BgraSupport, FeatureLevel.Level_11_0);
            }
            else
            {
                this.device = new Direct3D11.Device(adapter, DeviceCreationFlags.BgraSupport);
                //this.device = new Direct3D11.Device(Direct3D.DriverType.Hardware, DeviceCreationFlags.BgraSupport, Direct3D.FeatureLevel.Level_11_0);
            }
#else
            this.device = new Direct3D11.Device(Direct3D.DriverType.Hardware, DeviceCreationFlags.BgraSupport, Direct3D.FeatureLevel.Level_10_1);
#endif
            this.surfaceD3D = new DX11ImageSource();
            this.surfaceD3D.IsFrontBufferAvailableChanged += this.OnIsFrontBufferAvailableChanged;
            this.effects = EffectsManager.Instance;
            this.effects.InitEffects(this.device);
            this.deferredRenderer = new DeferredRenderer();

            this.CreateAndBindTargets();
            this.SetDefaultRenderTargets();
            this.Source = this.surfaceD3D;
        }
コード例 #2
0
            public DeferredLightingVariables(EffectsManager effectsContainer)
            {
                this.screenGeometryEffect    = effectsContainer.GetEffect(Techniques.RenderDeferredLighting);
                this.screenGeometryLayout    = effectsContainer.GetLayout(Techniques.RenderDeferredLighting);
                this.screenGeometryTechnique = screenGeometryEffect.GetTechniqueByName(Techniques.RenderDeferredLighting);

                this.renderPassAmbient          = this.screenGeometryTechnique.GetPassByName("AmbientPass");
                this.renderPassDirectionalLight = this.screenGeometryTechnique.GetPassByName("DirectionalLightPass");
                this.renderPassPointLight       = this.screenGeometryTechnique.GetPassByName("PointLightPass");
                this.renderPassSpotLight        = this.screenGeometryTechnique.GetPassByName("SpotLightPass");

                this.vLightDir     = this.screenGeometryEffect.GetVariableByName("vLightDir").AsVector();
                this.vLightPos     = this.screenGeometryEffect.GetVariableByName("vLightPos").AsVector();
                this.vLightAtt     = this.screenGeometryEffect.GetVariableByName("vLightAtt").AsVector();
                this.vLightSpot    = this.screenGeometryEffect.GetVariableByName("vLightSpot").AsVector();
                this.vLightColor   = this.screenGeometryEffect.GetVariableByName("vLightColor").AsVector();
                this.vLightAmbient = this.screenGeometryEffect.GetVariableByName("vLightAmbient").AsVector();

                this.vEyePos     = this.screenGeometryEffect.GetVariableByName("vEyePos").AsVector();
                this.mLightModel = this.screenGeometryEffect.GetVariableByName("mLightModel").AsMatrix();
                this.mLightView  = this.screenGeometryEffect.GetVariableByName("mLightView").AsMatrix();
                this.mLightProj  = this.screenGeometryEffect.GetVariableByName("mLightProj").AsMatrix();

                this.gDepthStencilShaderResourceVariables = this.screenGeometryEffect.GetVariableByName("DepthTexture").AsShaderResource();
                this.gBufferShaderResourceVariables       = new EffectShaderResourceVariable[4];
                this.gBufferShaderResourceVariables[0]    = this.screenGeometryEffect.GetVariableByName("NormalTexture").AsShaderResource();
                this.gBufferShaderResourceVariables[1]    = this.screenGeometryEffect.GetVariableByName("DiffuseAlbedoTexture").AsShaderResource();
                this.gBufferShaderResourceVariables[2]    = this.screenGeometryEffect.GetVariableByName("SpecularAlbedoTexture").AsShaderResource();
                this.gBufferShaderResourceVariables[3]    = this.screenGeometryEffect.GetVariableByName("PositionTexture").AsShaderResource();
            }
コード例 #3
0
            public DeferredLightingVariables(EffectsManager effectsContainer)
            {
                this.screenGeometryEffect = effectsContainer.GetEffect(Techniques.RenderDeferredLighting);
                this.screenGeometryLayout = effectsContainer.GetLayout(Techniques.RenderDeferredLighting);
                this.screenGeometryTechnique = screenGeometryEffect.GetTechniqueByName(Techniques.RenderDeferredLighting);

                this.renderPassAmbient = this.screenGeometryTechnique.GetPassByName("AmbientPass");
                this.renderPassDirectionalLight = this.screenGeometryTechnique.GetPassByName("DirectionalLightPass");
                this.renderPassPointLight = this.screenGeometryTechnique.GetPassByName("PointLightPass");
                this.renderPassSpotLight = this.screenGeometryTechnique.GetPassByName("SpotLightPass");

                this.vLightDir = this.screenGeometryEffect.GetVariableByName("vLightDir").AsVector();
                this.vLightPos = this.screenGeometryEffect.GetVariableByName("vLightPos").AsVector();
                this.vLightAtt = this.screenGeometryEffect.GetVariableByName("vLightAtt").AsVector();
                this.vLightSpot = this.screenGeometryEffect.GetVariableByName("vLightSpot").AsVector();
                this.vLightColor = this.screenGeometryEffect.GetVariableByName("vLightColor").AsVector();
                this.vLightAmbient = this.screenGeometryEffect.GetVariableByName("vLightAmbient").AsVector();

                this.vEyePos = this.screenGeometryEffect.GetVariableByName("vEyePos").AsVector();
                this.mLightModel = this.screenGeometryEffect.GetVariableByName("mLightModel").AsMatrix();
                this.mLightView = this.screenGeometryEffect.GetVariableByName("mLightView").AsMatrix();
                this.mLightProj = this.screenGeometryEffect.GetVariableByName("mLightProj").AsMatrix();

                this.gDepthStencilShaderResourceVariables = this.screenGeometryEffect.GetVariableByName("DepthTexture").AsShaderResource();
                this.gBufferShaderResourceVariables = new EffectShaderResourceVariable[4];
                this.gBufferShaderResourceVariables[0] = this.screenGeometryEffect.GetVariableByName("NormalTexture").AsShaderResource();
                this.gBufferShaderResourceVariables[1] = this.screenGeometryEffect.GetVariableByName("DiffuseAlbedoTexture").AsShaderResource();
                this.gBufferShaderResourceVariables[2] = this.screenGeometryEffect.GetVariableByName("SpecularAlbedoTexture").AsShaderResource();
                this.gBufferShaderResourceVariables[3] = this.screenGeometryEffect.GetVariableByName("PositionTexture").AsShaderResource();
            }
コード例 #4
0
ファイル: DPFCanvas.cs プロジェクト: BEEden/Diplomarbeit
        /// <summary>
        /// 
        /// </summary>
        private void StartD3D()
        {
#if DX11
            var adapter = GetBestAdapter();
            if (adapter == null)
            {                
                System.Windows.MessageBox.Show("No DirectX 10 or higher adapter found, a software adapter will be used!", "Warning");
                this.device = new Direct3D11.Device(DriverType.Warp, DeviceCreationFlags.BgraSupport, FeatureLevel.Level_11_0);
            }
            else
            {
                this.device = new Direct3D11.Device( adapter, DeviceCreationFlags.BgraSupport);
                //this.device = new Direct3D11.Device(Direct3D.DriverType.Hardware, DeviceCreationFlags.BgraSupport, Direct3D.FeatureLevel.Level_11_0); 
            }       
#else
            this.device = new Direct3D11.Device(Direct3D.DriverType.Hardware, DeviceCreationFlags.BgraSupport, Direct3D.FeatureLevel.Level_10_1);                        
#endif            
            this.surfaceD3D = new DX11ImageSource();
            this.surfaceD3D.IsFrontBufferAvailableChanged += this.OnIsFrontBufferAvailableChanged;
            this.effects = EffectsManager.Instance;
            this.effects.InitEffects(this.device);
            this.deferredRenderer = new DeferredRenderer();
            
            this.CreateAndBindTargets();
            this.SetDefaultRenderTargets();
            this.Source = this.surfaceD3D;
        }