浏览代码

Merge pull request #64 from EvgeniiG/master

Optimize IntegrateLD()
/main
GitHub 8 年前
当前提交
d5fa4483
共有 10 个文件被更改,包括 668 次插入40 次删除
  1. 2
      Assets/ScriptableRenderLoop/HDRenderLoop/Sky/Resources/GGXConvolve.shader
  2. 11
      Assets/ScriptableRenderLoop/ShaderLibrary/BSDF.hlsl
  3. 4
      Assets/ScriptableRenderLoop/ShaderLibrary/Common.hlsl
  4. 15
      Assets/ScriptableRenderLoop/ShaderLibrary/CommonLighting.hlsl
  5. 55
      Assets/ScriptableRenderLoop/ShaderLibrary/ImageBasedLighting.hlsl
  6. 26
      Assets/ScriptableRenderLoop/ShaderLibrary/Sampling.hlsl
  7. 153
      Assets/ScriptableRenderLoop/ShaderLibrary/Fibonacci.hlsl
  8. 9
      Assets/ScriptableRenderLoop/ShaderLibrary/Fibonacci.hlsl.meta
  9. 424
      Assets/ScriptableRenderLoop/ShaderLibrary/Hammersley.hlsl
  10. 9
      Assets/ScriptableRenderLoop/ShaderLibrary/Hammersley.hlsl.meta

2
Assets/ScriptableRenderLoop/HDRenderLoop/Sky/Resources/GGXConvolve.shader


PerceptualRoughnessToRoughness(perceptualRoughness),
_MipMapCount,
_InvOmegaP,
64,
55, // Matches the size of the precomputed Fibonacci point set
true);
return val;

11
Assets/ScriptableRenderLoop/ShaderLibrary/BSDF.hlsl


