0001: //
0002: // This program is to calculate the collision between bullet with ground.
0003: // This calculation is the same as a shadow volume's one.
0004: //
0005: 
0006: // ----------------------------------------------------------------------------
0007: // Input datas
0008: // ----------------------------------------------------------------------------
0009: struct appdata  {
0010:     float4 position  : POSITION;
0011:     float4 texcoord0 : TEXCOORD0;
0012: };
0013: // ----------------------------------------------------------------------------
0014: // Vertex shader program
0015: // ----------------------------------------------------------------------------
0016: vf20 main(appdata I
0017:         , uniform float4x4 viewproj_matrix
0018:         , uniform float4 trans
0019:         , uniform float4 velocity
0020:         , uniform float4 color
0021: ) {
0022:     vf20 O;
0023:     
0024:     // Coordinate transformation
0025:     float4 v = (0<=dot(I.position, velocity))
0026:                     ? I.position
0027:                     : (I.position-velocity);
0028:     v=v+trans;
0029:     O.HPOS = mul(viewproj_matrix, v);
0030:     
0031:     // I copy a constant to the vertex color
0032:     O.COL0   = color;
0033: 
0034:     return O;
0035: } 
0036: 
0037: 
0038: