UE4 Hammersley CosineSampleHemisphere数值测试

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

Index01234567
u00.1250.250.375

0.5

0.6250.750.875
v00.50.250.750.1250.6250.3750.875

CosineSampleHemisphere()

Index01234567
x1

0.3286

0-0.2588-0.8040-0.323500.1797
y00.32860.70710.25880-0.3235-0.6225-0.1797
z00.70710.50.8660.35350.79050.61230.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

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值