LitMetaPass.hlsl 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #ifndef UNIVERSAL_LIT_META_PASS_INCLUDED
  2. #define UNIVERSAL_LIT_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. #ifdef _TANGENT_TO_WORLD
  12. float4 tangentOS : TANGENT;
  13. #endif
  14. };
  15. struct Varyings
  16. {
  17. float4 positionCS : SV_POSITION;
  18. float2 uv : TEXCOORD0;
  19. };
  20. Varyings UniversalVertexMeta(Attributes input)
  21. {
  22. Varyings output;
  23. output.positionCS = MetaVertexPosition(input.positionOS, input.uv1, input.uv2, unity_LightmapST, unity_DynamicLightmapST);
  24. output.uv = TRANSFORM_TEX(input.uv0, _BaseMap);
  25. return output;
  26. }
  27. half4 UniversalFragmentMeta(Varyings input) : SV_Target
  28. {
  29. SurfaceData surfaceData;
  30. InitializeStandardLitSurfaceData(input.uv, surfaceData);
  31. BRDFData brdfData;
  32. InitializeBRDFData(surfaceData.albedo, surfaceData.metallic, surfaceData.specular, surfaceData.smoothness, surfaceData.alpha, brdfData);
  33. MetaInput metaInput;
  34. metaInput.Albedo = brdfData.diffuse + brdfData.specular * brdfData.roughness * 0.5;
  35. metaInput.SpecularColor = surfaceData.specular;
  36. metaInput.Emission = surfaceData.emission;
  37. return MetaFragment(metaInput);
  38. }
  39. //LWRP -> Universal Backwards Compatibility
  40. Varyings LightweightVertexMeta(Attributes input)
  41. {
  42. return UniversalVertexMeta(input);
  43. }
  44. half4 LightweightFragmentMeta(Varyings input) : SV_Target
  45. {
  46. return UniversalFragmentMeta(input);
  47. }
  48. #endif