Tattoo.cpp 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /******************************************************************************/
  2. #include "!Header.h"
  3. /******************************************************************************/
  4. #define PARAMS \
  5. uniform Bool skin ,\
  6. uniform Bool tesselate
  7. /******************************************************************************/
  8. struct VS_PS
  9. {
  10. Vec2 tex:TEXCOORD0;
  11. Vec pos:TEXCOORD1;
  12. Vec nrm:TEXCOORD2;
  13. };
  14. /******************************************************************************/
  15. // VS
  16. /******************************************************************************/
  17. void VS
  18. (
  19. VtxInput vtx,
  20. out VS_PS O,
  21. out Vec4 O_vtx:POSITION,
  22. PARAMS
  23. )
  24. {
  25. O.tex=vtx.tex();
  26. if(!skin)
  27. {
  28. if(tesselate)O.nrm=Normalize(TransformDir(vtx.nrm()));
  29. O.pos= TransformPos(vtx.pos());
  30. }else
  31. {
  32. VecI bone=vtx.bone();
  33. if(tesselate)O.nrm=Normalize(TransformDir(vtx.nrm(), bone, vtx.weight()));
  34. O.pos= TransformPos(vtx.pos(), bone, vtx.weight());
  35. }
  36. O_vtx=Project(O.pos);
  37. }
  38. /******************************************************************************/
  39. // PS
  40. /******************************************************************************/
  41. Vec4 PS
  42. (
  43. VS_PS I,
  44. PARAMS
  45. ):COLOR
  46. {
  47. return Tex(Col, I.tex)*Color[0];
  48. }
  49. /******************************************************************************/
  50. // HULL / DOMAIN
  51. /******************************************************************************/
  52. #if MODEL>=SM_4
  53. HSData HSConstant(InputPatch<VS_PS,3> I) {return GetHSData(I[0].pos, I[1].pos, I[2].pos, I[0].nrm, I[1].nrm, I[2].nrm);}
  54. [maxtessfactor(5.0)]
  55. [domain("tri")]
  56. [partitioning("fractional_odd")] // use 'odd' because it supports range from 1.0 ('even' supports range from 2.0)
  57. [outputtopology("triangle_cw")]
  58. [patchconstantfunc("HSConstant")]
  59. [outputcontrolpoints(3)]
  60. VS_PS HS
  61. (
  62. InputPatch<VS_PS,3> I, UInt cp_id:SV_OutputControlPointID,
  63. PARAMS
  64. )
  65. {
  66. VS_PS O;
  67. O.pos=I[cp_id].pos;
  68. O.nrm=I[cp_id].nrm;
  69. O.tex=I[cp_id].tex;
  70. return O;
  71. }
  72. /******************************************************************************/
  73. [domain("tri")]
  74. void DS
  75. (
  76. HSData hs_data, const OutputPatch<VS_PS,3> I, Vec B:SV_DomainLocation,
  77. out VS_PS O,
  78. out Vec4 O_vtx:POSITION,
  79. PARAMS
  80. )
  81. {
  82. O.tex=I[0].tex*B.z + I[1].tex*B.x + I[2].tex*B.y;
  83. SetDSPosNrm(O.pos, O.nrm, I[0].pos, I[1].pos, I[2].pos, I[0].nrm, I[1].nrm, I[2].nrm, B, hs_data, false, 0);
  84. O_vtx=Project(O.pos);
  85. }
  86. #endif
  87. /******************************************************************************/
  88. CUSTOM_TECHNIQUE
  89. /******************************************************************************/