当前位置: 首页>>代码示例>>C#>>正文


C# Device.CreateDepthStencilSurface方法代码示例

本文整理汇总了C#中Device.CreateDepthStencilSurface方法的典型用法代码示例。如果您正苦于以下问题:C# Device.CreateDepthStencilSurface方法的具体用法?C# Device.CreateDepthStencilSurface怎么用?C# Device.CreateDepthStencilSurface使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Device的用法示例。


在下文中一共展示了Device.CreateDepthStencilSurface方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: initShadows

        private void initShadows(Device d3dDevice)
        {


            //--------------------------------------------------------------------------------------
            // Creo el shadowmap. 
            // Format.R32F
            // Format.X8R8G8B8
            g_pShadowMap = new Texture(d3dDevice, SHADOWMAP_SIZE, SHADOWMAP_SIZE,
                                        1, Usage.RenderTarget, Format.R32F,
                                        Pool.Default);

            // tengo que crear un stencilbuffer para el shadowmap manualmente
            // para asegurarme que tenga la el mismo tamaño que el shadowmap, y que no tenga 
            // multisample, etc etc.
            g_pDSShadow = d3dDevice.CreateDepthStencilSurface(SHADOWMAP_SIZE,
                                                             SHADOWMAP_SIZE,
                                                             DepthFormat.D24S8,
                                                             MultiSampleType.None,
                                                             0,
                                                             true);

            // por ultimo necesito una matriz de proyeccion para el shadowmap, ya 
            // que voy a dibujar desde el pto de vista de la luz.
            // El angulo tiene que ser mayor a 45 para que la sombra no falle en los extremos del cono de luz
            // de hecho, un valor mayor a 90 todavia es mejor, porque hasta con 90 grados es muy dificil
            // lograr que los objetos del borde generen sombras
            Control panel3d = GuiController.Instance.Panel3d;
            float aspectRatio = (float)panel3d.Width / (float)panel3d.Height;
            g_mShadowProj = Matrix.PerspectiveFovLH(Geometry.DegreeToRadian(80),
                aspectRatio, 50, 5000);
            d3dDevice.Transform.Projection =
                Matrix.PerspectiveFovLH(Geometry.DegreeToRadian(45.0f),
                aspectRatio, near_plane, far_plane);

            float K = 300;
            GuiController.Instance.Modifiers.addVertex3f("LightLookFrom", new Vector3(-K, -K, -K), new Vector3(K, K, K), new Vector3(80, 120, 0));
            GuiController.Instance.Modifiers.addVertex3f("LightLookAt", new Vector3(-K, -K, -K), new Vector3(K, K, K), new Vector3(0, 0, 0));
        }
开发者ID:Dkazarian,项目名称:TP-TGC-Commandos-ValePorUnNombreGeek,代码行数:39,代码来源:PruebaShaders.cs

示例2: Init

        internal override void Init()
        {
            GuiController.Instance.CustomRenderEnabled = true;
            renderFlux = "RenderAll";//1.21 GigaWatts

            d3dDevice = GuiController.Instance.D3dDevice;
            MediaDir = GuiController.Instance.AlumnoEjemplosMediaDir + "Los_Borbotones\\";
            ShaderDir = GuiController.Instance.AlumnoEjemplosMediaDir + "Los_Borbotones\\Shaders\\";

            //Cargar Shader personalizado
            string compilationErrors;
            theShader = Effect.FromFile(d3dDevice,
                GuiController.Instance.AlumnoEjemplosMediaDir + "Los_Borbotones\\Shaders/postProcess.fx",
                null, null, ShaderFlags.PreferFlowControl, null, out compilationErrors);
            if (theShader == null)
            {
                throw new Exception("Error al cargar shader. Errores: " + compilationErrors);
            }
            //Configurar Technique dentro del shader
            theShader.Technique = "Propagation";

            depthStencil = d3dDevice.CreateDepthStencilSurface(d3dDevice.PresentationParameters.BackBufferWidth,
                                                                         d3dDevice.PresentationParameters.BackBufferHeight,
                                                                         DepthFormat.D24S8,
                                                                         MultiSampleType.None,
                                                                         0,
                                                                         true);

            // Inicializar el/los render target

            firstRenderTarget = new Texture(d3dDevice, d3dDevice.PresentationParameters.BackBufferWidth
                , d3dDevice.PresentationParameters.BackBufferHeight, 1, Usage.RenderTarget,
                Format.X8R8G8B8, Pool.Default);

            glowMapRenderTarget = new Texture(d3dDevice, d3dDevice.PresentationParameters.BackBufferWidth / 4
                , d3dDevice.PresentationParameters.BackBufferHeight / 4, 1, Usage.RenderTarget,
                Format.X8R8G8B8, Pool.Default);

            DownFilterRenderTarget = new Texture(d3dDevice, d3dDevice.PresentationParameters.BackBufferWidth / 4
                , d3dDevice.PresentationParameters.BackBufferHeight / 4, 1, Usage.RenderTarget,
                Format.X8R8G8B8, Pool.Default);

            gaussBlurAuxRenderTarget = new Texture(d3dDevice, d3dDevice.PresentationParameters.BackBufferWidth / 4
                , d3dDevice.PresentationParameters.BackBufferHeight / 4, 1, Usage.RenderTarget,
                Format.X8R8G8B8, Pool.Default);

            // inicializar valores en el Shader
            theShader.SetValue("g_RenderTarget", firstRenderTarget);
            theShader.SetValue("g_GlowMap", DownFilterRenderTarget);

            //       Resolucion de pantalla
            theShader.SetValue("screen_dx", d3dDevice.PresentationParameters.BackBufferWidth);
            theShader.SetValue("screen_dy", d3dDevice.PresentationParameters.BackBufferHeight);
            float desf_x = (float)(1 / (d3dDevice.PresentationParameters.BackBufferWidth * 0.5));
            float desf_y = (float)(1 / (d3dDevice.PresentationParameters.BackBufferHeight * 0.5));

            //Crea los 2 Triangulos
            CustomVertex.PositionTextured[] Vertices = new CustomVertex.PositionTextured[]
            {
                new CustomVertex.PositionTextured( -1-desf_x, 1+desf_y, 1, 0,0),
                new CustomVertex.PositionTextured(1,  1+desf_y, 1, 1,0),
                new CustomVertex.PositionTextured(-1-desf_x, -1, 1, 0,1),
                new CustomVertex.PositionTextured(1,-1, 1, 1,1)
            };
            //vertex buffer de los triangulos
            quadVertexBuffer = new VertexBuffer(typeof(CustomVertex.PositionTextured),
                    4, d3dDevice, Usage.Dynamic | Usage.WriteOnly,
                        CustomVertex.PositionTextured.Format, Pool.Default);
            quadVertexBuffer.SetData(Vertices, 0, LockFlags.None);

            GameManager.Instance.Init();
            HUDManager.Instance.Init();
        }
开发者ID:SantiagoFoster,项目名称:AlumnoEjemplos,代码行数:73,代码来源:PostProcessManager.cs


注:本文中的Device.CreateDepthStencilSurface方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。