Posts

Showing posts from June, 2010

Depth Bias

Image
To solve Z fighting issue: use depth bias. An application can help ensure that coplanar polygons are rendered properly by adding a bias to the z-values that the system uses when rendering the sets of coplanar polygons. To add a z-bias to a set of polygons, call the IDirect3DDevice9::SetRenderState method just before rendering them, setting the State parameter to D3DRS_DEPTHBIAS, and the Value parameter to a value between 0-16 inclusive. A higher z-bias value increases the likelihood that the polygons you render will be visible when displayed with other coplanar polygons. Offset = m * D3DRS_SLOPESCALEDEPTHBIAS + D3DRS_DEPTHBIAS where m is the maximum depth slope of the triangle being rendered. m = max(abs(delta z / delta x), abs(delta z / delta y))  reference: http://msdn.microsoft.com/en-us/library/bb205599%28VS.85%29.aspx                                                  Z Slope Scale = 0.0, Depth Bias = 0.0                                         

Occlusion Culling Using Direct3D 9.0

Image
In the view frustum culling scenario, the culling-in objects like the bottom figure shows: But in the practical view looks like the bottom figure, we just need to render three objects: red, purple, and blue one. The green and yellow one are hidden. In this condition, we can adopt GPU hardware support. Direct3D provides Occlusion Query to calculate number of pixel visible. If the number is zero, meaning it is fully occluded, else is greater than zero  the pixel is visible by the viewer. The IDirect3DQuery9 process is presented below: Render every object's bounding mesh For every object: Begin query Re-render the bounding mesh End query Retrieve occlusion query data. If the pixels visible are greater than zero, the object should be rendered. Otherwise, the object should be occluded from rendering. In the first step, we need to decide the bounding mesh. Use bounding box? sphere?...The suit way is using lower vertex count mesh to instead of bounding box or spher

Shadow Application In A Soccer Game

Image
Maybe you will wonder in this snapshot how to present so many shadows in one frame. There is some tricky, because the gorgeous shadow result doesn't appear always. In the often gameplay situation, it only looks like the bottom snapshot . In this snapshot, doesn't have any self-shadow result. The shadow approach looks like planar shadow. When in the replay clips, Planar shadow and shadow map are used together. In the planar shadow phases, all shadows are rendered to a target, and then preparing shadow map uses another render target(using sizeof 1024x2048, cause what?, now I still don't understand.). At the rendering pass, planar shadow can use a rectangle to mapping the render target. With regard to shadow map, fetch the shadow texel in each object's pixel shader .

Order-Independent Transparency

Depth sorting alpha blended objects http://blogs.msdn.com/b/shawnhar/archive/2009/02/18/depth-sorting-alpha-blended-objects.aspx Order Independent Transparency with Dual Depth Peeling http://developer.download.nvidia.com/SDK/10/opengl/src/dual_depth_peeling/doc/DualDepthPeeling.pdf Interactive Order-Independent Transparency http://developer.nvidia.com/object/Interactive_Order_Transparency.html Alpha blending without sorting http://www.gamedev.net/community/forums/topic.asp?topic_id=405755 Depth-sort based Alpha Blending http://www.opengpu.org/bbs/archiver/?tid-422.html Sort-Indenpency Alpha Blending http://0rz.tw/DSYnW Order-indenpendent transparency http://www.wolfgang-engel.info/blogs/?p=96

Current shadow map method

Switch render target. Keep the current pass color surface and depth surface, set the shadow map color surface and depth surface in order to get the frame buffer data into the screen space texture - shadow map. We use the R32 color map to store shadow texture, size of 1024x1024. Because dx 9.0 can't be valid for modify depth texture, but graphics card vendor support get depth texture approach, it may has something warning in dx 9.0 runtime .( Nvidia : hardware shadow map, pcf 2x2. ATI : fetch4) If we can fetch depth info. as texture then disable color write, use depth bias to solve depth fighting. The process of shadow map will decrease cost effectively. In the second rendering pass, fetch the shadow map, and adopt PCF 2x2 to blur the aliasing. ftp://download.nvidia.com/developer/presentations/2004/GPU_Jackpot/Shadow_Mapping.pdf http://msdn.microsoft.com/en-us/library/ee416324%28VS.85%29.aspx

Matrix multiple in HLSL

In HLSL , We could use constant float to transit the value into shader code. There is a confusing problem to me, in row-major and column major rule will have the same result? When we use setConstantF to the register, shader's assembly use vector to record them. At processing time, these vector use dot product operator with you variable. So when you use mul ( pos , WorldMtx ); WorldMtx is: { _00, _01, _02, _03, _10, _11, _12, _13, _20, _21, _22, _23, _30, _31, _32, _33 } the WorldMtx need to be transpose at software, and the process is: Output.x = dot( vector( pos . xyz , 1.0f), vector(_00,_10,_20,_30) ); Output.y = dot( vector( pos . xyz , 1.0f), vector(_01,_11,_21,_31) ); Output.z = dot( vector( pos . xyz , 1.0f), vector(_02,_12,_22,_32) ); Or you also can use mul ( WoldMtx , pos ); , and don't transpose WorldMtx . The result is: Output.x = mul ( vector(_00,_01,_02,_03), pos . x ) + mul (_30, 1.0f); Output.y = mul ( vector(_10,_11,_12,_13), pos . y ) + mul (_31, 1.0f)

好黑暗的會議

昨天的會議後來真是讓我覺得有點灰心,可能這就是社會...會有人被覺得不適合,然後就從你身邊被拔掉了。如果平常表現的能力無法取得信任,又沒有時時為自己充電新知識,就會被有所挑剔。其實在旁邊聽的我,也覺得自己要有所警惕,效率要快,要多汲取新知,不然隨時都會被後來的新血給取代...

SSAO - Screen Space Ambient Occlusion

About SSAO approach can reference here http://mtlung.blogspot.com/2008/09/ssao.html http://http.developer.nvidia.com/GPUGems2/gpugems2_chapter14.html

Hardware Occlusion Queries

GPU provides query mode to test pixel whether or not would be draw. In the previous frame, render model only its bounding box, and query if success in the view indeed . Furthermore, we just render objects the bounding box is in the clip space . But sometimes this method will have more drawcalls , and need to wait some frames. It will have overcome. http://www.gamedev.net/community/forums/topic.asp?topic_id=377484 http://http.developer.nvidia.com/GPUGems2/gpugems2_chapter06.html http://cggmwww.csie.nctu.edu.tw/~danki/myweb/projects/hom/index.html Fast and Simple Occlusion Culling using Hardware-Based. pdf Occlusion Culling Using DirectX 9 http://www.gamedev.net/reference/programming/features/occlusionculling/

Website introduce shader

HLSL Shaders http://knol.google.com/k/hlsl-shaders# Introduction to Shader Programming http://www.gamedev.net/columns/hardcore/dxshader1/ http://www.gamedev.net/columns/hardcore/dxshader2/ http://www.gamedev.net/columns/hardcore/dxshader3/ http://www.gamedev.net/columns/hardcore/dxshader4/ http://www.gamedev.net/columns/hardcore/dxshader5/