Tim Cooper
8 年前
当前提交
1ddcb9ee
共有 28 个文件被更改,包括 1313 次插入 和 782 次删除
-
142Assets/ScriptableRenderLoop/HDRenderLoop/Material/LayeredLit/Editor/LayeredLitUI.cs
-
30Assets/ScriptableRenderLoop/HDRenderLoop/Material/LayeredLit/LayeredLit.shader
-
2Assets/ScriptableRenderLoop/HDRenderLoop/Material/Lit/Lit.shader
-
43Assets/ScriptableRenderLoop/HDRenderLoop/Material/Lit/LitData.hlsl
-
52Assets/ScriptableRenderLoop/HDRenderLoop/Material/Lit/LitSurfaceData.hlsl
-
143Assets/ScriptableRenderLoop/HDRenderLoop/Sky/ProceduralSky/ProceduralSkyParameters.cs
-
198Assets/ScriptableRenderLoop/HDRenderLoop/Sky/ProceduralSky/ProceduralSkyRenderer.cs
-
67Assets/ScriptableRenderLoop/HDRenderLoop/Sky/ProceduralSky/Resources/AtmosphericScattering.hlsl
-
43Assets/ScriptableRenderLoop/HDRenderLoop/Sky/ProceduralSky/Resources/SkyProcedural.shader
-
2Assets/ScriptableRenderLoop/HDRenderLoop/Sky/Resources/GGXConvolve.shader
-
8Assets/ScriptableRenderLoop/HDRenderLoop/Sky/SkyManager.cs
-
11Assets/ScriptableRenderLoop/ShaderLibrary/BSDF.hlsl
-
4Assets/ScriptableRenderLoop/ShaderLibrary/Common.hlsl
-
15Assets/ScriptableRenderLoop/ShaderLibrary/CommonLighting.hlsl
-
55Assets/ScriptableRenderLoop/ShaderLibrary/ImageBasedLighting.hlsl
-
26Assets/ScriptableRenderLoop/ShaderLibrary/Sampling.hlsl
-
24Assets/ScriptableRenderLoop/common/ShaderBase.h
-
137Assets/ScriptableRenderLoop/common/TextureCache.cs
-
4Assets/ScriptableRenderLoop/fptl/LightingTemplate.hlsl
-
10Assets/ScriptableRenderLoop/fptl/ReflectionTemplate.hlsl
-
2README.md
-
153Assets/ScriptableRenderLoop/ShaderLibrary/Fibonacci.hlsl
-
9Assets/ScriptableRenderLoop/ShaderLibrary/Fibonacci.hlsl.meta
-
424Assets/ScriptableRenderLoop/ShaderLibrary/Hammersley.hlsl
-
9Assets/ScriptableRenderLoop/ShaderLibrary/Hammersley.hlsl.meta
-
80Assets/ScriptableRenderLoop/common/CubeToSpherical.shader
-
12Assets/ScriptableRenderLoop/HDRenderLoop/Sky/AtmosphericParameters.cs.meta
-
390Assets/ScriptableRenderLoop/HDRenderLoop/Sky/AtmosphericParameters.cs
|
|||
#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 |
|
|||
fileFormatVersion: 2 |
|||
guid: 63275e6ba7e477f43a376217dc2e147f |
|||
timeCreated: 1482325231 |
|||
licenseType: Pro |
|||
ShaderImporter: |
|||
defaultTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
#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 |
|
|||
fileFormatVersion: 2 |
|||
guid: aa5e319c8b8499f4fba1c3ecdd133545 |
|||
timeCreated: 1482325231 |
|||
licenseType: Pro |
|||
ShaderImporter: |
|||
defaultTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
Shader "Hidden/CubeToPano" { |
|||
Properties { |
|||
_SrcBlend ("", Float) = 1 |
|||
_DstBlend ("", Float) = 1 |
|||
} |
|||
SubShader { |
|||
|
|||
|
|||
|
|||
|
|||
Pass |
|||
{ |
|||
ZWrite Off |
|||
ZTest Always |
|||
Cull Off |
|||
Blend Off |
|||
|
|||
|
|||
CGPROGRAM |
|||
#pragma target 4.5 |
|||
#pragma vertex vert |
|||
#pragma fragment frag |
|||
|
|||
#include "UnityCG.cginc" |
|||
|
|||
UNITY_DECLARE_TEXCUBE(_srcCubeTexture); |
|||
|
|||
uniform int _cubeMipLvl; |
|||
|
|||
|
|||
struct v2f { |
|||
float4 vertex : SV_POSITION; |
|||
float2 texcoord : TEXCOORD0; |
|||
}; |
|||
|
|||
v2f vert (float4 vertex : POSITION, float2 texcoord : TEXCOORD0) |
|||
{ |
|||
v2f o; |
|||
o.vertex = UnityObjectToClipPos(vertex); |
|||
o.texcoord = texcoord.xy; |
|||
return o; |
|||
} |
|||
|
|||
half2 DirectionToSphericalTexCoordinate(half3 dir) // use this for the lookup |
|||
{ |
|||
// coordinate frame is (-Z,X) meaning negative Z is primary axis and X is secondary axis. |
|||
float recipPi = 1.0/3.1415926535897932384626433832795; |
|||
return half2( 1.0-0.5*recipPi*atan2(dir.x, -dir.z), asin(dir.y)*recipPi+0.5 ); |
|||
} |
|||
|
|||
half3 SphericalTexCoordinateToDirection(half2 sphTexCoord) |
|||
{ |
|||
float pi = 3.1415926535897932384626433832795; |
|||
float theta = (1-sphTexCoord.x) * (pi*2); |
|||
float phi = (sphTexCoord.y-0.5) * pi; |
|||
|
|||
float csTh, siTh, csPh, siPh; |
|||
sincos(theta, siTh, csTh); |
|||
sincos(phi, siPh, csPh); |
|||
|
|||
// theta is 0 at negative Z (backwards). Coordinate frame is (-Z,X) meaning negative Z is primary axis and X is secondary axis. |
|||
return float3(siTh*csPh, siPh, -csTh*csPh); |
|||
} |
|||
|
|||
half4 frag (v2f i) : SV_Target |
|||
{ |
|||
uint2 pixCoord = ((uint2) i.vertex.xy); |
|||
|
|||
half3 dir = SphericalTexCoordinateToDirection(i.texcoord.xy); |
|||
half3 res = UNITY_SAMPLE_TEXCUBE_LOD(_srcCubeTexture, dir, (float) _cubeMipLvl).xyz; |
|||
|
|||
return half4(res,1.0); |
|||
} |
|||
|
|||
ENDCG |
|||
} |
|||
|
|||
} |
|||
Fallback Off |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 97f65a78ace4fbf4187144e9fe724009 |
|||
timeCreated: 1479992550 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using UnityEngine; |
|||
|
|||
[ExecuteInEditMode] |
|||
public class AtmosphericParameters : MonoBehaviour |
|||
{ |
|||
public enum OcclusionDownscale { x1 = 1, x2 = 2, x4 = 4 } |
|||
public enum OcclusionSamples { x64 = 0, x164 = 1, x244 = 2 } |
|||
public enum DepthTexture { Enable, Disable/*, Ignore*/ } // 'Ignore' appears to be currently unused.
|
|||
public enum ScatterDebugMode { None, Scattering, Occlusion, OccludedScattering, Rayleigh, Mie, Height } |
|||
|
|||
[Header("Global Settings")] |
|||
public Gradient worldRayleighColorRamp = null; |
|||
public float worldRayleighColorIntensity = 1f; |
|||
public float worldRayleighDensity = 10f; |
|||
public float worldRayleighExtinctionFactor = 1.1f; |
|||
public float worldRayleighIndirectScatter = 0.33f; |
|||
public Gradient worldMieColorRamp = null; |
|||
public float worldMieColorIntensity = 1f; |
|||
public float worldMieDensity = 15f; |
|||
public float worldMieExtinctionFactor = 0f; |
|||
public float worldMiePhaseAnisotropy = 0.9f; |
|||
public float worldNearScatterPush = 0f; |
|||
public float worldNormalDistance = 1000f; |
|||
|
|||
[Header("Height Settings")] |
|||
public Color heightRayleighColor = Color.white; |
|||
public float heightRayleighIntensity = 1f; |
|||
public float heightRayleighDensity = 10f; |
|||
public float heightMieDensity = 0f; |
|||
public float heightExtinctionFactor = 1.1f; |
|||
public float heightSeaLevel = 0f; |
|||
public float heightDistance = 50f; |
|||
public Vector3 heightPlaneShift = Vector3.zero; |
|||
public float heightNearScatterPush = 0f; |
|||
public float heightNormalDistance = 1000f; |
|||
|
|||
[Header("Sky Dome")] |
|||
/*public*/ Vector3 skyDomeScale = new Vector3(1f, 1f, 1f); |
|||
/*public*/ Vector3 skyDomeRotation = Vector3.zero; |
|||
/*public*/ Transform skyDomeTrackedYawRotation = null; |
|||
/*public*/ bool skyDomeVerticalFlip = false; |
|||
/*public*/ Cubemap skyDomeCube = null; |
|||
/*public*/ float skyDomeExposure = 1f; |
|||
/*public*/ Color skyDomeTint = Color.white; |
|||
/*public*/ Vector3 skyDomeOffset = Vector3.zero; |
|||
|
|||
/* |
|||
[Header("Scatter Occlusion")] |
|||
public bool useOcclusion = false; |
|||
public float occlusionBias = 0f; |
|||
public float occlusionBiasIndirect = 0.6f; |
|||
public float occlusionBiasClouds = 0.3f; |
|||
public OcclusionDownscale occlusionDownscale = OcclusionDownscale.x2; |
|||
public OcclusionSamples occlusionSamples = OcclusionSamples.x64; |
|||
public bool occlusionDepthFixup = true; |
|||
public float occlusionDepthThreshold = 25f; |
|||
public bool occlusionFullSky = false; |
|||
public float occlusionBiasSkyRayleigh = 0.2f; |
|||
public float occlusionBiasSkyMie = 0.4f; |
|||
*/ |
|||
|
|||
[Header("Other")] |
|||
public Shader atmosphericShaderOverride = null; |
|||
// public Shader occlusionShaderOverride = null;
|
|||
public float worldScaleExponent = 1.0f; |
|||
// public bool forcePerPixel = true;
|
|||
// public bool forcePostEffect = true;
|
|||
[Tooltip("Soft clouds need depth values. Ignore means externally controlled.")] |
|||
public DepthTexture depthTexture = DepthTexture.Enable; |
|||
public ScatterDebugMode debugMode = ScatterDebugMode.None; |
|||
|
|||
// [HideInInspector] public Shader occlusionShaderOverride;
|
|||
|
|||
// Camera m_currentCamera;
|
|||
|
|||
// UnityEngine.Rendering.CommandBuffer m_occlusionCmdAfterShadows, m_occlusionCmdBeforeScreen;
|
|||
|
|||
Material m_atmosphericMaterial = null; |
|||
// Material m_occlusionMaterial = null;
|
|||
bool m_isAwake = false; |
|||
|
|||
public static AtmosphericParameters instance { get; private set; } |
|||
|
|||
void Awake() |
|||
{ |
|||
if (worldRayleighColorRamp == null) |
|||
{ |
|||
worldRayleighColorRamp = new Gradient(); |
|||
worldRayleighColorRamp.SetKeys( |
|||
new[] { new GradientColorKey(new Color(0.3f, 0.4f, 0.6f), 0f), |
|||
new GradientColorKey(new Color(0.5f, 0.6f, 0.8f), 1f) }, |
|||
new[] { new GradientAlphaKey(1f, 0f), |
|||
new GradientAlphaKey(1f, 1f) } |
|||
); |
|||
} |
|||
|
|||
if (worldMieColorRamp == null) |
|||
{ |
|||
worldMieColorRamp = new Gradient(); |
|||
worldMieColorRamp.SetKeys( |
|||
new[] { new GradientColorKey(new Color(0.95f, 0.75f, 0.5f), 0f), |
|||
new GradientColorKey(new Color(1f, 0.9f, 8.0f), 1f) }, |
|||
new[] { new GradientAlphaKey(1f, 0f), |
|||
new GradientAlphaKey(1f, 1f) } |
|||
); |
|||
} |
|||
|
|||
if (atmosphericShaderOverride != null) |
|||
{ |
|||
// Override the default shader.
|
|||
m_atmosphericMaterial = new Material(atmosphericShaderOverride); |
|||
m_atmosphericMaterial.hideFlags = HideFlags.HideAndDontSave; |
|||
} |
|||
|
|||
/* |
|||
if (occlusionShaderOverride != null) |
|||
{ |
|||
// Override the default shader.
|
|||
m_occlusionMaterial = new Material(occlusionShaderOverride); |
|||
m_occlusionMaterial.hideFlags = HideFlags.HideAndDontSave; |
|||
} |
|||
*/ |
|||
|
|||
m_isAwake = true; |
|||
} |
|||
|
|||
public void OnValidate() |
|||
{ |
|||
if (!m_isAwake) return; |
|||
|
|||
Light light = gameObject.GetComponentInParent<Light>(); |
|||
|
|||
if (light == null || light.type != LightType.Directional) |
|||
{ |
|||
Debug.LogErrorFormat("Unexpected: AtmosphericParameters is not attached to a directional light."); |
|||
return; |
|||
} |
|||
|
|||
worldScaleExponent = Mathf.Clamp(worldScaleExponent, 1f, 2f); |
|||
worldNormalDistance = Mathf.Clamp(worldNormalDistance, 1f, 10000f); |
|||
worldNearScatterPush = Mathf.Clamp(worldNearScatterPush, -200f, 300f); |
|||
worldRayleighDensity = Mathf.Clamp(worldRayleighDensity, 0, 1000f); |
|||
worldMieDensity = Mathf.Clamp(worldMieDensity, 0f, 1000f); |
|||
worldRayleighIndirectScatter = Mathf.Clamp(worldRayleighIndirectScatter, 0f, 1f); |
|||
worldMiePhaseAnisotropy = Mathf.Clamp01(worldMiePhaseAnisotropy); |
|||
|
|||
heightNormalDistance = Mathf.Clamp(heightNormalDistance, 1f, 10000f); |
|||
heightNearScatterPush = Mathf.Clamp(heightNearScatterPush, -200f, 300f); |
|||
heightRayleighDensity = Mathf.Clamp(heightRayleighDensity, 0, 1000f); |
|||
heightMieDensity = Mathf.Clamp(heightMieDensity, 0, 1000f); |
|||
|
|||
/* |
|||
occlusionBias = Mathf.Clamp01(occlusionBias); |
|||
occlusionBiasIndirect = Mathf.Clamp01(occlusionBiasIndirect); |
|||
occlusionBiasClouds = Mathf.Clamp01(occlusionBiasClouds); |
|||
occlusionBiasSkyRayleigh = Mathf.Clamp01(occlusionBiasSkyRayleigh); |
|||
occlusionBiasSkyMie = Mathf.Clamp01(occlusionBiasSkyMie); |
|||
*/ |
|||
|
|||
skyDomeExposure = Mathf.Clamp(skyDomeExposure, 0f, 8f); |
|||
|
|||
if (instance == this) |
|||
{ |
|||
// TODO: what's the point of doing this?
|
|||
Cleanup(); |
|||
OnEnable(); |
|||
} |
|||
|
|||
// TODO: why would I want to do that here?
|
|||
// #if UNITY_EDITOR
|
|||
// UnityEditor.SceneView.RepaintAll();
|
|||
// #endif
|
|||
} |
|||
|
|||
void OnEnable() |
|||
{ |
|||
if (!m_isAwake) return; |
|||
|
|||
// Define select preprocessor symbols.
|
|||
UpdateKeywords(true); |
|||
|
|||
if (depthTexture == DepthTexture.Disable) |
|||
{ |
|||
// Disable depth texture rendering.
|
|||
Camera.current.depthTextureMode = DepthTextureMode.None; |
|||
} |
|||
|
|||
// Set shader constants.
|
|||
UpdateStaticUniforms(); |
|||
UpdateDynamicUniforms(); |
|||
|
|||
if (instance && instance != this) |
|||
{ |
|||
Debug.LogErrorFormat("Unexpected: AtmosphericParameters.instance already set (to: {0}). Still overriding with: {1}.", instance.name, name); |
|||
} |
|||
|
|||
instance = this; |
|||
} |
|||
|
|||
void Cleanup() |
|||
{ |
|||
// Undefine all preprocessor symbols.
|
|||
UpdateKeywords(false); |
|||
|
|||
if (instance && instance != this) |
|||
{ |
|||
Debug.LogErrorFormat("Unexpected: AtmosphericParameters.instance set to: {0}, not to: {1}. Leaving alone.", instance.name, name); |
|||
} |
|||
else |
|||
{ |
|||
instance = null; |
|||
} |
|||
} |
|||
|
|||
void UpdateKeywords(bool enable) |
|||
{ |
|||
Shader.DisableKeyword("ATMOSPHERICS_OCCLUSION"); |
|||
Shader.DisableKeyword("ATMOSPHERICS_OCCLUSION_FULLSKY"); |
|||
Shader.DisableKeyword("ATMOSPHERICS_OCCLUSION_EDGE_FIXUP"); |
|||
Shader.DisableKeyword("ATMOSPHERICS_SUNRAYS"); |
|||
Shader.DisableKeyword("ATMOSPHERICS_DEBUG"); |
|||
|
|||
if (enable) |
|||
{ |
|||
/* |
|||
if (useOcclusion) |
|||
{ |
|||
Shader.EnableKeyword("ATMOSPHERICS_OCCLUSION"); |
|||
|
|||
if(occlusionDepthFixup && occlusionDownscale != OcclusionDownscale.x1) |
|||
Shader.EnableKeyword("ATMOSPHERICS_OCCLUSION_EDGE_FIXUP"); |
|||
|
|||
if(occlusionFullSky) |
|||
Shader.EnableKeyword("ATMOSPHERICS_OCCLUSION_FULLSKY"); |
|||
} |
|||
*/ |
|||
|
|||
if (debugMode != ScatterDebugMode.None) |
|||
{ |
|||
Shader.EnableKeyword("ATMOSPHERICS_DEBUG"); |
|||
} |
|||
} |
|||
} |
|||
|
|||
void UpdateStaticUniforms() |
|||
{ |
|||
Shader.SetGlobalVector("_SkyDomeOffset", skyDomeOffset); |
|||
Shader.SetGlobalVector("_SkyDomeScale", skyDomeScale); |
|||
Shader.SetGlobalTexture("_SkyDomeCube", skyDomeCube); |
|||
Shader.SetGlobalFloat("_SkyDomeExposure", skyDomeExposure); |
|||
Shader.SetGlobalColor("_SkyDomeTint", skyDomeTint); |
|||
|
|||
/* |
|||
Shader.SetGlobalFloat("_ShadowBias", useOcclusion ? occlusionBias : 1f); |
|||
Shader.SetGlobalFloat("_ShadowBiasIndirect", useOcclusion ? occlusionBiasIndirect : 1f); |
|||
Shader.SetGlobalFloat("_ShadowBiasClouds", useOcclusion ? occlusionBiasClouds : 1f); |
|||
Shader.SetGlobalVector("_ShadowBiasSkyRayleighMie", useOcclusion ? new Vector4(occlusionBiasSkyRayleigh, occlusionBiasSkyMie, 0f, 0f) : Vector4.zero); |
|||
Shader.SetGlobalFloat("_OcclusionDepthThreshold", occlusionDepthThreshold); |
|||
*/ |
|||
|
|||
Shader.SetGlobalFloat("_WorldScaleExponent", worldScaleExponent); |
|||
|
|||
Shader.SetGlobalFloat("_WorldNormalDistanceRcp", 1f/worldNormalDistance); |
|||
Shader.SetGlobalFloat("_WorldNearScatterPush", -Mathf.Pow(Mathf.Abs(worldNearScatterPush), worldScaleExponent) * Mathf.Sign(worldNearScatterPush)); |
|||
|
|||
Shader.SetGlobalFloat("_WorldRayleighDensity", -worldRayleighDensity / 100000f); |
|||
Shader.SetGlobalFloat("_MiePhaseAnisotropy", worldMiePhaseAnisotropy); |
|||
Shader.SetGlobalVector("_RayleighInScatterPct", new Vector4(1f - worldRayleighIndirectScatter, worldRayleighIndirectScatter, 0f, 0f)); |
|||
|
|||
Shader.SetGlobalFloat("_HeightNormalDistanceRcp", 1f/heightNormalDistance); |
|||
Shader.SetGlobalFloat("_HeightNearScatterPush", -Mathf.Pow(Mathf.Abs(heightNearScatterPush), worldScaleExponent) * Mathf.Sign(heightNearScatterPush)); |
|||
Shader.SetGlobalFloat("_HeightRayleighDensity", -heightRayleighDensity / 100000f); |
|||
|
|||
Shader.SetGlobalFloat("_HeightSeaLevel", heightSeaLevel); |
|||
Shader.SetGlobalFloat("_HeightDistanceRcp", 1f/heightDistance); |
|||
Shader.SetGlobalVector("_HeightPlaneShift", heightPlaneShift); |
|||
Shader.SetGlobalVector("_HeightRayleighColor", (Vector4)heightRayleighColor * heightRayleighIntensity); |
|||
Shader.SetGlobalFloat("_HeightExtinctionFactor", heightExtinctionFactor); |
|||
Shader.SetGlobalFloat("_RayleighExtinctionFactor", worldRayleighExtinctionFactor); |
|||
Shader.SetGlobalFloat("_MieExtinctionFactor", worldMieExtinctionFactor); |
|||
|
|||
var rayleighColorM20 = worldRayleighColorRamp.Evaluate(0.00f); |
|||
var rayleighColorM10 = worldRayleighColorRamp.Evaluate(0.25f); |
|||
var rayleighColorO00 = worldRayleighColorRamp.Evaluate(0.50f); |
|||
var rayleighColorP10 = worldRayleighColorRamp.Evaluate(0.75f); |
|||
var rayleighColorP20 = worldRayleighColorRamp.Evaluate(1.00f); |
|||
|
|||
var mieColorM20 = worldMieColorRamp.Evaluate(0.00f); |
|||
var mieColorO00 = worldMieColorRamp.Evaluate(0.50f); |
|||
var mieColorP20 = worldMieColorRamp.Evaluate(1.00f); |
|||
|
|||
Shader.SetGlobalVector("_RayleighColorM20", (Vector4)rayleighColorM20 * worldRayleighColorIntensity); |
|||
Shader.SetGlobalVector("_RayleighColorM10", (Vector4)rayleighColorM10 * worldRayleighColorIntensity); |
|||
Shader.SetGlobalVector("_RayleighColorO00", (Vector4)rayleighColorO00 * worldRayleighColorIntensity); |
|||
Shader.SetGlobalVector("_RayleighColorP10", (Vector4)rayleighColorP10 * worldRayleighColorIntensity); |
|||
Shader.SetGlobalVector("_RayleighColorP20", (Vector4)rayleighColorP20 * worldRayleighColorIntensity); |
|||
|
|||
Shader.SetGlobalVector("_MieColorM20", (Vector4)mieColorM20 * worldMieColorIntensity); |
|||
Shader.SetGlobalVector("_MieColorO00", (Vector4)mieColorO00 * worldMieColorIntensity); |
|||
Shader.SetGlobalVector("_MieColorP20", (Vector4)mieColorP20 * worldMieColorIntensity); |
|||
|
|||
Shader.SetGlobalInt("_AtmosphericsDebugMode", (int)debugMode); |
|||
} |
|||
|
|||
void OnWillRenderObject() |
|||
{ |
|||
/* |
|||
if (!m_isAwake) return; |
|||
|
|||
// For now, we only use the directional light we are attached to, and the current camera.
|
|||
|
|||
if (depthTexture == DepthTexture.Disable) |
|||
{ |
|||
// Disable depth texture rendering.
|
|||
Camera.current.depthTextureMode = DepthTextureMode.None; |
|||
} |
|||
|
|||
// Set shader constants.
|
|||
UpdateDynamicUniforms(); |
|||
|
|||
|
|||
if (useOcclusion) { |
|||
var camRgt = m_currentCamera.transform.right; |
|||
var camUp = m_currentCamera.transform.up; |
|||
var camFwd = m_currentCamera.transform.forward; |
|||
|
|||
var dy = Mathf.Tan(m_currentCamera.fieldOfView * 0.5f * Mathf.Deg2Rad); |
|||
var dx = dy * m_currentCamera.aspect; |
|||
|
|||
var vpCenter = camFwd * m_currentCamera.farClipPlane; |
|||
var vpRight = camRgt * dx * m_currentCamera.farClipPlane; |
|||
var vpUp = camUp * dy * m_currentCamera.farClipPlane; |
|||
|
|||
m_occlusionMaterial.SetVector("_CameraPosition", m_currentCamera.transform.position); |
|||
m_occlusionMaterial.SetVector("_ViewportCorner", vpCenter - vpRight - vpUp); |
|||
m_occlusionMaterial.SetVector("_ViewportRight", vpRight * 2f); |
|||
m_occlusionMaterial.SetVector("_ViewportUp", vpUp * 2f); |
|||
var farDist = m_currentCamera ? m_currentCamera.farClipPlane : 1000f; |
|||
var refDist = (Mathf.Min(farDist, QualitySettings.shadowDistance) - 1f) / farDist; |
|||
m_occlusionMaterial.SetFloat("_OcclusionSkyRefDistance", refDist); |
|||
|
|||
var srcRect = m_currentCamera.pixelRect; |
|||
var downscale = 1f / (float)(int)occlusionDownscale; |
|||
var occWidth = Mathf.RoundToInt(srcRect.width * downscale); |
|||
var occHeight = Mathf.RoundToInt(srcRect.height * downscale); |
|||
var occlusionId = Shader.PropertyToID("_OcclusionTexture"); |
|||
|
|||
m_occlusionCmdBeforeScreen.Clear(); |
|||
m_occlusionCmdBeforeScreen.GetTemporaryRT(occlusionId, occWidth, occHeight, 0, FilterMode.Bilinear, RenderTextureFormat.R8, RenderTextureReadWrite.sRGB); |
|||
m_occlusionCmdBeforeScreen.Blit( |
|||
null, |
|||
occlusionId, |
|||
m_occlusionMaterial, |
|||
(int)occlusionSamples |
|||
); |
|||
m_occlusionCmdBeforeScreen.SetGlobalTexture(occlusionId, occlusionId); |
|||
} |
|||
*/ |
|||
} |
|||
|
|||
void UpdateDynamicUniforms() |
|||
{ |
|||
/* For now, we only use the directional light we are attached to, and the current camera. */ |
|||
|
|||
var trackedYaw = skyDomeTrackedYawRotation ? skyDomeTrackedYawRotation.eulerAngles.y : 0f; |
|||
Shader.SetGlobalMatrix("_SkyDomeRotation", |
|||
Matrix4x4.TRS(Vector3.zero, Quaternion.Euler(skyDomeRotation.x, 0f, 0f), Vector3.one) |
|||
* Matrix4x4.TRS(Vector3.zero, Quaternion.Euler(0f, skyDomeRotation.y - trackedYaw, 0f), Vector3.one) |
|||
* Matrix4x4.TRS(Vector3.zero, Quaternion.identity, new Vector3(1f, skyDomeVerticalFlip ? -1f : 1f, 1f)) |
|||
); |
|||
|
|||
Shader.SetGlobalVector("_SunDirection", -transform.forward); |
|||
Shader.SetGlobalFloat("_WorldMieDensity", -worldMieDensity / 100000f); |
|||
Shader.SetGlobalFloat("_HeightMieDensity", -heightMieDensity / 100000f); |
|||
|
|||
var pixelRect = Camera.current ? Camera.current.pixelRect |
|||
: new Rect(0f, 0f, Screen.width, Screen.height); |
|||
var scale = 1.0f; //(float)(int)occlusionDownscale;
|
|||
var depthTextureScaledTexelSize = new Vector4(scale / pixelRect.width, |
|||
scale / pixelRect.height, |
|||
-scale / pixelRect.width, |
|||
-scale / pixelRect.height); |
|||
Shader.SetGlobalVector("_DepthTextureScaledTexelSize", depthTextureScaledTexelSize); |
|||
} |
|||
|
|||
void OnRenderObject() |
|||
{ |
|||
/* This component is not rendered directly. */ |
|||
} |
|||
} |
撰写
预览
正在加载...
取消
保存
Reference in new issue