YetAnotherProblem

Subsurf.cginc

Mar 3rd, 2019
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #define INTERPOLATE(name) \
  2.             o.name = \
  3.             patch[0].name * barycentric.x + \
  4.             patch[1].name * barycentric.y + \
  5.             patch[2].name * barycentric.z;
  6.  
  7. int subdivisions = 1;
  8.  
  9. struct v2h
  10. {
  11.     float2 uv : TEXCOORD0;
  12.     float3 normal : NORMAL;
  13.     float4 vertex : SV_POSITION;
  14. };
  15.  
  16. struct chull
  17. {
  18.     float edges[3] : SV_TessFactor;
  19.     float inside : SV_InsideTessFactor;
  20. };
  21.  
  22. [UNITY_domain("tri")]
  23. [UNITY_partitioning("integer")]
  24. [UNITY_outputcontrolpoints(3)]
  25. [UNITY_outputtopology("triangle_cw")]
  26. [UNITY_patchconstantfunc("hull_const")]
  27. v2h hull(InputPatch<v2h, 3> patch,
  28.     uint id : SV_OutputControlPointID) {
  29.     v2h o = patch[id];
  30.     return o;
  31. }
  32.  
  33. chull hull_const(InputPatch<v2h, 3> patch) {
  34.     chull o;
  35.     o.edges[0] = subdivisions;
  36.     o.edges[1] = subdivisions;
  37.     o.edges[2] = subdivisions;
  38.     o.inside = subdivisions;
  39.     return o;
  40. }
  41.  
  42. [UNITY_domain("tri")]
  43. v2h domain(
  44.     chull factors,
  45.     OutputPatch<v2h, 3> patch,
  46.     float3 barycentric : SV_DomainLocation
  47. ) {
  48.     v2h o;
  49.     INTERPOLATE(uv);
  50.     INTERPOLATE(normal);
  51.     INTERPOLATE(vertex);
  52.     return o;
  53. }
Add Comment
Please, Sign In to add comment