render states

Direct3D is basically a state machine

不会改变直到我们改变

以下是渲染的设置

1. ID3D11RasterizerState: This interface represents a state group used to configure the rasterization stage of the pipeline.
2. ID3D11BlendState: This interface represents a state group used to configure blending operations. We will discuss these states in
the chapter on blending; by default, blending is disabled, so we do not need to worry about it for now.
3. ID3D11DepthStencilState: This interface represents a state group used to configure the depth and stencil tests. We will discuss
these states in the chapter on the stencil buffer; by default, stenciling is disabled, so we do not need to worry about it for now. The
default depth test settings are set to do the standard depth test as described in

HRESULT ID3D11Device::CreateRasterizerState(
    const D3D11_RASTERIZER_DESC *pRasterizerDesc,
    ID3D11RasterizerState **ppRasterizerState);

D3D11_RASTERIZER_DESC定义

typedef struct D3D11_RASTERIZER_DESC {
    D3D11_FILL_MODE FillMode; // Default: D3D11_FILL_SOLID
    D3D11_CULL_MODE CullMode; // Default: D3D11_CULL_BACK
    BOOL FrontCounterClockwise; // Default: false
    INT DepthBias; // Default: 0
    FLOAT DepthBiasClamp; // Default: 0.0f
    FLOAT SlopeScaledDepthBias; // Default: 0.0f
    BOOL DepthClipEnable; // Default: true
    BOOL ScissorEnable; // Default: false
    BOOL MultisampleEnable; // Default: false
    BOOL AntialiasedLineEnable; // Default: false
} D3D11_RASTERIZER_DESC;

example codes

D3D11_RASTERIZER_DESC rsDesc;
ZeroMemory(&rsDesc, sizeof(D3D11_RASTERIZER_DESC));
rsDesc.FillMode = D3D11_FILL_SOLID;
rsDesc.CullMode = D3D11_CULL_NONE;
rsDesc.FrontCounterClockwise = false;
rsDesc.DepthClipEnable = true;
HR(md3dDevice->CreateRasterizerState(&rsDesc, &mNoCullRS));

切换state

ID3D11RasterizerState* mWireframeRS;
ID3D11RasterizerState* mSolidRS;
...
// Switch between the render state objects in the draw function.
md3dImmediateContext->RSSetState(mSolidRS);
DrawObject();
md3dImmediateContext->RSSetState(mWireframeRS);
DrawObject();
时间: 2024-11-05 06:26:40

render states的相关文章

Unity3D Optimizing Graphics Performance for iOS

原地址:http://blog.sina.com.cn/s/blog_72b936d801013ptr.html icense Comparisons http://unity3d.com/unity/licenses#iphone Optimizing Graphics Performance http://unity3d.com/support/documentation/Manual/Optimizing Graphics Performance.html iOS A useful bac

INITIALIZING DIRECT3D

初始化Direct3D需要一下几个步骤: 1. Create the ID3D11Device and ID3D11DeviceContext interfaces using the D3D11CreateDevice function.2. Check 4X MSAA quality level support using the ID3D11Device::CheckMultisampleQualityLevels method.3. Describe the characteristic

DirectX 9.0c游戏开发手记之RPG编程自学日志之13: Drawing with DirectX Graphics (用DirectX图形绘图)(第6节)

        本文由哈利_蜘蛛侠原创,转载请注明出处!有问题请联系[email protected]   这一次我们继续来讲述Jim Adams老哥的RPG编程书籍第二版第二章的第6节:Alpha Blending,也就是alpha混合.这一节的内容不多,所以就一次性讲完吧! 我们先将这一节的各小节的标题列在下面,以供大家参考: 1. Enabling Alpha Blending (开启alpha混合) 2. Drawing with Alpha Blending (用alpha混合进行绘图

Depth Bias 以及 Ogre材质中的depth_bias

深度偏移用来解决共面情况下出现闪烁的问题 通过给多边形增加一个z方向深度偏移(depth bias,z_bias),使3D空间的共面多边形看起来好像并不共面,以便它们能够被正确渲染.这种技术是很有用的,例如,我们要渲染投射在墙上的阴影,这时候墙和阴影共面,如果没有深度偏移,先渲染墙,再渲染阴影,由于depth test,阴影可能不能正确显示.我们给墙设置一个深度偏移,使它增大,例如z增加0.01,先渲染墙,再渲染阴影,则墙和阴影可以正确的显示. Depth-bias操作在clipping之后进行

hge source explor 0xC graphics Ⅲ

这里关于图形模块的内部接口部分 内部调用接口 内部接口主要完成:关于固定流水线的设置:dx的初始化:dx的结束 可以说内部接口已经完成了左右工作,只要进行组合调用即可 _GfxInit() DX的初始化函数 Direct3DCreate8 创建接口 GetAdapterIdentifier 获得设备信息,在这里可以查询设备能够做到什么 PRESENT_PARAMETER 参数的填写 CreateDevice 创建设备 _AdjustWindow 这个函数原来在window模块里已经考虑过,在这里

DirectX 9.0c游戏开发手记之RPG编程自学日志之16: Drawing with DirectX Graphics (用DirectX图形绘图)(第10-12节)

        本文由哈利_蜘蛛侠原创,转载请注明出处!有问题请联系[email protected]   这一次我们继续来讲述Jim Adams 老哥的RPG编程书籍第二版第二章的第10节:Particles (粒子),第11节:Depth Sorting and Z-Buffering (深度排序和Z-缓存),以及第12节:Working with Viewports (使用视口).这两节的内容都不多,所以就放在一期里面讲了. 原文翻译: ==========================

Discussion about z pre-pass

Z pre-pass In the rendering Process, the first pass render to a depth buffer to get the front layer of depth. Next, we use this depth layer to cull the objects behind where a lot of draws are omitted. This technique works well when we render transpar

龙书11_chapter_6 一:一般绘制流程

先看BoxDemo的前几节, 1.vertex input  Layout 2.vertexBuffer 3.IndexBuffer 4.vertexShader 5.constant Buffer 6.pixelShader 7.renderState 8.effect 1.vertex input  Layout Once we have defined a vertex structure, we need to provide Direct3D with a description of

DirectX 11游戏编程学习笔记之7: 第6章Drawing in Direct3D(在Direct3D中绘制)(重点回顾+勘误)

        本文由哈利_蜘蛛侠原创,转载请注明出处!有问题欢迎联系[email protected]         注:我给的电子版是700多页,而实体书是800多页,所以我在提到相关概念的时候,会使用章节号而非页码.同样的情况适合于"龙书"第二版. 上一期的地址: DX 11游戏编程学习笔记之6 这一章应该是本书最长的一章了,可能也是最难的一章,所以大家一定要好好消化,仔细学习!这一章大致相当于"龙书"第二版的第7章和第8章,还添加了一些别的东西. 由于这一