理解D3D—(2)最多混合几层texture

来源:互联网 发布:java解析wsdl 编辑:程序博客网 时间:2024/05/29 02:54

理解D3D—(2)最多混合几层texture

先提出问题

Q:要是模型有很多层贴图,再加上shadow map,还有ssao,岂不是会不够用了?

A:

参考资料

IDirect3DDevice9::SetTexture

Assigns a texture to a stage for a device.

 

HRESULT SetTexture(DWORD Sampler,IDirect3DBaseTexture9 * pTexture);

 

Parameters

Sampler

Zero based sampler number. Textures are bound to samplers; samplers define sampling state such as the filtering mode and the address wrapping mode. Textures are referenced differently by the programmable and the fixed function pipeline【可编程着色器和固定管线,这两种情况下,textures不同】:

  1. Programmable shaders reference textures using the sampler number. The number of samplers available to a programmable shader is dependent on the shader version【可编程着色器的有效采样器的数目取决于着色器的版本】. For vertex shaders, seeSampler (Direct3D 9 asm-vs). For pixel shaders see Sampler (Direct3D 9 asm-ps).
  2. The fixed function pipeline on the other hand, references textures by texture stage number【另一方面,固定管线取决于texture stage的数目】. The maximum number of samplers is determined from two caps:MaxSimultaneousTextures and MaxTextureBlendStages of the D3DCAPS9 structure.

[in] There are two other special cases for stage/sampler numbers.

  1. A special number called D3DDMAPSAMPLER is used for Displacement Mapping (Direct3D 9).
  2. A programmable vertex shader uses a special number defined by a D3DVERTEXTEXTURESAMPLER when accessing Vertex Textures in vs_3_0 (DirectX HLSL).

 

  • pTexture
  • [in] Pointer to an IDirect3DBaseTexture9 interface, representing the texture being set.
Remarks

IDirect3DDevice9::SetTexture is not allowed if the texture is created with a pool type of D3DPOOL_SCRATCH.IDirect3DDevice9::SetTexture is not allowed with a pool type of D3DPOOL_SYSTEMMEM texture unless DevCaps is set with D3DDEVCAPS_TEXTURESYSTEMMEMORY.

 

 

IDirect3DDevice9::SetTextureStageState

Sets the state value for the currently assigned texture.

HRESULT SetTextureStageState(DWORD Stage,D3DTEXTURESTAGESTATETYPE Type,DWORD Value);
Parameters
Stage
[in] Stage identifier of the texture for which the state value is set. Stage identifiers are zero-based. Devices can have up to eight set textures, so the maximum value allowed for Stage is 7【Stage标识符从0开始。设备可以有8组textures,所以Stage的最大值为7】. 【Q:eight set textures == 8组textures?啥意思?】
Type
[in] Texture state to set. This parameter can be any member of the D3DTEXTURESTAGESTATETYPE enumerated type.
Value
[in] State value to set. The meaning of this value is determined by the Type parameter.

Gamebryo里面

nid3dpass.h

    //  Max number of blending stages supported.//  Should correspond to the number of pixel shader instructions allowed.    static unsigned int ms_uiMaxTextureBlendStages;//  Max number of textures that can be bound to the blending stages.//  Should correspond to the number of texture registers supported by the//  pixel shaders.    static unsigned int ms_uiMaxSimultaneousTextures;//  Max number of samplers supported.//  Can only be greater than ms_uiMaxTextureBlendStages under DX9 when//  PS2.0 (or greater) hardware is supported.    static unsigned int ms_uiMaxSamplers;

内网跟踪了下LightSpeed的版本蜗牛的例子StandardMaterial,ms_uiMaxTextureBlendStages == 8.

  1. Bump maps

  2. Dark maps

  3. Decal maps (up to 3)

  4. Detail maps

  5. Gloss maps

  6. Glow maps

  7. Normal maps
  8. Parallax maps

  9. Environment maps

Q:已经9个了,那Base maps呢?

A:ms_uiMaxSamplers可以比ms_uiMaxTextureBlendStages大了,呵呵,加上Base maps一共10个,还有shadow,猜想ms_uiMaxSamplers至少==11.

2009-9-30 经跟踪代码,Pixel Shader版本大于2,就是16个。就是device capabilities嘛,一初始化程序就能确定。device::GetDeviceCaps(…)

nidx9renderer.cpp

NiDX9Renderer::InitializeDeviceCaps

复制代码
Parameters
pCaps
[out] Pointer to a D3DCAPS9 structure, describing the returned device.
Return Values

If the method succeeds, the return value is D3D_OK. If the method fails, the return value can be D3DERR_INVALIDCALL.

Remarks

IDirect3DDevice9::GetDeviceCaps retrieves the software vertex pipeline capabilities when the device is being used in software vertex processing mode. 

0 0
原创粉丝点击