Set Color.cpp 2.9 KB

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