shader学习笔记(4)-关于cg1.2和cg1.4的发展历程
流水帐,随手记下:
- 直到现在我才明白,CG是CG,CGFX是CGFX,CG是一种语言,CGFX是一套编程模型,而我们要做的是封装cgFX,有了CGFX就有更强的一种表达,可以对不同的Profile指定配置,可以设定openGL state。
- 对于D3D的绘制方式而言,是根据名字得到Technique的句柄,然后每次绘制Mesh前设定生效的Technique,在遍历该Technique下的所有Pass,逐一进行绘制;
- 那么对于OpenGL来说,我们只知道在CreateProgram的时候指定一个入口函数,那对于具有多个Technique的情况我们还不知道怎么进行切换,是用两个Program表示呢,还是调用什么参数可以切换?
- 但是不管怎么表示,从概念上是应该允许像D3D那样指定的,即在某一个Mesh绘制前指定用某一个Effect的某一个Technique,甚至Pass。
- 后来查到在cg1.2发布的cg_tookit里边提供了CgFx的很好的支持,能够想D3D Effect格式那样ICgFxEffect->setTechnique(),有pass->begin(),pass->end()这种方法,但是不知道为什么到cg1.4把这些东西去掉了。在cgReleaseNote里边写到:
- Complete rewrite of CgFX, including an API integrated with the Cg runtime API, support for extensible, cross-platform graphics state management, and support for unsized arrays and interfaces.
再看看Nvidia到底怎么说的:太恶心了,就是说原来如果你用了很好实现的CgFx,现在对不起,不能用了。 所以我看到 的早期的使用cg1.2的 nebula2 都封装了 CGFX ,但是到了 1.4 不知道为什么,发布的 CG_tookit 里边却去掉了这个 CGFX 的运行库。 nebula2 新的版本也去掉了 CGFX ,只剩下 D3DShader 的支持。
- Applications and effects that used previous versions of CgFX will require modification.Applications that use CgFX will have to be modified to use the new CgFX API. If the supplied OpenGL state manager for CgFX is used, the effect files themselves must be modified. The effects must be changed to use OpenGL state assignments, rather than the D3D state assignments supported in prior versions of CgFX. A subsequent release of Cg will provide D3D and cross-platform state managers for CgFX.
- CgFX has been redesigned and re-implemented. As noted above, existing applications that use CgFX must be modified if the new API is to be used. In addition, if you wish to use the supplied “native” OpenGL state manager, which assumes that OpenGL-style state names and vales are used in effects, existing effects must be modified to use OpenGL-style states. See the “Introduction to CgFX” chapter in the Cg Users Manual for more details. If you have questions or problems related to porting existing CgFX applications, please contact NVIDIA developer relations.
上边这段话最后 说如果有问题,联系Nvidia developer relations。我想一想也没有办法了,去问wj大牛都不知道怎么回事儿,那只好去问一下了,结果到了nvidia developer网站上也差不到可以直接问谁,还填了一张表注册了一个用户,现在还没有被批下来。最后实在等不及了,去论坛上问吧。下面几个地址,没准儿有熟知cg的人可以答复一下.
http://www.gamedev.net/community/forums/topic.asp?topic_id=389475
http://www.smth.org/bbscon.php?bid=50&id=43518
http://www.smth.org/bbscon.php?bid=197&id=50169
http://forums.nvidia.com/index.php?showtopic=13875
- Cg1.1里边关于cgFX说:
CgFX beta support for DirectX 8, DirectX 9, and OpenGL
- Cg1.2里边关于cgFX说:
Cg Effects Explained document
CgFX beta support for DirectX 8, DirectX 9, and OpenGL
- Cg1.4.1里边关于cgFX说:
Complete rewrite of CgFX, including an API integrated with the Cg runtime API, support for extensible, cross-platform graphics state management, and support for unsized arrays and interfaces.
- Cg1.5beta里边关于cgFX说:
Cg 1.3 and 1.4 style Effects files supported
- 又考察了openGL2.0和GLSL,发现对于绘制的描述感觉跟CG1.4的FX的运行库也差不多,又因为不熟悉,还是回头看cgFX吧。
- 装了cg1.2看原来的文档,学习笔记如下:
- cgFX主要提供了三点好处:
- 不同硬件得以配置(technique,profile)
- 多遍绘制的描述(pass)
- 表达了环境信息(state)
- cgFX同microsoft FX2.0和DirectX9.0的Effect格式相似
- cgFX既可以在openGL又可以在D3D上运行,便于以后扩展
- 主要方法接口:
- CgFXCreateEffect,CgFXCreateEffectFromFileA,CgFXCreateEffectCompiler,CgFXCreateEffectCompilerFromFileA
- CgFXSetDevice,CgFXFreeDevice
- CGFXHANDLE GetTechnique(UINT index);CGFXHANDLE GetTechniqueByName(LPCSTR name);
- CGFXHANDLE GetPass(CGFXHANDLE technique, UINT index);CGFXHANDLE GetPassByName(CGFXHANDLE technique, LPCSTR name);
- CGFXHANDLE GetParameter(CGFXHANDLE parent, UINT index);
- CGFXHANDLE GetParameterByName(CGFXHANDLE parent, LPCSTR name);
- CGFXHANDLE GetParameterBySemantic(CGFXHANDLE parent, LPCSTR name);
- CGFXHANDLE GetParameterElement(CGFXHANDLE parent, UINT element);
- HRESULT FindNextValidTechnique(CGFXHANDLE hTechnique,CGFXHANDLE *pTechnique);
- HRESULT SetTechnique(CGFXHANDLE pTechnique);CGFXHANDLE GetCurrentTechnique();
- HRESULT Begin(UINT* pPasses, DWORD Flags);HRESULT Pass(UINT passNum);HRESULT End();
- HRESULT CloneEffect(ICgFXEffect** ppNewEffect);
- HRESULT GetDevice(LPVOID* ppDevice);
- HRESULT OnLostDevice();
- HRESULT OnResetDevice();
- 主要接口:
- ICgFXBaseEffect
- ICgFXEffect
- ICgFXEffectCompiler