설명 없음
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.

SobolBluenoiseSampling.hlsl 1.5KB

12345678910111213141516171819202122232425262728293031
  1. #ifndef _SAMPLING_SOBOLBLUENOISESAMPLING_HLSL_
  2. #define _SAMPLING_SOBOLBLUENOISESAMPLING_HLSL_
  3. #include "SamplingResources.hlsl"
  4. // This is an implementation of the method from the paper
  5. // "A Low-Discrepancy Sampler that Distributes Monte Carlo Errors as a Blue Noise in Screen Space" by Heitz et al.
  6. float GetBNDSequenceSample(uint2 pixelCoord, uint sampleIndex, uint sampleDimension)
  7. {
  8. // wrap arguments
  9. pixelCoord = pixelCoord & 127;
  10. sampleIndex = sampleIndex & 255;
  11. sampleDimension = sampleDimension & 255;
  12. // xor index based on optimized ranking
  13. uint rankingIndex = (pixelCoord.x + pixelCoord.y * 128) * 8 + (sampleDimension & 7);
  14. uint rankedSampleIndex = sampleIndex ^ clamp((uint)(_SobolRankingTile[uint2(rankingIndex & 127, rankingIndex / 128)] * 256.0), 0, 255);
  15. // fetch value in sequence
  16. uint value = clamp((uint)(_SobolOwenScrambledSequence[uint2(sampleDimension, rankedSampleIndex.x)] * 256.0), 0, 255);
  17. // If the dimension is optimized, xor sequence value based on optimized scrambling
  18. uint scramblingIndex = (pixelCoord.x + pixelCoord.y * 128) * 8 + (sampleDimension & 7);
  19. float scramblingValue = min(_SobolScramblingTile[uint2(scramblingIndex & 127, scramblingIndex / 128)], 0.999);
  20. value = value ^ uint(scramblingValue * 256.0);
  21. // Convert to float (to avoid the same 1/256th quantization everywhere, we jitter by the pixel scramblingValue)
  22. return (max(0.001, scramblingValue) + value) / 256.0;
  23. }
  24. #endif // _SAMPLING_SOBOLBLUENOISESAMPLING_HLSL_