return INV_PI * D_GGXNoPI(NdotH, roughness);
}
float D_GGX_Inverse(float NdotH, float roughness)
{
roughness = max(roughness, UNITY_MIN_ROUGHNESS);
float a2 = roughness * roughness;
float f = (NdotH * a2 - NdotH) * NdotH + 1.0;
float g = (f * f) / a2;
return PI * g;
}
// Ref: http://jcgt.org/published/0003/02/03/paper.pdf
float V_SmithJointGGX(float NdotL, float NdotV, float roughness)
{

4
Assets/ScriptableRenderLoop/ShaderLibrary/Common.hlsl


float GetShiftedNdotV(inout float3 N, float3 V, bool twoSided)
{
float NdotV = dot(N, V);
float limit = 1e-6;
float limit = 1e-4;
if (!twoSided && NdotV < limit)
{
// We do not renormalize the normal because { abs(length(N) - 1.0) < limit }.

15
Assets/ScriptableRenderLoop/ShaderLibrary/CommonLighting.hlsl


return dot(v, v) - v2.x * v2.y - v2.y * v2.z - v2.z * v2.x + v2.x * v2.y * v2.z;
}
// texelArea = 4.0 / (resolution * resolution).
// Ref: http://bpeers.com/blog/?itemid=1017
float ComputeCubemapTexelSolidAngle(float3 L, float texelArea)
{
// Stretch 'L' by (1/d) so that it points at a side of a [-1, 1]^2 cube.
float d = Max3(abs(L.x), abs(L.y), abs(L.z));
// Since 'L' is a unit vector, we can directly compute its
// new (inverse) length without dividing 'L' by 'd' first.
float invDist = d;
// dw = dA * cosTheta / (dist * dist), cosTheta = 1.0 / dist,
// where 'dA' is the area of the cube map texel.
return texelArea * invDist * invDist * invDist;
}
//-----------------------------------------------------------------------------
// Attenuation functions
//-----------------------------------------------------------------------------

55
Assets/ScriptableRenderLoop/ShaderLibrary/ImageBasedLighting.hlsl


out float3 L)
{
// Cosine sampling - ref: http://www.rorydriscoll.com/2009/01/07/better-sampling/
float cosTheta = sqrt(max(0.0, 1.0 - u.x));
float cosTheta = sqrt(saturate(1.0 - u.x));
float sinTheta = sqrt(u.x);
float phi = TWO_PI * u.y;

{
// GGX NDF sampling
float cosThetaH = sqrt((1.0 - u.x) / (1.0 + (roughness * roughness - 1.0) * u.x));
float sinThetaH = sqrt(max(0.0, 1.0 - cosThetaH * cosThetaH));
float sinThetaH = sqrt(saturate(1.0 - cosThetaH * cosThetaH));
float phiH = TWO_PI * u.y;
// Transform from spherical into cartesian

// Convert sample from half angle to incident angle
L = 2.0 * dot(V, H) * H - V;
}
// Special case of ImportanceSampleGGXDir() where N == V.
// Approximates GGX with a BRDF which is isotropic for all viewing angles.
void ImportanceSampleGGXViewIndDir(float2 u,
float3 N,
float3 tangentX,
float3 tangentY,
float roughness,
out float3 L,
out float NdotH)
{
// GGX NDF sampling
float cosThetaH = sqrt((1.0 - u.x) / (1.0 + (roughness * roughness - 1.0) * u.x));
float sinThetaH = sqrt(saturate(1.0 - cosThetaH * cosThetaH));
float phiH = TWO_PI * u.y;
// Transform from spherical into Cartesian.
float3 localH = float3(sinThetaH * cos(phiH), sinThetaH * sin(phiH), cosThetaH);
// localN == localV == float3(0.0, 0.0, 1.0).
NdotH = localH.z;
// Compute { L = reflect(-localV, localH) }.
float VdotH = NdotH;
L = float3(0.0, 0.0, -1.0) + 2.0 * VdotH * localH;
// Local to world
L = tangentX * L.x + tangentY * L.y + N * L.z;
}
// ref: http://blog.selfshadow.com/publications/s2012-shading-course/burley/s2012_pbs_disney_brdf_notes_v3.pdf p26

float roughness,
float mipmapcount,
float invOmegaP,
uint sampleCount,
uint sampleCount, // Matches the size of the precomputed Fibonacci point set
float3 acc = float3(0.0, 0.0, 0.0);
float accWeight = 0;
float3 acc = float3(0.0, 0.0, 0.0);
float accWeight = 0;
float2 randNum = InitRandom(V.xy * 0.5 + 0.5);

for (uint i = 0; i < sampleCount; ++i)
{
float2 u = Hammersley2d(i, sampleCount);
u = frac(u + randNum + 0.5);
float2 u = k_Fibonacci2dSeq55[i];
u = frac(u + randNum);
float3 H;
ImportanceSampleGGXDir(u, V, N, tangentX, tangentY, roughness, H, L);
float NdotH;
ImportanceSampleGGXViewIndDir(u, N, tangentX, tangentY, roughness, L, NdotH);
float NdotL = saturate(dot(N,L));
float NdotL = saturate(dot(N, L));
float mipLevel;

// - OmegaS : Solid angle associated to a sample
// - OmegaP : Solid angle associated to a pixel of the cubemap
float NdotH = saturate(dot(N, H));
float pdf = D_GGX(NdotH, roughness) * 0.25;
float omegaS = 1.0 / (sampleCount * pdf); // Solid angle associated with the sample
float invPdf = D_GGX_Inverse(NdotH, roughness) * 4.0;
float omegaS = rcp(sampleCount) * invPdf; // Solid angle associated with the sample
// invOmegaP is precomputed on CPU and provide as a parameter of the function
// float omegaP = FOUR_PI / (6.0f * cubemapWidth * cubemapWidth); // Solid angle associated with the pixel of the cubemap
mipLevel = 0.5 * log2(omegaS * invOmegaP) + 1.0; // Clamp is not necessary as the hardware will do it

26
Assets/ScriptableRenderLoop/ShaderLibrary/Sampling.hlsl


// Sample generator
//-----------------------------------------------------------------------------
// Ref: http://holger.dammertz.org/stuff/notes_HammersleyOnHemisphere.html
uint ReverseBits32(uint bits)
{
#if 1 // Shader model 5
return reversebits(bits);
#else
bits = (bits << 16) | (bits >> 16);
bits = ((bits & 0x00ff00ff) << 8) | ((bits & 0xff00ff00) >> 8);
bits = ((bits & 0x0f0f0f0f) << 4) | ((bits & 0xf0f0f0f0) >> 4);
bits = ((bits & 0x33333333) << 2) | ((bits & 0xcccccccc) >> 2);
bits = ((bits & 0x55555555) << 1) | ((bits & 0xaaaaaaaa) >> 1);
return bits;
#endif
}
float RadicalInverse_VdC(uint bits)
{
return float(ReverseBits32(bits)) * 2.3283064365386963e-10; // 0x100000000
}
float2 Hammersley2d(uint i, uint maxSampleCount)
{
return float2(float(i) / float(maxSampleCount), RadicalInverse_VdC(i));
}
#include "Fibonacci.hlsl"
#include "Hammersley.hlsl"
float Hash(uint s)
{

153
Assets/ScriptableRenderLoop/ShaderLibrary/Fibonacci.hlsl


#ifndef UNITY_FIBONACCI_INCLUDED
#define UNITY_FIBONACCI_INCLUDED
// Computes a point using the Fibonacci sequence of length N.
// Input: Fib[N - 1], Fib[N - 2], and the index 'i' of the point.
// Ref: Integration of nonperiodic functions of two variables by Fibonacci lattice rules
float2 Fibonacci2dSeq(float fibN1, float fibN2, int i)
{
// 3 cycles on GCN if 'fibN1' and 'fibN2' are known at compile time.
return float2(i / fibN1, frac(i * (fibN2 / fibN1)));
}
static const int k_FibonacciSeq[] = {
0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377
};
static const float2 k_Fibonacci2dSeq21[] = {
float2(0.00000000, 0.00000000),
float2(0.04761905, 0.61904764),
float2(0.09523810, 0.23809528),
float2(0.14285715, 0.85714293),
float2(0.19047619, 0.47619057),
float2(0.23809524, 0.09523821),
float2(0.28571430, 0.71428585),
float2(0.33333334, 0.33333349),
float2(0.38095239, 0.95238113),
float2(0.42857143, 0.57142878),
float2(0.47619048, 0.19047642),
float2(0.52380955, 0.80952406),
float2(0.57142860, 0.42857170),
float2(0.61904764, 0.04761887),
float2(0.66666669, 0.66666698),
float2(0.71428573, 0.28571510),
float2(0.76190478, 0.90476227),
float2(0.80952382, 0.52380943),
float2(0.85714287, 0.14285755),
float2(0.90476191, 0.76190567),
float2(0.95238096, 0.38095284)
};
static const float2 k_Fibonacci2dSeq34[] = {
float2(0.00000000, 0.00000000),
float2(0.02941176, 0.61764705),
float2(0.05882353, 0.23529410),
float2(0.08823530, 0.85294116),
float2(0.11764706, 0.47058821),
float2(0.14705883, 0.08823538),
float2(0.17647059, 0.70588231),
float2(0.20588236, 0.32352924),
float2(0.23529412, 0.94117641),
float2(0.26470590, 0.55882359),
float2(0.29411766, 0.17647076),
float2(0.32352942, 0.79411745),
float2(0.35294119, 0.41176462),
float2(0.38235295, 0.02941132),
float2(0.41176471, 0.64705849),
float2(0.44117647, 0.26470566),
float2(0.47058824, 0.88235283),
float2(0.50000000, 0.50000000),
float2(0.52941179, 0.11764717),
float2(0.55882353, 0.73529434),
float2(0.58823532, 0.35294151),
float2(0.61764705, 0.97058773),
float2(0.64705884, 0.58823490),
float2(0.67647058, 0.20588207),
float2(0.70588237, 0.82352924),
float2(0.73529410, 0.44117641),
float2(0.76470590, 0.05882263),
float2(0.79411763, 0.67646980),
float2(0.82352942, 0.29411697),
float2(0.85294116, 0.91176414),
float2(0.88235295, 0.52941132),
float2(0.91176468, 0.14705849),
float2(0.94117647, 0.76470566),
float2(0.97058821, 0.38235283)
};
static const float2 k_Fibonacci2dSeq55[] = {
float2(0.00000000, 0.00000000),
float2(0.01818182, 0.61818182),
float2(0.03636364, 0.23636365),
float2(0.05454545, 0.85454547),
float2(0.07272727, 0.47272730),
float2(0.09090909, 0.09090900),
float2(0.10909091, 0.70909095),
float2(0.12727273, 0.32727289),
float2(0.14545454, 0.94545460),
float2(0.16363636, 0.56363630),
float2(0.18181819, 0.18181801),
float2(0.20000000, 0.80000019),
float2(0.21818182, 0.41818190),
float2(0.23636363, 0.03636360),
float2(0.25454545, 0.65454578),
float2(0.27272728, 0.27272701),
float2(0.29090908, 0.89090919),
float2(0.30909091, 0.50909138),
float2(0.32727271, 0.12727261),
float2(0.34545454, 0.74545479),
float2(0.36363637, 0.36363602),
float2(0.38181818, 0.98181820),
float2(0.40000001, 0.60000038),
float2(0.41818181, 0.21818161),
float2(0.43636364, 0.83636379),
float2(0.45454547, 0.45454597),
float2(0.47272727, 0.07272720),
float2(0.49090910, 0.69090843),
float2(0.50909090, 0.30909157),
float2(0.52727270, 0.92727280),
float2(0.54545456, 0.54545403),
float2(0.56363636, 0.16363716),
float2(0.58181816, 0.78181839),
float2(0.60000002, 0.39999962),
float2(0.61818182, 0.01818275),
float2(0.63636363, 0.63636398),
float2(0.65454543, 0.25454521),
float2(0.67272729, 0.87272835),
float2(0.69090909, 0.49090958),
float2(0.70909089, 0.10909081),
float2(0.72727275, 0.72727203),
float2(0.74545455, 0.34545517),
float2(0.76363635, 0.96363640),
float2(0.78181821, 0.58181763),
float2(0.80000001, 0.20000076),
float2(0.81818181, 0.81818199),
float2(0.83636361, 0.43636322),
float2(0.85454547, 0.05454636),
float2(0.87272727, 0.67272758),
float2(0.89090908, 0.29090881),
float2(0.90909094, 0.90909195),
float2(0.92727274, 0.52727318),
float2(0.94545454, 0.14545441),
float2(0.96363634, 0.76363754),
float2(0.98181820, 0.38181686)
};
// Loads elements from one of the precomputed tables for sequence lengths of 9, 10, 11.
// Computes the values at runtime otherwise.
// For sampling, the size of the point set is given by { k_FibonacciSeq[sequenceLength - 1] }.
float2 Fibonacci2d(uint i, uint sequenceLength)
{
int fibN1 = k_FibonacciSeq[sequenceLength - 1];
int fibN2 = k_FibonacciSeq[sequenceLength - 2];
switch (fibN1)
{
case 21: return k_Fibonacci2dSeq21[i];
case 34: return k_Fibonacci2dSeq34[i];
case 55: return k_Fibonacci2dSeq55[i];
default: Fibonacci2dSeq(fibN1, fibN2, i);
}
}
#endif // UNITY_FIBONACCI_INCLUDED

9
Assets/ScriptableRenderLoop/ShaderLibrary/Fibonacci.hlsl.meta


fileFormatVersion: 2
guid: 63275e6ba7e477f43a376217dc2e147f
timeCreated: 1482325231
licenseType: Pro
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

424
Assets/ScriptableRenderLoop/ShaderLibrary/Hammersley.hlsl


#ifndef UNITY_HAMMERSLEY_INCLUDED
#define UNITY_HAMMERSLEY_INCLUDED
// Ref: http://holger.dammertz.org/stuff/notes_HammersleyOnHemisphere.html
uint ReverseBits32(uint bits)
{
#if 1 // Shader model 5
return reversebits(bits);
#else
bits = (bits << 16) | (bits >> 16);
bits = ((bits & 0x00ff00ff) << 8) | ((bits & 0xff00ff00) >> 8);
bits = ((bits & 0x0f0f0f0f) << 4) | ((bits & 0xf0f0f0f0) >> 4);
bits = ((bits & 0x33333333) << 2) | ((bits & 0xcccccccc) >> 2);
bits = ((bits & 0x55555555) << 1) | ((bits & 0xaaaaaaaa) >> 1);
return bits;
#endif
}
float RadicalInverse_VdC(uint bits)
{
return float(ReverseBits32(bits)) * 2.3283064365386963e-10; // 0x100000000
}
float2 Hammersley2dSeq(uint i, uint sequenceLength)
{
return float2(float(i) / float(sequenceLength), RadicalInverse_VdC(i));
}
static const float2 k_Hammersley2dSeq16[] = {
float2(0.00000000, 0.00000000),
float2(0.06250000, 0.50000000),
float2(0.12500000, 0.25000000),
float2(0.18750000, 0.75000000),
float2(0.25000000, 0.12500000),
float2(0.31250000, 0.62500000),
float2(0.37500000, 0.37500000),
float2(0.43750000, 0.87500000),
float2(0.50000000, 0.06250000),
float2(0.56250000, 0.56250000),
float2(0.62500000, 0.31250000),
float2(0.68750000, 0.81250000),
float2(0.75000000, 0.18750000),
float2(0.81250000, 0.68750000),
float2(0.87500000, 0.43750000),
float2(0.93750000, 0.93750000)
};
static const float2 k_Hammersley2dSeq32[] = {
float2(0.00000000, 0.00000000),
float2(0.03125000, 0.50000000),
float2(0.06250000, 0.25000000),
float2(0.09375000, 0.75000000),
float2(0.12500000, 0.12500000),
float2(0.15625000, 0.62500000),
float2(0.18750000, 0.37500000),
float2(0.21875000, 0.87500000),
float2(0.25000000, 0.06250000),
float2(0.28125000, 0.56250000),
float2(0.31250000, 0.31250000),
float2(0.34375000, 0.81250000),
float2(0.37500000, 0.18750000),
float2(0.40625000, 0.68750000),
float2(0.43750000, 0.43750000),
float2(0.46875000, 0.93750000),
float2(0.50000000, 0.03125000),
float2(0.53125000, 0.53125000),
float2(0.56250000, 0.28125000),
float2(0.59375000, 0.78125000),
float2(0.62500000, 0.15625000),
float2(0.65625000, 0.65625000),
float2(0.68750000, 0.40625000),
float2(0.71875000, 0.90625000),
float2(0.75000000, 0.09375000),
float2(0.78125000, 0.59375000),
float2(0.81250000, 0.34375000),
float2(0.84375000, 0.84375000),
float2(0.87500000, 0.21875000),
float2(0.90625000, 0.71875000),
float2(0.93750000, 0.46875000),
float2(0.96875000, 0.96875000)
};
static const float2 k_Hammersley2dSeq64[] = {
float2(0.00000000, 0.00000000),
float2(0.01562500, 0.50000000),
float2(0.03125000, 0.25000000),
float2(0.04687500, 0.75000000),
float2(0.06250000, 0.12500000),
float2(0.07812500, 0.62500000),
float2(0.09375000, 0.37500000),
float2(0.10937500, 0.87500000),
float2(0.12500000, 0.06250000),
float2(0.14062500, 0.56250000),
float2(0.15625000, 0.31250000),
float2(0.17187500, 0.81250000),
float2(0.18750000, 0.18750000),
float2(0.20312500, 0.68750000),
float2(0.21875000, 0.43750000),
float2(0.23437500, 0.93750000),
float2(0.25000000, 0.03125000),
float2(0.26562500, 0.53125000),
float2(0.28125000, 0.28125000),
float2(0.29687500, 0.78125000),
float2(0.31250000, 0.15625000),
float2(0.32812500, 0.65625000),
float2(0.34375000, 0.40625000),
float2(0.35937500, 0.90625000),
float2(0.37500000, 0.09375000),
float2(0.39062500, 0.59375000),
float2(0.40625000, 0.34375000),
float2(0.42187500, 0.84375000),
float2(0.43750000, 0.21875000),
float2(0.45312500, 0.71875000),
float2(0.46875000, 0.46875000),
float2(0.48437500, 0.96875000),
float2(0.50000000, 0.01562500),
float2(0.51562500, 0.51562500),
float2(0.53125000, 0.26562500),
float2(0.54687500, 0.76562500),
float2(0.56250000, 0.14062500),
float2(0.57812500, 0.64062500),
float2(0.59375000, 0.39062500),
float2(0.60937500, 0.89062500),
float2(0.62500000, 0.07812500),
float2(0.64062500, 0.57812500),
float2(0.65625000, 0.32812500),
float2(0.67187500, 0.82812500),
float2(0.68750000, 0.20312500),
float2(0.70312500, 0.70312500),
float2(0.71875000, 0.45312500),
float2(0.73437500, 0.95312500),
float2(0.75000000, 0.04687500),
float2(0.76562500, 0.54687500),
float2(0.78125000, 0.29687500),
float2(0.79687500, 0.79687500),
float2(0.81250000, 0.17187500),
float2(0.82812500, 0.67187500),
float2(0.84375000, 0.42187500),
float2(0.85937500, 0.92187500),
float2(0.87500000, 0.10937500),
float2(0.89062500, 0.60937500),
float2(0.90625000, 0.35937500),
float2(0.92187500, 0.85937500),
float2(0.93750000, 0.23437500),
float2(0.95312500, 0.73437500),
float2(0.96875000, 0.48437500),
float2(0.98437500, 0.98437500)
};
static const float2 k_Hammersley2dSeq256[] = {
float2(0.00000000, 0.00000000),
float2(0.00390625, 0.50000000),
float2(0.00781250, 0.25000000),
float2(0.01171875, 0.75000000),
float2(0.01562500, 0.12500000),
float2(0.01953125, 0.62500000),
float2(0.02343750, 0.37500000),
float2(0.02734375, 0.87500000),
float2(0.03125000, 0.06250000),
float2(0.03515625, 0.56250000),
float2(0.03906250, 0.31250000),
float2(0.04296875, 0.81250000),
float2(0.04687500, 0.18750000),
float2(0.05078125, 0.68750000),
float2(0.05468750, 0.43750000),
float2(0.05859375, 0.93750000),
float2(0.06250000, 0.03125000),
float2(0.06640625, 0.53125000),
float2(0.07031250, 0.28125000),
float2(0.07421875, 0.78125000),
float2(0.07812500, 0.15625000),
float2(0.08203125, 0.65625000),
float2(0.08593750, 0.40625000),
float2(0.08984375, 0.90625000),
float2(0.09375000, 0.09375000),
float2(0.09765625, 0.59375000),
float2(0.10156250, 0.34375000),
float2(0.10546875, 0.84375000),
float2(0.10937500, 0.21875000),
float2(0.11328125, 0.71875000),
float2(0.11718750, 0.46875000),
float2(0.12109375, 0.96875000),
float2(0.12500000, 0.01562500),
float2(0.12890625, 0.51562500),
float2(0.13281250, 0.26562500),
float2(0.13671875, 0.76562500),
float2(0.14062500, 0.14062500),
float2(0.14453125, 0.64062500),
float2(0.14843750, 0.39062500),
float2(0.15234375, 0.89062500),
float2(0.15625000, 0.07812500),
float2(0.16015625, 0.57812500),
float2(0.16406250, 0.32812500),
float2(0.16796875, 0.82812500),
float2(0.17187500, 0.20312500),
float2(0.17578125, 0.70312500),
float2(0.17968750, 0.45312500),
float2(0.18359375, 0.95312500),
float2(0.18750000, 0.04687500),
float2(0.19140625, 0.54687500),
float2(0.19531250, 0.29687500),
float2(0.19921875, 0.79687500),
float2(0.20312500, 0.17187500),
float2(0.20703125, 0.67187500),
float2(0.21093750, 0.42187500),
float2(0.21484375, 0.92187500),
float2(0.21875000, 0.10937500),
float2(0.22265625, 0.60937500),
float2(0.22656250, 0.35937500),
float2(0.23046875, 0.85937500),
float2(0.23437500, 0.23437500),
float2(0.23828125, 0.73437500),
float2(0.24218750, 0.48437500),
float2(0.24609375, 0.98437500),
float2(0.25000000, 0.00781250),
float2(0.25390625, 0.50781250),
float2(0.25781250, 0.25781250),
float2(0.26171875, 0.75781250),
float2(0.26562500, 0.13281250),
float2(0.26953125, 0.63281250),
float2(0.27343750, 0.38281250),
float2(0.27734375, 0.88281250),
float2(0.28125000, 0.07031250),
float2(0.28515625, 0.57031250),
float2(0.28906250, 0.32031250),
float2(0.29296875, 0.82031250),
float2(0.29687500, 0.19531250),
float2(0.30078125, 0.69531250),
float2(0.30468750, 0.44531250),
float2(0.30859375, 0.94531250),
float2(0.31250000, 0.03906250),
float2(0.31640625, 0.53906250),
float2(0.32031250, 0.28906250),
float2(0.32421875, 0.78906250),
float2(0.32812500, 0.16406250),
float2(0.33203125, 0.66406250),
float2(0.33593750, 0.41406250),
float2(0.33984375, 0.91406250),
float2(0.34375000, 0.10156250),
float2(0.34765625, 0.60156250),
float2(0.35156250, 0.35156250),
float2(0.35546875, 0.85156250),
float2(0.35937500, 0.22656250),
float2(0.36328125, 0.72656250),
float2(0.36718750, 0.47656250),
float2(0.37109375, 0.97656250),
float2(0.37500000, 0.02343750),
float2(0.37890625, 0.52343750),
float2(0.38281250, 0.27343750),
float2(0.38671875, 0.77343750),
float2(0.39062500, 0.14843750),
float2(0.39453125, 0.64843750),
float2(0.39843750, 0.39843750),
float2(0.40234375, 0.89843750),
float2(0.40625000, 0.08593750),
float2(0.41015625, 0.58593750),
float2(0.41406250, 0.33593750),
float2(0.41796875, 0.83593750),
float2(0.42187500, 0.21093750),
float2(0.42578125, 0.71093750),
float2(0.42968750, 0.46093750),
float2(0.43359375, 0.96093750),
float2(0.43750000, 0.05468750),
float2(0.44140625, 0.55468750),
float2(0.44531250, 0.30468750),
float2(0.44921875, 0.80468750),
float2(0.45312500, 0.17968750),
float2(0.45703125, 0.67968750),
float2(0.46093750, 0.42968750),
float2(0.46484375, 0.92968750),
float2(0.46875000, 0.11718750),
float2(0.47265625, 0.61718750),
float2(0.47656250, 0.36718750),
float2(0.48046875, 0.86718750),
float2(0.48437500, 0.24218750),
float2(0.48828125, 0.74218750),
float2(0.49218750, 0.49218750),
float2(0.49609375, 0.99218750),
float2(0.50000000, 0.00390625),
float2(0.50390625, 0.50390625),
float2(0.50781250, 0.25390625),
float2(0.51171875, 0.75390625),
float2(0.51562500, 0.12890625),
float2(0.51953125, 0.62890625),
float2(0.52343750, 0.37890625),
float2(0.52734375, 0.87890625),
float2(0.53125000, 0.06640625),
float2(0.53515625, 0.56640625),
float2(0.53906250, 0.31640625),
float2(0.54296875, 0.81640625),
float2(0.54687500, 0.19140625),
float2(0.55078125, 0.69140625),
float2(0.55468750, 0.44140625),
float2(0.55859375, 0.94140625),
float2(0.56250000, 0.03515625),
float2(0.56640625, 0.53515625),
float2(0.57031250, 0.28515625),
float2(0.57421875, 0.78515625),
float2(0.57812500, 0.16015625),
float2(0.58203125, 0.66015625),
float2(0.58593750, 0.41015625),
float2(0.58984375, 0.91015625),
float2(0.59375000, 0.09765625),
float2(0.59765625, 0.59765625),
float2(0.60156250, 0.34765625),
float2(0.60546875, 0.84765625),
float2(0.60937500, 0.22265625),
float2(0.61328125, 0.72265625),
float2(0.61718750, 0.47265625),
float2(0.62109375, 0.97265625),
float2(0.62500000, 0.01953125),
float2(0.62890625, 0.51953125),
float2(0.63281250, 0.26953125),
float2(0.63671875, 0.76953125),
float2(0.64062500, 0.14453125),
float2(0.64453125, 0.64453125),
float2(0.64843750, 0.39453125),
float2(0.65234375, 0.89453125),
float2(0.65625000, 0.08203125),
float2(0.66015625, 0.58203125),
float2(0.66406250, 0.33203125),
float2(0.66796875, 0.83203125),
float2(0.67187500, 0.20703125),
float2(0.67578125, 0.70703125),
float2(0.67968750, 0.45703125),
float2(0.68359375, 0.95703125),
float2(0.68750000, 0.05078125),
float2(0.69140625, 0.55078125),
float2(0.69531250, 0.30078125),
float2(0.69921875, 0.80078125),
float2(0.70312500, 0.17578125),
float2(0.70703125, 0.67578125),
float2(0.71093750, 0.42578125),
float2(0.71484375, 0.92578125),
float2(0.71875000, 0.11328125),
float2(0.72265625, 0.61328125),
float2(0.72656250, 0.36328125),
float2(0.73046875, 0.86328125),
float2(0.73437500, 0.23828125),
float2(0.73828125, 0.73828125),
float2(0.74218750, 0.48828125),
float2(0.74609375, 0.98828125),
float2(0.75000000, 0.01171875),
float2(0.75390625, 0.51171875),
float2(0.75781250, 0.26171875),
float2(0.76171875, 0.76171875),
float2(0.76562500, 0.13671875),
float2(0.76953125, 0.63671875),
float2(0.77343750, 0.38671875),
float2(0.77734375, 0.88671875),
float2(0.78125000, 0.07421875),
float2(0.78515625, 0.57421875),
float2(0.78906250, 0.32421875),
float2(0.79296875, 0.82421875),
float2(0.79687500, 0.19921875),
float2(0.80078125, 0.69921875),
float2(0.80468750, 0.44921875),
float2(0.80859375, 0.94921875),
float2(0.81250000, 0.04296875),
float2(0.81640625, 0.54296875),
float2(0.82031250, 0.29296875),
float2(0.82421875, 0.79296875),
float2(0.82812500, 0.16796875),
float2(0.83203125, 0.66796875),
float2(0.83593750, 0.41796875),
float2(0.83984375, 0.91796875),
float2(0.84375000, 0.10546875),
float2(0.84765625, 0.60546875),
float2(0.85156250, 0.35546875),
float2(0.85546875, 0.85546875),
float2(0.85937500, 0.23046875),
float2(0.86328125, 0.73046875),
float2(0.86718750, 0.48046875),
float2(0.87109375, 0.98046875),
float2(0.87500000, 0.02734375),
float2(0.87890625, 0.52734375),
float2(0.88281250, 0.27734375),
float2(0.88671875, 0.77734375),
float2(0.89062500, 0.15234375),
float2(0.89453125, 0.65234375),
float2(0.89843750, 0.40234375),
float2(0.90234375, 0.90234375),
float2(0.90625000, 0.08984375),
float2(0.91015625, 0.58984375),
float2(0.91406250, 0.33984375),
float2(0.91796875, 0.83984375),
float2(0.92187500, 0.21484375),
float2(0.92578125, 0.71484375),
float2(0.92968750, 0.46484375),
float2(0.93359375, 0.96484375),
float2(0.93750000, 0.05859375),
float2(0.94140625, 0.55859375),
float2(0.94531250, 0.30859375),
float2(0.94921875, 0.80859375),
float2(0.95312500, 0.18359375),
float2(0.95703125, 0.68359375),
float2(0.96093750, 0.43359375),
float2(0.96484375, 0.93359375),
float2(0.96875000, 0.12109375),
float2(0.97265625, 0.62109375),
float2(0.97656250, 0.37109375),
float2(0.98046875, 0.87109375),
float2(0.98437500, 0.24609375),
float2(0.98828125, 0.74609375),
float2(0.99218750, 0.49609375),
float2(0.99609375, 0.99609375)
};
// Loads elements from one of the precomputed tables for sequence lengths of 16, 32, 64, 256.
// Computes the values at runtime otherwise.
// For sampling, the size of the point set is the same as the sequence length.
float2 Hammersley2d(uint i, uint sequenceLength)
{
switch (sequenceLength)
{
case 16: return k_Hammersley2dSeq16[i];
case 32: return k_Hammersley2dSeq32[i];
case 64: return k_Hammersley2dSeq64[i];
case 256: return k_Hammersley2dSeq256[i];
default: return Hammersley2dSeq(i, sequenceLength);
}
}
#endif // UNITY_HAMMERSLEY_INCLUDED

9
Assets/ScriptableRenderLoop/ShaderLibrary/Hammersley.hlsl.meta


fileFormatVersion: 2
guid: aa5e319c8b8499f4fba1c3ecdd133545
timeCreated: 1482325231
licenseType: Pro
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存