Advertisement
Guest User

tess.hs

a guest
May 24th, 2013
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.84 KB | None | 0 0
  1. #include "common.h"
  2. #include "DX11\tess.h"
  3.  
  4. HS_CONSTANT_DATA_OUTPUT PatchConstantsHS(
  5. InputPatch<p_bumped, 3> ip,
  6. uint PatchID : SV_PrimitiveID )
  7. {
  8. HS_CONSTANT_DATA_OUTPUT Output;
  9.  
  10. ComputeTessFactor(Output.Edges, Output.Inside);
  11.  
  12. #ifdef TESS_PN
  13. float3 N[3] =
  14. {
  15. normalize(float3(ip[0].M1.z, ip[0].M2.z, ip[0].M3.z)),
  16. normalize(float3(ip[1].M1.z, ip[1].M2.z, ip[1].M3.z)),
  17. normalize(float3(ip[2].M1.z, ip[2].M2.z, ip[2].M3.z))
  18. };
  19.  
  20. float3 P[3] =
  21. {
  22. ip[0].position.xyz,
  23. ip[1].position.xyz,
  24. ip[2].position.xyz
  25. };
  26.  
  27. ComputePNPatch(P, N, Output.patch);
  28.  
  29. //Discard back facing patches
  30. # ifndef TESS_HM
  31. bool doDiscard = (N[0].z>0.1) && (N[1].z>0.1) && (N[2].z>0.1)
  32. && (Output.patch.f3N110.z>0.1) && (Output.patch.f3N011.z>0.1) && (Output.patch.f3N101.z>0.1)
  33. && (P[0].z>5) && (P[1].z>5) && (P[2].z>5);
  34.  
  35. if (doDiscard)
  36. Output.Edges[0]= Output.Edges[1]=Output.Edges[2]=Output.Inside=-1;
  37. # endif
  38.  
  39. #endif
  40.  
  41. // Data for interpolation in screen space
  42. // float w0 = mul(m_P, float4(ip[2].position.xyz, 1)).w;
  43. // float w1 = mul(m_P, float4(ip[1].position.xyz, 1)).w;
  44. // float w2 = mul(m_P, float4(ip[0].position.xyz, 1)).w;
  45.  
  46. // Output.www = float3(w0, w1, w2);
  47.  
  48. return Output;
  49. }
  50.  
  51. [domain("tri")]
  52. [partitioning("pow2")]
  53. [outputtopology("triangle_ccw")]
  54. [outputcontrolpoints(3)]
  55. [patchconstantfunc("PatchConstantsHS")]
  56. p_bumped main( InputPatch<p_bumped, 3> ip,
  57. uint i : SV_OutputControlPointID,
  58. uint PatchID : SV_PrimitiveID )
  59. {
  60. p_bumped ouput;
  61.  
  62. ouput.tcdh = ip[i].tcdh;
  63. ouput.position = ip[i].position;
  64. ouput.M1 = ip[i].M1;
  65. ouput.M2 = ip[i].M2;
  66. ouput.M3 = ip[i].M3;
  67. #ifdef USE_TDETAIL
  68. ouput.tcdbump = ip[i].tcdbump;
  69. #endif
  70. #ifdef USE_LM_HEMI
  71. ouput.lmh = ip[i].lmh;
  72. #endif
  73.  
  74. return ouput;
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement