]]>clip plane妯℃嫙錛堟妱鑷狣XSDK錛?/title>http://www.shnenglu.com/bloodbao/archive/2008/11/09/66448.htmlbloodbaobloodbaoSun, 09 Nov 2008 12:47:00 GMThttp://www.shnenglu.com/bloodbao/archive/2008/11/09/66448.htmlhttp://www.shnenglu.com/bloodbao/comments/66448.htmlhttp://www.shnenglu.com/bloodbao/archive/2008/11/09/66448.html#Feedback0http://www.shnenglu.com/bloodbao/comments/commentRss/66448.htmlhttp://www.shnenglu.com/bloodbao/services/trackbacks/66448.htmlDX9涓嬩嬌鐢?br>D3DXPLANE plane; D3DXPlaneFromPointNormal( &plane, &vPoint, &vNormal ); //鐢熸垚榪欎釜騫抽潰 D3DXMatrixReflect( &matReflect, &plane ); //鍙栧緱璇ュ鉤闈㈢殑鍙嶅皠鐭╅樀 //璁劇疆鍓垏騫抽潰錛屼嬌鍙嶅皠闈笂鐨勫唴瀹硅娓叉煋錛岄潰涓嬬殑琚涪寮? m_pd3dDevice->SetClipPlane( 0, plane ); m_pd3dDevice->SetRenderState( D3DRS_CLIPPLANEENABLE, 0x01 ); DX10涓嬫ā鎷燂細 User Clip PlanesUser Clip Planes are emulated by specifying a clip distance output from the Vertex Shader with the SV_ClipDistance[n] flag, where n is either 0 or 1. Each component can hold up to 4 clip distances in x, y, z, and w giving a total of 8 clip distances.
In this scenario, each clip planes is defined by a plane equation of the form:
鍦ㄨ繖涓満鏅噷錛屾瘡涓猚lip plane琚竴涓鉤闈㈡柟紼嬪畾涔夛細
Ax + By + Cz + D =0;
Where <A,B,C> is the normal of the plane, and D is the distance of the plane from the origin. Plugging in any point <x,y,z> into this equation gives its distance from the plane. Therefore, all points <x,y,z> that satisfy the equation Ax + By + Cz + D = 0 are on the plane. All points that satisfy Ax + By + Cz + D < 0 are below the plane. All points that satisfy Ax + By + Cz + D > 0 are above the plane.
In the Vertex Shader, each vertex is tested against each plane equation to produce a distance to the clip plane. Each of the three clip distances are stored in the first three components of the output component with the semantic SV_ClipDistance0. These clip distances get interpolated over the triangle during rasterization and clipped if the value every goes below 0.
]]>Main Features in my blood enginehttp://www.shnenglu.com/bloodbao/archive/2008/08/11/58530.htmlbloodbaobloodbaoMon, 11 Aug 2008 07:05:00 GMThttp://www.shnenglu.com/bloodbao/archive/2008/08/11/58530.htmlhttp://www.shnenglu.com/bloodbao/comments/58530.htmlhttp://www.shnenglu.com/bloodbao/archive/2008/08/11/58530.html#Feedback0http://www.shnenglu.com/bloodbao/comments/commentRss/58530.htmlhttp://www.shnenglu.com/bloodbao/services/trackbacks/58530.htmlDirect3D 9 is used to render the scene User input is gathered though DirectInput Single pass multi-texturing using the fixed-function pipeline (FFP) Light-mapping Frustum culling Simple skybox Keyframe Animation with GPU-based frame interpolation through a custom vertex and pixel shader written in HLSL. This technique is also known as Vertex Tweening or even Morph Target Support for Quake2 models (.md2) Support for DirectX models (.x) Support for PCX texture loading in addition to the other image formats already supported by Direct3D Support for Quake3:Arena levels Lightmaps Curved surfaces using Bezier patches Partial support of Quake3 materials and effects (.shader) Uses the BSP/PVS to quickly discard non visible geometry Collision detection using the BSP tree (supports ray, sphere and box sweeps) A flexible scene graph system where entities can be attached to each other in order to perform hierarchical transformations and geometry culling Quake-like player movement physics A powerful in-game console system: Outputs vital information Can take command inputs from the user Console variables can be dynamically edited at runtime Commands and console variable settings can be loaded from a user-specified text file (cfg) Garbage collection of unused resources through reference counting Control keys can be dynamically changed in-game through the console, using the bind command User input is abstracted through an Action Manager which maps inputs to actions A smart chase-camera controller that will detect collisions with the world to prevent the view from being occluded by other pieces of world geometry. Error handling through exceptions The in-game HUD can display vital performance statistics about the game, such as frames per second, total number of triangles on the screen, number of textures loaded, etc…
At the top level, the rendering steps look like the following:
If ambient lighting is enabled, render the entire scene with ambient only.
For each light in the scene, do the following:
Disable depth-buffer and frame-buffer writing.
Prepare the stencil buffer render states for rendering the shadow volume.
Render the shadow volume mesh with a vertex extruding shader. This sets up the stencil buffer according to whether or not the pixels are in the shadow volume.
Prepare the stencil buffer render states for lighting.
Prepare the additive blending mode.
Render the scene for lighting with only the light being processed.
return output; } 綆鍗旳LPHA嫻嬭瘯 // // PS for rendering with alpha test // float4 PSAlphaTestmain(PSSceneIn input) : COLOR0 { float4 color = tex2D( g_samLinear, g_txDiffuse, input.tex ) * input.colorD; if( color.a < 0.5 ) discard; return color; } 闆懼寲錛?/p>
// // Calculates fog factor based upon distance // // E is defined as the base of the natural logarithm (2.71828) float CalcFogFactor( float d ) { float fogCoeff = 1.0;