Nessuna descrizione
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.

SpriteLitPass.hlsl 2.1KB

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