Guest User

vertex_program/a_envmask_spec_vs11_for_ps11.vsh

a guest
May 11th, 2016
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.55 KB | None | 0 0
  1. //hlsl vs_1_1
  2.  
  3. #define textureCoordinateSetMAIN    textureCoordinateSet0
  4. #define DECLARE_textureCoordinateSets   \
  5.     float2 textureCoordinateSet0 : TEXCOORD0 : register(v7);
  6.  
  7. #include "vertex_program/include/vertex_shader_constants.inc"
  8. #include "vertex_program/include/functions.inc"
  9.  
  10. struct InputVertex
  11. {
  12.     float4  position              : POSITION0  : register(v0);
  13.     float4  normal              : NORMAL0    : register(v3);
  14.     DECLARE_textureCoordinateSets
  15. };
  16.  
  17. struct OutputVertex
  18. {
  19.     float4 position     : POSITION0;
  20.     float3 diffuse      : COLOR0;
  21.     float3 specular         : COLOR1;
  22.     float  fog          : FOG;
  23.     float2 tcs_MAIN     : TEXCOORD0;
  24.     float3 tcs_ENVM     : TEXCOORD1;
  25. };
  26.  
  27. OutputVertex main(InputVertex inputVertex)
  28. {
  29.     OutputVertex outputVertex;
  30.  
  31.     // transform vertex
  32.     outputVertex.position = transform3d(inputVertex.position);
  33.  
  34.     // calculate fog
  35.     outputVertex.fog = calculateFog(inputVertex.position);
  36.  
  37.     // calculate reflection vector for env mapping
  38.     float3 viewer_w = calculateViewerDirection_w(inputVertex.position);
  39.     float3 normal_w = rotateNormalize_o2w(inputVertex.normal);
  40.     outputVertex.tcs_ENVM = reflect(-viewer_w, normal_w);
  41.  
  42.     // calculate lighting
  43.     DiffuseSpecular diffuseSpecular = calculateDiffuseSpecularLighting(false, inputVertex.position, inputVertex.normal);
  44.     outputVertex.diffuse  = lightData.ambient.ambientColor + diffuseSpecular.diffuse;
  45.     outputVertex.specular = diffuseSpecular.specular * material.specularColor;
  46.  
  47.     // copy texture coordinates
  48.     outputVertex.tcs_MAIN = inputVertex.textureCoordinateSetMAIN;
  49.  
  50.     return outputVertex;
  51. }
Add Comment
Please, Sign In to add comment