UnlitPass.hlsl 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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.normalWS = input.normalWS;
  9. inputData.viewDirectionWS = input.viewDirectionWS;
  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. half4 frag(PackedVaryings packedInput) : SV_TARGET
  30. {
  31. Varyings unpacked = UnpackVaryings(packedInput);
  32. UNITY_SETUP_INSTANCE_ID(unpacked);
  33. UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(unpacked);
  34. SurfaceDescription surfaceDescription = BuildSurfaceDescription(unpacked);
  35. #if _ALPHATEST_ON
  36. half alpha = surfaceDescription.Alpha;
  37. clip(alpha - surfaceDescription.AlphaClipThreshold);
  38. #elif _SURFACE_TYPE_TRANSPARENT
  39. half alpha = surfaceDescription.Alpha;
  40. #else
  41. half alpha = 1;
  42. #endif
  43. #if defined(_DBUFFER)
  44. ApplyDecalToBaseColor(unpacked.positionCS, surfaceDescription.BaseColor);
  45. #endif
  46. InputData inputData;
  47. InitializeInputData(unpacked, inputData);
  48. // TODO: Mip debug modes would require this, open question how to do this on ShaderGraph.
  49. //SETUP_DEBUG_TEXTURE_DATA(inputData, input.texCoord1, _MainTex);
  50. half4 finalColor = UniversalFragmentUnlit(inputData, surfaceDescription.BaseColor, alpha);
  51. return finalColor;
  52. }