转到正文

存档

分类: DirectX10

When you want to write DirectX10 program in your project, you should add .fx files. Article [1] introduces one method about how to build project with .fx files.

After that, you will get a perfect project which can compile and build .fx file, and you will run your DX10 program very well.

However, you may get some warmings about "Compiling" for every .fx files in your projects when you run your program every time. It's very disgusting for us because it costs us a lot of time.

The method how to avoid these "Repeat Compiling" information is : Make the FXC rule not selected:

And then, you will get no warming about "Compiling .fxc file" when you run you program.

继续阅读

When you build a new DirectX9 or DirectX10 project using Visual Studio2005 or higher verion, you may meet a strange error :

1>DXUTCORE_D_64.lib(DXUT.obj) : error LNK2019: unresolved external symbol __imp_InitCommonControls referenced in function "long __cdecl DXUTInit(bool,bool,wchar_t *,bool)" (?DXUTInit@@YAJ_N0PEA_W0@Z)
1>DXUTCORE_D_64.lib(DXUTmisc.obj) : error LNK2019: unresolved external symbol DXTraceW referenced in function "long __cdecl DXUTTrace(char const *,unsigned long,long,wchar_t const *,bool)" (?DXUTTrace@@YAJPEBDKJPEB_W_N@Z)
1>DXUTOptional_D_64.lib(SDKmisc.obj) : error LNK2001: unresolved external symbol DXTraceW
1>DXUTOptional_D_64.lib(SDKmisc.obj) : error LNK2019: unresolved external symbol D3DXCreateTextureFromFileExW referenced in function "public: long __cdecl CDXUTResourceCache::CreateTextureFromFileEx(struct IDirect3DDevice9 *,wchar_t const *,unsigned int,unsigned int,unsigned int,unsigned long,enum _D3DFORMAT,enum _D3DPOOL,unsigned long,unsigned long,unsigned long,struct _D3DXIMAGE_INFO *,struct tagPALETTEENTRY *,struct IDirect3DTexture9 * *)" (?CreateTextureFromFileEx@CDXUTResourceCache@@QEAAJPEAUIDirect3DDevice9@@PEB_WIIIKW4_D3DFORMAT@@W4_D3DPOOL@@KKKPEAU_D3DXIMAGE_INFO@@PEAUtagPALETTEENTRY@@PEAPEAUIDirect3DTexture9@@@Z)
1>DXUTOptional_D_64.lib(SDKmisc.obj) : error LNK2019: unresolved external symbol D3DX10CreateTextureFromFileW referenced in function "public: long __cdecl CDXUTResourceCache::CreateTextureFromFileEx(struct ID3D10Device *,wchar_t const *,struct D3DX10_IMAGE_LOAD_INFO *,struct ID3DX10ThreadPump *,struct ID3D10ShaderResourceView * *,bool)"
.....

You may think that all your work is pretty good, and you are all right!

It's very obvious that the problem is caused by missing some libraries.( Because error: error LNK2019: unresolved external symbol ) However, You jsut build a new project ,and you link the DXUT library corrrectly, Why Compiler always always have so many complains?  Is it crazy?

继续阅读

It's well known that if you want to create a BMP file, the raw image data memory should be written in the sequence of "BGR"[1], and not the ordinary sequence of "RGB".

So, you may write your code as follows if you want to create a RED pixel:

unsigned char *image = new unsigned char[4];
image[0] = 0;  // Blue
image[1] = 0;  // Green
image[2] = 255;  // Red
image[3] = 255;  // alpha

继续阅读

There is a little differences of Texture Coordinate between OpenGl and DirectX.

In the "OBJ" file, the texture coordinate is the same with OpengGL. You don't have to modify anything in OpengGL when you want to do some texture mapping for "Obj" file. However, if you want to render "Obj" file in DirectX, you have to make some changes for the coordinate of "OBJ" file.

