float2 Hammersley( uint Index, uint NumSamples, uint2 Random )
{
float E1 = frac( (float)Index / NumSamples + float( Random.x & 0xffff ) / (1<<16) );
float E2 = float( ReverseBits32(Index) ^ Random.y ) * 2.3283064365386963e-10;
return float2( E1, E2 );
}
NumSapmles=8, Random=0
Index | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | u | 0 | 0.125 | 0.25 | 0.375 | 0.5 | 0.625 | 0.75 | 0.875 | v | 0 | 0.5 | 0.25 | 0.75 | 0.125 | 0.625 | 0.375 | 0.875 |
CosineSampleHemisphere()
Index | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | x | 1 | 0.3286 | 0 | -0.2588 | -0.8040 | -0.3235 | 0 | 0.1797 | y | 0 | 0.3286 | 0.7071 | 0.2588 | 0 | -0.3235 | -0.6225 | -0.1797 | z | 0 | 0.7071 | 0.5 | 0.866 | 0.3535 | 0.7905 | 0.6123 | 0.9354 |
?Shader
float3 finalColor = float3(0,0,0);
int i = 0;
float numSamples = NumSamples;
while (i < numSamples)
{
float2 pdf = CosineSampleHemisphere(Hammersley( i, numSamples, 0 )).xy;
float2 a = (uv-0.5)*3;
float2 b = pdf;
float d = sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
if(d<CircleSize){finalColor.r+=1.0;}
i++;
}
return finalColor;
blur
?
?
?
|