Nav apraksta
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

SpriteUnlitPass.hlsl 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #include "Packages/com.unity.render-pipelines.universal/Shaders/2D/Include/Core2D.hlsl"
  2. #include "Packages/com.unity.render-pipelines.universal/Shaders/2D/Include/SurfaceData2D.hlsl"
  3. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Debug/Debugging2D.hlsl"
  4. half4 _RendererColor;
  5. PackedVaryings vert(Attributes input)
  6. {
  7. Varyings output = (Varyings)0;
  8. input.positionOS = UnityFlipSprite(input.positionOS, unity_SpriteProps.xy);
  9. output = BuildVaryings(input);
  10. output.color *= _RendererColor * unity_SpriteColor; // vertex color has to applied here
  11. PackedVaryings packedOutput = PackVaryings(output);
  12. return packedOutput;
  13. }
  14. half4 frag(PackedVaryings packedInput) : SV_TARGET
  15. {
  16. Varyings unpacked = UnpackVaryings(packedInput);
  17. UNITY_SETUP_INSTANCE_ID(unpacked);
  18. UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(unpacked);
  19. SurfaceDescription surfaceDescription = BuildSurfaceDescription(unpacked);
  20. #ifdef UNIVERSAL_USELEGACYSPRITEBLOCKS
  21. half4 color = surfaceDescription.SpriteColor;
  22. #else
  23. half4 color = half4(surfaceDescription.BaseColor, surfaceDescription.Alpha);
  24. #endif
  25. if (color.a == 0.0)
  26. discard;
  27. #if ALPHA_CLIP_THRESHOLD
  28. clip(color.a - surfaceDescription.AlphaClipThreshold);
  29. #endif
  30. #if defined(DEBUG_DISPLAY)
  31. SurfaceData2D surfaceData;
  32. InitializeSurfaceData(color.rgb, color.a, surfaceData);
  33. InputData2D inputData;
  34. InitializeInputData(unpacked.positionWS.xy, half2(unpacked.texCoord0.xy), inputData);
  35. half4 debugColor = 0;
  36. SETUP_DEBUG_DATA_2D(inputData, unpacked.positionWS, unpacked.positionCS);
  37. if (CanDebugOverrideOutputColor(surfaceData, inputData, debugColor))
  38. {
  39. return debugColor;
  40. }
  41. #endif
  42. // Disable vertex color multiplication. Users can get the color from VertexColor node
  43. #if !defined(HAVE_VFX_MODIFICATION) && !defined(_DISABLE_COLOR_TINT)
  44. color *= unpacked.color;
  45. #endif
  46. return color;
  47. }