2008年6月11日

     摘要: In 3D world, many enthusiastic specialists and PhD are giving their life-time effort to rendering photorealistic objects like milk, skin, water, feather, shadow, etc. No doubt that it is good to have all these physical models about the rendering. When it comes to practical application, we, however, have to made a tradeoff between quality and performance and most of the time, the result yield at the later choice.  阅读全文

posted @ 2008-06-11 22:44 SigEric 阅读(42) | 评论 (0)编辑

2008年4月30日

 

Vertex Buffer and Index Buffer are two vital “components” in XNA rendering. In another word, if you managed to figure out how it works and how it works faster, you will get a faster rendering engine in XNA.

As you may notice, there is no Draw Box, sphere, etc functions in XNA framework and it is very inconvenient for rendering and collision detection. So I decide to program my own game component to render the bounding box, bounding sphere and bounding volume(still developing).

Here are the sample and the source code

P.S.

 For the vertex buffer updating, I strongly suggest you check Shawn Hargreaves’ Blog, which describe the stalling between CPU and GPU when rendering. And it is a very good blog for XNA developing. Updating the VBO in my source code is taking the advice of using a double buffers from Stalls part two: beware of SetData

Here is the screen shoot:

posted @ 2008-04-30 17:40 SigEric 阅读(52) | 评论 (0)编辑

2008年3月20日

 

It has been 2 years since I started my work in *.shp format. In the same time, I produced couples of tools to convert them for different software and format.

1.       Converting the building top view in shp file to a graphic engine format so that we can load it directly from engine.

2.       A plugin for 3Ds Max to import Shp file to max model.

Since I am new comer to FBX team, I decided to make a converter to turn shp file to FBX format.

First, we have to know FBX is more for animation propose because it is the original format of Motion Builder.  So, building meshes through FBX SDK is a tough job for new users.

In this passage, I want to talk about the difficulty I was encountered when programming my tools. Hope this will help you out a little bit.

1.       There is no predefined and custom vertex format. If you want have position, uv, normal, binormal, tangent, vertex color, etc in FBX mesh, well, you need to build them layer element  by layer element. (Layer Element is a key concept in FBX which means a component of sth, e.g. A mesh can have normal layer element , vertex color layer element  , diffuse channel layer element  , etc.). After the gathering of all elements, u can put them in a layer and element between layers can “mixed” or “blend” together somehow. E.g. Texture element in different layers can blend with each other.

2.       The Concept of Textures, materials and mesh. In most DCC and 3D rendering Engine, textures belong to materials, which can be applied to multiple meshes. However,  textures are applied to polygons on meshes directly with ID or Value(By IndexArray or DirectArray) and materials only have the properties like colors, shinness.  In the current version (2006.11.1) of SDK, there is not shader in file. But I am pretty sure even you have shaders in material.

3.       How to share materials and textures? For material, you can setup couples of material layer elements. Then call the SetMaterials of Layer. For textures, well, it is a little bit complicated. You need to setup an array to hold your textures, create texture layer element in each mesh, add necessary textures to layer element, calculate back the index of texture in the layer element, Set the texture index for each polygon.

Here is the screen shoot, take a coffee and enjoy…

posted @ 2008-03-20 18:03 SigEric 阅读(51) | 评论 (0)编辑

2008年2月27日

It has been a long time that no update shows up here. Sorry....
I have been working on the requirement on a new Demo Engine, which is small and flexible.
After doing some survey all these days, I found that it is very necessary to support both GL and D3D to my engine.

For GL, it is state machine based so that an encapsulation for VBO is very vital for the rendering pipe line.

Here are the diagrams to show the class relationships:

Buffer diagram

Both vertex buffer and index buffer are inheritant from the buffer object class.
They provide  both reading and writing to the buffer object, bind/unbind, size calculation, etc.

VertexElement and VertexDeclaration are util class that helps to utilize the format of the rendering vertices. The user(programmer) can declare attribute of vertex, like position, normal, diffuse color, specular color, tangent, etc.

 



All the operation including creation, modification and deletion of buffer objects are calling from the BufferManager, which is a singelton class.

Here is the source code: VBO Manager

posted @ 2008-02-27 18:32 SigEric 阅读(57) | 评论 (0)编辑

2008年1月26日

 

Last week is a long week because lots of stuff happened which made the development process even harder, in another more tough and interesting.

 

