SimpleLitMetaPass.hlsl 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #ifndef UNIVERSAL_SIMPLE_LIT_META_PASS_INCLUDED
  2. #define UNIVERSAL_SIMPLE_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,
  24. unity_LightmapST, unity_DynamicLightmapST);
  25. output.uv = TRANSFORM_TEX(input.uv0, _BaseMap);
  26. return output;
  27. }
  28. half4 UniversalFragmentMetaSimple(Varyings input) : SV_Target
  29. {
  30. float2 uv = input.uv;
  31. MetaInput metaInput;
  32. metaInput.Albedo = _BaseColor.rgb * SAMPLE_TEXTURE2D(_BaseMap, sampler_BaseMap, uv).rgb;
  33. metaInput.SpecularColor = SampleSpecularSmoothness(uv, 1.0h, _SpecColor, TEXTURE2D_ARGS(_SpecGlossMap, sampler_SpecGlossMap)).xyz;
  34. metaInput.Emission = SampleEmission(uv, _EmissionColor.rgb, TEXTURE2D_ARGS(_EmissionMap, sampler_EmissionMap));
  35. return MetaFragment(metaInput);
  36. }
  37. //LWRP -> Universal Backwards Compatibility
  38. Varyings LightweightVertexMeta(Attributes input)
  39. {
  40. return UniversalVertexMeta(input);
  41. }
  42. half4 LightweightFragmentMetaSimple(Varyings input) : SV_Target
  43. {
  44. return UniversalFragmentMetaSimple(input);
  45. }
  46. #endif