Açıklama Yok
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.

UnlitPass.hlsl 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Unlit.hlsl"
  2. void InitializeInputData(Varyings input, out InputData inputData)
  3. {
  4. inputData = (InputData)0;
  5. // InputData is only used for DebugDisplay purposes in Unlit, so these are not initialized.
  6. #if defined(DEBUG_DISPLAY)
  7. inputData.positionWS = input.positionWS;
  8. inputData.positionCS = input.positionCS;
  9. inputData.normalWS = input.normalWS;
  10. #else
  11. inputData.positionWS = half3(0, 0, 0);
  12. inputData.normalWS = half3(0, 0, 1);
  13. inputData.viewDirectionWS = half3(0, 0, 1);
  14. #endif
  15. inputData.shadowCoord = 0;
  16. inputData.fogCoord = 0;
  17. inputData.vertexLighting = half3(0, 0, 0);
  18. inputData.bakedGI = half3(0, 0, 0);
  19. inputData.normalizedScreenSpaceUV = 0;
  20. inputData.shadowMask = half4(1, 1, 1, 1);
  21. }
  22. PackedVaryings vert(Attributes input)
  23. {
  24. Varyings output = (Varyings)0;
  25. output = BuildVaryings(input);
  26. PackedVaryings packedOutput = PackVaryings(output);
  27. return packedOutput;
  28. }
  29. void frag(
  30. PackedVaryings packedInput
  31. , out half4 outColor : SV_Target0
  32. #ifdef _WRITE_RENDERING_LAYERS
  33. , out float4 outRenderingLayers : SV_Target1
  34. #endif
  35. )
  36. {
  37. Varyings unpacked = UnpackVaryings(packedInput);
  38. UNITY_SETUP_INSTANCE_ID(unpacked);
  39. UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(unpacked);
  40. SurfaceDescription surfaceDescription = BuildSurfaceDescription(unpacked);
  41. #if defined(_SURFACE_TYPE_TRANSPARENT)
  42. bool isTransparent = true;
  43. #else
  44. bool isTransparent = false;
  45. #endif
  46. #if defined(_ALPHATEST_ON)
  47. half alpha = AlphaDiscard(surfaceDescription.Alpha, surfaceDescription.AlphaClipThreshold);
  48. #elif defined(_SURFACE_TYPE_TRANSPARENT)
  49. half alpha = surfaceDescription.Alpha;
  50. #else
  51. half alpha = half(1.0);
  52. #endif
  53. #if defined(LOD_FADE_CROSSFADE) && USE_UNITY_CROSSFADE
  54. LODFadeCrossFade(unpacked.positionCS);
  55. #endif
  56. #if defined(_ALPHAMODULATE_ON)
  57. surfaceDescription.BaseColor = AlphaModulate(surfaceDescription.BaseColor, alpha);
  58. #endif
  59. #if defined(_DBUFFER)
  60. ApplyDecalToBaseColor(unpacked.positionCS, surfaceDescription.BaseColor);
  61. #endif
  62. InputData inputData;
  63. InitializeInputData(unpacked, inputData);
  64. #ifdef VARYINGS_NEED_TEXCOORD0
  65. SETUP_DEBUG_TEXTURE_DATA(inputData, unpacked.texCoord0);
  66. #else
  67. SETUP_DEBUG_TEXTURE_DATA_NO_UV(inputData);
  68. #endif
  69. half4 finalColor = UniversalFragmentUnlit(inputData, surfaceDescription.BaseColor, alpha);
  70. finalColor.a = OutputAlpha(finalColor.a, isTransparent);
  71. #if defined(_SCREEN_SPACE_OCCLUSION) && !defined(_SURFACE_TYPE_TRANSPARENT)
  72. float2 normalizedScreenSpaceUV = GetNormalizedScreenSpaceUV(unpacked.positionCS);
  73. AmbientOcclusionFactor aoFactor = GetScreenSpaceAmbientOcclusion(normalizedScreenSpaceUV);
  74. finalColor.rgb *= aoFactor.directAmbientOcclusion;
  75. #endif
  76. outColor = finalColor;
  77. #ifdef _WRITE_RENDERING_LAYERS
  78. uint renderingLayers = GetMeshRenderingLayer();
  79. outRenderingLayers = float4(EncodeMeshRenderingLayer(renderingLayers), 0, 0, 0);
  80. #endif
  81. }