Guest User

Untitled

a guest
Mar 19th, 2020
2,897
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1.  
  2. void MainLight_half(float3 WorldPos, out half3 Direction, out half3 Color, out half DistanceAtten, out half ShadowAtten)
  3. {
  4. #if SHADERGRAPH_PREVIEW
  5. Direction = half3(0.5, 0.5, 0);
  6. Color = 1;
  7. DistanceAtten = 1;
  8. ShadowAtten = 1;
  9. #else
  10. #if SHADOWS_SCREEN
  11. half4 clipPos = TransformWorldToHClip(WorldPos);
  12. half4 shadowCoord = ComputeScreenPos(clipPos);
  13. #else
  14. half4 shadowCoord = TransformWorldToShadowCoord(WorldPos);
  15. #endif
  16. Light mainLight = GetMainLight(shadowCoord);
  17. Direction = mainLight.direction;
  18. Color = mainLight.color;
  19. DistanceAtten = mainLight.distanceAttenuation;
  20.  
  21. #if !defined(_MAIN_LIGHT_SHADOWS) || defined(_RECEIVE_SHADOWS_OFF)
  22. ShadowAtten = 1.0h;
  23. #endif
  24.  
  25. #if SHADOWS_SCREEN
  26. ShadowAtten = SampleScreenSpaceShadowmap(shadowCoord);
  27. #else
  28. ShadowSamplingData shadowSamplingData = GetMainLightShadowSamplingData();
  29. half shadowStrength = GetMainLightShadowStrength();
  30. ShadowAtten = SampleShadowmap(shadowCoord, TEXTURE2D_ARGS(_MainLightShadowmapTexture,
  31. sampler_MainLightShadowmapTexture),
  32. shadowSamplingData, shadowStrength, false);
  33. #endif
  34. #endif
  35. }
Add Comment
Please, Sign In to add comment