暫無描述
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

PreviewVaryings.hlsl 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. Varyings BuildVaryings(Attributes input)
  2. {
  3. Varyings output = (Varyings)0;
  4. // Returns the camera relative position (if enabled)
  5. float3 positionWS = TransformObjectToWorld(input.positionOS);
  6. #ifdef ATTRIBUTES_NEED_NORMAL
  7. float3 normalWS = TransformObjectToWorldNormal(input.normalOS);
  8. #else
  9. // Required to compile ApplyVertexModification that doesn't use normal.
  10. float3 normalWS = float3(0.0, 0.0, 0.0);
  11. #endif
  12. #ifdef ATTRIBUTES_NEED_TANGENT
  13. float4 tangentWS = float4(TransformObjectToWorldDir(input.tangentOS.xyz), input.tangentOS.w);
  14. #endif
  15. #ifdef VARYINGS_NEED_POSITION_WS
  16. output.positionWS = positionWS;
  17. #endif
  18. #ifdef VARYINGS_NEED_POSITIONPREDISPLACEMENT_WS
  19. output.positionPredisplacementWS = positionWS;
  20. #endif
  21. #ifdef VARYINGS_NEED_NORMAL_WS
  22. output.normalWS = normalize(normalWS);
  23. #endif
  24. #ifdef VARYINGS_NEED_TANGENT_WS
  25. output.tangentWS = normalize(tangentWS);
  26. #endif
  27. output.positionCS = TransformWorldToHClip(positionWS);
  28. #if defined(VARYINGS_NEED_TEXCOORD0) || defined(VARYINGS_DS_NEED_TEXCOORD0)
  29. output.texCoord0 = input.uv0;
  30. #endif
  31. #if defined(VARYINGS_NEED_TEXCOORD1) || defined(VARYINGS_DS_NEED_TEXCOORD1)
  32. output.texCoord1 = input.uv1;
  33. #endif
  34. #if defined(VARYINGS_NEED_TEXCOORD2) || defined(VARYINGS_DS_NEED_TEXCOORD2)
  35. output.texCoord2 = input.uv2;
  36. #endif
  37. #if defined(VARYINGS_NEED_TEXCOORD3) || defined(VARYINGS_DS_NEED_TEXCOORD3)
  38. output.texCoord3 = input.uv3;
  39. #endif
  40. #if defined(VARYINGS_NEED_COLOR) || defined(VARYINGS_DS_NEED_COLOR)
  41. output.color = input.color;
  42. #endif
  43. #if defined(VARYINGS_NEED_VERTEXID)
  44. output.vertexID = input.vertexID;
  45. #endif
  46. #ifdef VARYINGS_NEED_BITANGENT_WS
  47. output.bitangentWS = cross(normalWS, tangentWS.xyz) * tangentWS.w;
  48. #endif
  49. #ifdef VARYINGS_NEED_SCREENPOSITION
  50. output.screenPosition = ComputeScreenPos(output.positionCS, _ProjectionParams.x);
  51. #endif
  52. return output;
  53. }