UniversalMetaPass.hlsl 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #ifndef UNIVERSAL_META_PASS_INCLUDED
  2. #define UNIVERSAL_META_PASS_INCLUDED
  3. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/MetaInput.hlsl"
  4. struct Attributes
  5. {
  6. float4 positionOS : POSITION;
  7. float3 normalOS : NORMAL;
  8. float2 uv0 : TEXCOORD0;
  9. float2 uv1 : TEXCOORD1;
  10. float2 uv2 : TEXCOORD2;
  11. UNITY_VERTEX_INPUT_INSTANCE_ID
  12. };
  13. struct Varyings
  14. {
  15. float4 positionCS : SV_POSITION;
  16. float2 uv : TEXCOORD0;
  17. #ifdef EDITOR_VISUALIZATION
  18. float2 VizUV : TEXCOORD1;
  19. float4 LightCoord : TEXCOORD2;
  20. #endif
  21. };
  22. Varyings UniversalVertexMeta(Attributes input)
  23. {
  24. Varyings output = (Varyings)0;
  25. output.positionCS = UnityMetaVertexPosition(input.positionOS.xyz, input.uv1, input.uv2);
  26. output.uv = TRANSFORM_TEX(input.uv0, _BaseMap);
  27. #ifdef EDITOR_VISUALIZATION
  28. UnityEditorVizData(input.positionOS.xyz, input.uv0, input.uv1, input.uv2, output.VizUV, output.LightCoord);
  29. #endif
  30. return output;
  31. }
  32. half4 UniversalFragmentMeta(Varyings fragIn, MetaInput metaInput)
  33. {
  34. #ifdef EDITOR_VISUALIZATION
  35. metaInput.VizUV = fragIn.VizUV;
  36. metaInput.LightCoord = fragIn.LightCoord;
  37. #endif
  38. return UnityMetaFragment(metaInput);
  39. }
  40. #endif