1, The Frame buffer object. Also, we can call it render target. This technology can really speed up the rendering by using a texture or render buffer as an offline, which allow us to add some post effect on it, for example, glow effect, HDR tone mapping, DOF, etc. Therefore, this is the key component in the current rendering engine. Most of the time, we need to deal with Multiple Render Targets (MRTs), which is pretty tricky and require you to be clear which render target you are deal with, how and when to “activate and “restore” it. There are many sample codes online which are pretty good: http://www.g-truc.net/sample-ogl2.html, http://www.feedsfarm.com/article/ad25941ddd7038b6a25c3ab76a6144603487ee24.html

 

2, CgFx Material. No matter you are dealing with CgFx, GLSL, or HLSL, you need to have you own class to manage the shader framework and also, you need to take care of the performance issue or you scene will run extremely slow after integrating couples of shaders. You may ask why. Why? It is pretty common as you may know each pass in a shader need to setup its own rendering state, which cause lots of processing time for your GPU to switch between states. Here is the common solution: 1, sort your object by rendering state(material, effect, etc). 2, Set or Reset the state only when the same state group is finished rendering. 3, Optimize you framework to make sure the parameter setting call number is minimum. Because whenever you set a parameter of certain shader, you need to pass some variable from system memory to GPU memory, which is slow. In a word, cut the shader calls as less as you can.

 

3, Make sure you know what you are doing when coding. People are very careless these days when programming. I met a legacy bug from the system, which states in pixel shader of Shader Model 3.0, you can loop through an indexed array only when it is texture coordinate semantic and indexed by the loop variable. Like this kind of bug is not easy to fix because the algorithm is  already fxied and the calculation need to be done in pixel shader, how can you avoid the looping? I didn’t come up with the perfect answer but we can unfold the looping and limit the maximum boundary of the loop, which means we limit the function of the shader if we have to fix this. Let’s think about the cause, why a bug like this will exist. If we can always pay attention to what you are writing rightnow, let say I am writing a PS 2.0 program and I need to stick with the profile spec of it. Also, after you program seems to work, we need to put some log or error checking when calling it to make sure there is no warning or error. I know, I know this will cost some time but it will save lots of people time and money to just find the bug, let alone to fix it.

 

4, Check the module related with what you have modified before hastily submitting your code. Make a fully test the corresponding module before telling others you just fixed a bug or create a new wonderful feature because this may be the beginning of a new regression. This situation happens a lot in new developers, even for some experienced programmers. People are easily ignore to testing all the related codes, instead, to submit the new changed code just because they think they spend some or a lot time on the development and finally it comes up with a nice result. However, the last path to success is always full of mines. If you don’t take care them, you may cause some serious trouble for yourself, even the entire development and QA team.

 

Above, it is my feeling during last week.

posted @ 2008-01-26 11:19 SigEric 阅读(81) | 评论 (0)编辑

2008年1月12日

     摘要: Antialiasing (AA) is old topic for computer graphic since the structure of PC screen is measure by pixel and there is no way to create a unit samller than that, we have no choice but using a way named antialiasing to avoid the jaggy on the edge of the objects.Now, the way of applying the aa effect as the post processing to RT and FBO is described here.  阅读全文

posted @ 2008-01-12 21:30 SigEric 阅读(181) | 评论 (0)编辑

2008年1月6日

过了一年才发觉好久没有更新博客了,最近琐事特别多,所以时间感觉是在不够用。
新公司在浦东,四号线环线通车后上班还是挺方便的。Mudbox的开发刚刚开始,新的挑战还在前面!!
欢迎各位和我讨论图形相关的技术。

posted @ 2008-01-06 13:45 SigEric 阅读(67) | 评论 (0)编辑

2007年11月22日

     摘要: The purpose of the project is to train to design, test and code for a small project for a shot period of time, like say 3 days.

I am using the xp and protoyping iteration for this project to keep updating new feature and making the code to run on Windows, WM5 and WM6.  阅读全文

posted @ 2007-11-22 00:01 SigEric 阅读(111) | 评论 (0)编辑

2007年11月15日

今天终于递了辞职信,心情霎时轻松.终于可以换个环境做自己爱做的事情,继续我的事业.
这是我第一次辞职,怎么说呢,有一种新生的感觉,前路光明也充满挑战.
嗯,很不错.

posted @ 2007-11-15 20:35 SigEric 阅读(40) | 评论 (0)编辑

2007年10月20日

     摘要: Last Wednesday, I got the the copy of 3Ds Max 2008. And today, I play around the new features of it, mainly focus on the scene explorer.  阅读全文

posted @ 2007-10-20 17:28 SigEric 阅读(410) | 评论 (0)编辑