varianceshadowcastervp.cg
上传用户:xhbjoy
上传日期:2014-10-07
资源大小:38068k
文件大小:2k
源码类别:

游戏引擎

开发平台:

Visual C++

  1. /////////////////////////////////////////////////////////////////////////////////
  2. //
  3. // shadowcastervp.cg
  4. //
  5. // Hamilton Chong
  6. // (c) 2006
  7. //
  8. // This is an example vertex shader for shadow caster objects.  
  9. //
  10. /////////////////////////////////////////////////////////////////////////////////
  11. // Define inputs from application.
  12. struct VertexIn
  13. {
  14.   float4 position : POSITION;       // vertex position in object space
  15.   float4 normal   : NORMAL;         // vertex normal in object space
  16. };
  17. // Define outputs from vertex shader.
  18. struct VertexOut
  19. {
  20.   float4 position   : POSITION;     // post projection position coordinates
  21.   float4 pos       : TEXCOORD0;    // ditto. Not all hardware allows access values bound to POSITION in fp.
  22.   float4 normal     : TEXCOORD1;    // normal in object space (to be interpolated)
  23.   float4 modelPos   : TEXCOORD2;    // position in object space (to be interpolated) 
  24. };
  25. VertexOut main( VertexIn         In,                   // vertex to process
  26.                 uniform float4x4 uModelViewProjection  // model-view-projection matrix
  27.               )
  28. {
  29.     VertexOut Out;   // output data
  30.     
  31.     // Transform vertex position into post projective (homogenous screen) space.
  32.     Out.position = mul(uModelViewProjection, In.position);
  33.     Out.pos      = mul(uModelViewProjection, In.position);
  34.     // copy over data to interpolate using perspective correct interpolation
  35.     Out.normal = float4(In.normal.x, In.normal.y, In.normal.z, 0.0);
  36.     Out.modelPos = In.position;
  37.     return Out;
  38. }