Guest User

Watch_dogs shader file

a guest
Jun 16th, 2014
469
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.08 KB | None | 0 0
  1. #ifndef _SHADERS_DEFERREDAMBIENT_INC_FX_
  2. #define _SHADERS_DEFERREDAMBIENT_INC_FX_
  3.  
  4. #include "Ambient.inc.fx"
  5.  
  6. #if defined(XBOX360_TARGET) || defined(PS3_TARGET)
  7. #define READ_3D_TEXTURES
  8. #endif
  9.  
  10. #define PROBE_VOLUME_SIZE_Z 17
  11. #define LINEARZSPACING 3.5f
  12.  
  13. float3 GetUnifiedVolumeUVW(in float3 worldSpacePosition, float baseZ)
  14. {
  15. // Figure out where we stand in the our 3x3 grid (128m per tile).
  16. float2 distFromCenter = worldSpacePosition.xy - VolumeCentreGlobal.xy;
  17. float2 uv = (distFromCenter / (256.0f / 23.0f * 120.0f)) + 0.5f;
  18.  
  19. // Since we have 24x24 probes, but we have 1 row/column of redundancy between
  20. // tiles, we need to introduce a 1px offset for each tile as we move away
  21. // from the center.
  22. uv += round(distFromCenter / 256.0f) / 120.0f;
  23.  
  24. float w = saturate((worldSpacePosition.z - baseZ) / LINEARZSPACING / PROBE_VOLUME_SIZE_Z);
  25.  
  26. return float3(uv, w);
  27. }
  28.  
  29. // This is al ultra dumbed-down version of what there is in DeferredAmbient.fx,
  30. // designed for rain light. Assumes normal pointing up and no floor correction.
  31. float3 GetRainLightProbeAmbient( float3 worldSpacePos )
  32. {
  33. float3 volumeUVW = GetUnifiedVolumeUVW(worldSpacePos.xyz, CenterBaseZ);
  34.  
  35. float4 finalUVW4 = float4(volumeUVW, 0);
  36. finalUVW4.z += (0.5f / PROBE_VOLUME_SIZE_Z);
  37.  
  38. #ifdef READ_3D_TEXTURES
  39. #ifdef NOMAD_PLATFORM_XENON
  40. // On XBOX, since the texture filtering is good, we stick to
  41. // 8-bit texture. We dont use gamma because this would require us
  42. // to use one of the _AS_16 format the the shader becomes
  43. // texture cache stall bound. We opt for a manual (non-gamma-correct)
  44. // filtering using a sqrt() for encoding and x^2 for decoding.
  45. float4 encodedUpperColor = tex3Dlod(BigProbeVolumeTextureUpperColor3D,finalUVW4);
  46. float3 upperColor = (encodedUpperColor.rgb * encodedUpperColor.rgb) / (encodedUpperColor.a * RelightingMultiplier.y);
  47. #else
  48. float3 upperColor = tex3Dlod(BigProbeVolumeTextureUpperColor3D,finalUVW4).xyz;
  49. #endif
  50. #else
  51. // This is PC only, who cares.
  52. float3 upperColor = DefaultProbeUpperColor;
  53. #endif
  54.  
  55. return upperColor;
  56. }
  57.  
  58. #endif // _SHADERS_DEFERREDAMBIENT_INC_FX_
Add Comment
Please, Sign In to add comment