1.semantics

比如在effect里这么写:

1 float4x4 matWorldViewProj : WORLDVIEWPROJ;

然后程序里可以这么获得这个变量的handle

1 D3DHANDLE handle = 
2     m_pEffect->GetParameterBySemantic(NULL, "WORLDVIEWPROJ");

看来我之前把一些常用变量的定义写到define.fx里去然后#include"define.fx"来统一不同shader里相同用途的变量的方式或许该改改了呢。

2.annotations

1 texture Tex0 < string name = "tiger.bmp"; >;

 就是括在尖括号里的“初始化语句”而已。必须以分号结尾,只能与Technique、Pass或者最顶层的变量相关联。只能是字符串或者数值类型。在程序里用GetAnnotation或者GetAnnotationByName访问。

3. parameter blocks

1     m_pEffect->SetTechnique( "RenderScene" );
2 
3     m_pEffect->BeginParameterBlock();
4     D3DXVECTOR4 v4( Diffuse.r, Diffuse.g, Diffuse.b, Diffuse.a );
5     m_pEffect->SetVector( "g_vDiffuse", &v4 );
6     m_pEffect->SetFloat( "g_fReflectivity", fReflectivity );
7     m_pEffect->SetFloat( "g_fAnimSpeed", fAnimSpeed );
8     m_pEffect->SetFloat( "g_fSizeMul", fSize );
9     m_hParameters = m_pEffect->EndParameterBlock();

设置effect的变量的方法。但是这种方法只能在ID3dXEffect::Begin()和ID3DXEffect()之外使用。

4.文档中关于Handles的介绍中有说:

Performance tip At the start of your application, perform an initialization pass to generate handles from the strings. From that point on, use only handles. Passing in strings instead of generated handles is slower.

也就是说,我之前那种把GetParameterByName和SetParameterXXX封装在一个函数里的方式会影响一定的效率……

 

 

 

posted on 2013-01-21 00:43  Snafloda  阅读(553)  评论(0编辑  收藏  举报