先提出问题
Q:要是模型有很多层贴图,再加上shadow map,还有ssao,岂不是会不够用了?
A:
参考资料
IDirect3DDevice9::SetTexture
Assigns a texture to a stage for a device.
HRESULT SetTexture( DWORD Sampler, IDirect3DBaseTexture9 * pTexture );
Parameters
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不同】:
[in] There are two other special cases for stage/sampler numbers.
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
);
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.
Bump maps
Dark maps
Decal maps (up to 3)
Detail maps
Gloss maps
Glow maps
Parallax maps
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
再加上ssao,也肯定是是够用的了。
IDirect3DDevice9::GetDeviceCaps
Retrieves the capabilities of the rendering device.【取得渲染设备的能力】
HRESULT GetDeviceCaps( D3DCAPS9 * pCaps );
If the method succeeds, the return value is D3D_OK. If the method fails, the return value can be D3DERR_INVALIDCALL.
IDirect3DDevice9::GetDeviceCaps retrieves the software vertex pipeline capabilities when the device is being used in software vertex processing mode.