Suppose the texture coordinate in "OBJ" which has been read from is (U1,V1), so the DirectX's texture coordinate should be (U2,V2) = (U1, 1-V1)

Don't forget this simple fact when you want to deal with "OBJ" file using DirectX.

继续阅读

刚拿到DirectX Dec2005 SDK,发现竟然有D3D10的文档和例子,速研究了一下,以下只是个人的读书笔记,仅作参考

  1. 去掉了固定管线
    文档里列出了用DX10特性模拟的一些固定管线的操作,MS那么大度把DX都开源了(^O^)。
  2. 去掉了以前版本DX的设备能力检查(CAPS)
    为DX10和Windows Vista提供的显示硬件必须满足DX10的所有硬件特性。这样对于开发者就比较可以放心的使用各种硬件特性了,很类似Console平台的开发。
  3. 状态对象(State Object)
    "从100多个渲染状态中解脱出来吧!"
    D3D10对渲染状态这个概念进行淡化,一方面使用全Shader化的架构使得状态的前后设置和互相影响对渲染成功率降低到最少
    另外对API架构也更为简洁,另一方面对一些关键渲染状态进行封装和分类。主要分类有:
    Input Layout Object 输入层对象 。这个东西很类似D3D9里的顶点声明,也就是对用户输入数据进行整合和系统化
    Rasterizer Object 光栅化对象。 这部分主要控制光栅器的行为:填充模式(FILL_MODE),剔除模式(CULL_MODE),多采样,DepthBias等等
    DepthStencil Object 深度缓冲对象。 主要控制深度缓冲的行为,像Z-buffer Enable之类的
    Blend Object 混合对象。 设置象素混合的方法,类似AlphaBlend SrcAlpha ,DestAlpha等等
    Sampler Object 采样器对象 。设置纹理采样状态,包括过滤器和MipMap
  4. 继续阅读

It suddently comes to me today that I want to know how to get vertex adjacency data information in DirectX10 using Shader.

And I found one post in Ogre Forums[1]. Through reading total article, I think we can follow some steps to implement the title idea .

  1. Have indices for every vertex
  2. Using the edge list, iterate over all the edges, storing the adjacencies in a map
  3. Use this map to create the textures
  4. Send the textures to the vertex shader

However, there is one question still confused me: If we can find edge list for the model object, why we get vertex adjacency information at the same time?  Even if we get the edge list information, we also have to store these information into a texture map, and we also have to put it in the shader. Why we just have a O(n*n) complexity in CPU and we can get it out?

继续阅读

There are some confusions about the Microsoft's DirectX10 SDK document about D3DXVec3TransformNormal.

The correct meaning of "D3DXVec3TransformNormal" is that "D3DXVec3TransformNormal transforms a normal using the transpose of the inverse of the given matrix". However, the DirectX SDK says: "If you want to transform a normal, the matrix you pass to this function should be the transpose of the inverse of the matrix you would use to transform a point.". The SDK document means that you should inverse your input matrix and then transpose it manually and then give it as parameter to the function "D3DXVec3TransformNormal". But as a matter of fact, you just have to input the transformation matix, and DirectX would do inversion/transpotion for you.

There are some details as follows for the function of "D3DXVec3TransformNormal" if you want to know:

Normals are different than vertex positions in that they always have their origin at 0,0,0 (i.e. they don't have a position) and they shouldn't be scaled or skewed.

For this reason, when transforming normals:

1. You shouldn't apply any translation.
继续阅读

It's common to use reflect HLSL function if you want to write a realistic computer graphics of DirectX10 program.

You can read MSDN  to learn how to use it. There is a little confusion of this function. The format of this function is

ret reflect(i, n)

"i" is a floating-point, incident vector. "n" is a floating-point, normal vector.

By using this function, you'll get v = i - 2 * n * dot(i•n)  and its direction is showed at the following picture.

继续阅读

www.liaoqiqi.com网站PR查询 博客简洁版 博客Google_Site_Map 博客Baidu_Site_Map ?