浏览代码

Merge branch 'master' into Branch_Batching2

/Branch_Batching2
Arnaud Carre 7 年前
当前提交
0bcbf4af
共有 7 个文件被更改,包括 89 次插入11 次删除
  1. 2
      Assets/ScriptableRenderPipeline/Core/Shadow/Shadow.cs
  2. 5
      Assets/ScriptableRenderPipeline/Core/Shadow/VectorArray.cs
  3. 5
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.hlsl
  4. 8
      Assets/ScriptableRenderPipeline/ShaderLibrary/Common.hlsl
  5. 4
      Assets/ScriptableRenderPipeline/ShaderLibrary/Shadow/ShadowAlgorithms.hlsl
  6. 66
      Assets/ScriptableRenderPipeline/ShaderLibrary/Noise.hlsl
  7. 10
      Assets/ScriptableRenderPipeline/ShaderLibrary/Noise.hlsl.meta

2
Assets/ScriptableRenderPipeline/Core/Shadow/Shadow.cs


public bool IsValid() { return viewport.width > 0 && viewport.height > 0; }
}
protected struct CachedEntry : IComparable<CachedEntry>
protected class CachedEntry : IComparable<CachedEntry>
{
public Key key;
public Data current;

5
Assets/ScriptableRenderPipeline/Core/Shadow/VectorArray.cs


{
for (idx = 0; idx < m_count; ++idx)
{
T obj = this[idx];
if (compareDelegate(ref designator, ref obj))
if (compareDelegate(ref designator, ref m_array[m_offset + idx]))
return true;
}
idx = k_InvalidIdx;

{
for (idx = 0; idx < m_count; ++idx)
{
if (this[idx].Equals(designator))
if (m_array[m_offset + idx].Equals(designator))
return true;
}
idx = k_InvalidIdx;

5
Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.hlsl


outGBuffer1.a = PackMaterialId(MATERIALID_LIT_STANDARD); // We save 1bit in gbuffer1 and use aniso value instead to detect we are aniso
// Encode tangent on 16bit with oct compression
float2 octTangentWS = PackNormalOctEncode(surfaceData.tangentWS);
outGBuffer2 = float4(octTangentWS * 0.5 + 0.5, surfaceData.anisotropy, PackFloatInt8bit(surfaceData.metallic, surfaceData.specular, 4.0));
// To be recognize as anisotropic material, we need to have anisotropy > 0 (Else artits can be confuse to not have anisotropic material in material classification), thus the max
outGBuffer2 = float4(octTangentWS * 0.5 + 0.5, max(surfaceData.anisotropy, 1.5 / 255.0), PackFloatInt8bit(surfaceData.metallic, surfaceData.specular, 4.0));
}
else if (surfaceData.materialId == MATERIALID_LIT_SSS)
{

bsdfData.diffuseColor = baseColor;
bsdfData.fresnel0 = inGBuffer2.rgb;
}
else if (anisotropy > 0)
else if (anisotropy > 0.0)
{
bsdfData.materialId = MATERIALID_LIT_ANISO;
FillMaterialIdStandardData(baseColor, specular, metallic, bsdfData);

8
Assets/ScriptableRenderPipeline/ShaderLibrary/Common.hlsl


#endif
#include "API/Validate.hlsl"
#include "Noise.hlsl"
// Some shader compiler don't support to do multiple ## for concatenation inside the same macro, it require an indirection.
// This is the purpose of this macro
#define MERGE_NAME(X, Y) X##Y

// LOD1 must use this function with ditherFactor 0..1
void LODDitheringTransition(uint2 unPositionSS, float ditherFactor)
{
// Generate a fixed pattern
float p = cos(dot(unPositionSS, float2(443.8975, 397.2973)));
p = frac(p * 491.1871);
// Generate a spatially varying pattern.
// Unfortunately, varying the pattern with time confuses the TAA, increasing the amount of noise.
float p = GenerateHashedRandomFloat(unPositionSS);
// We want to have a symmetry between 0..0.5 ditherFactor and 0.5..1 so no pixels are transparent during the transition
// this is handled by this test which reverse the pattern

4
Assets/ScriptableRenderPipeline/ShaderLibrary/Shadow/ShadowAlgorithms.hlsl


ShadowData sd = shadowContext.shadowDatas[index + 1 + shadowSplitIndex];
// normal based bias
float3 orig_pos = positionWS;
float orig_payloadOffset = payloadOffset;
uint orig_payloadOffset = payloadOffset;
positionWS += EvalShadow_NormalBias( normalWS, saturate( dot( normalWS, L ) ), scales[shadowSplitIndex] * sd.texelSizeRcp.zw, sd.normalBias );
// get shadowmap texcoords
float3 posNDC;

ShadowData sd = shadowContext.shadowDatas[index + 1 + shadowSplitIndex]; \
/* normal based bias */ \
float3 orig_pos = positionWS; \
float orig_payloadOffset = payloadOffset; \
uint orig_payloadOffset = payloadOffset; \
positionWS += EvalShadow_NormalBias( normalWS, saturate( dot( normalWS, L ) ), scales[shadowSplitIndex] * sd.texelSizeRcp.zw, sd.normalBias ); \
/* get shadowmap texcoords */ \
float3 posNDC; \

66
Assets/ScriptableRenderPipeline/ShaderLibrary/Noise.hlsl


#ifndef UNITY_NOISE_INCLUDED
#define UNITY_NOISE_INCLUDED
// A single iteration of Bob Jenkins' One-At-A-Time hashing algorithm.
uint JenkinsHash(uint x)
{
x += (x << 10u);
x ^= (x >> 6u);
x += (x << 3u);
x ^= (x >> 11u);
x += (x << 15u);
return x;
}
// Compound versions of the hashing algorithm.
uint JenkinsHash(uint2 v)
{
return JenkinsHash(v.x ^ JenkinsHash(v.y));
}
uint JenkinsHash(uint3 v)
{
return JenkinsHash(v.x ^ JenkinsHash(v.y) ^ JenkinsHash(v.z));
}
uint JenkinsHash(uint4 v)
{
return JenkinsHash(v.x ^ JenkinsHash(v.y) ^ JenkinsHash(v.z) ^ JenkinsHash(v.w));
}
// Construct a float with half-open range [0:1] using low 23 bits.
// All zeros yields 0, all ones yields the next smallest representable value below 1.
float ConstructFloat(uint m) {
const uint ieeeMantissa = 0x007FFFFFu; // Binary FP32 mantissa bitmask
const uint ieeeOne = 0x3F800000u; // 1.0 in FP32 IEEE
m &= ieeeMantissa; // Keep only mantissa bits (fractional part)
m |= ieeeOne; // Add fractional part to 1.0
float f = asfloat(m); // Range [1:2]
return f - 1; // Range [0:1]
}
// Pseudo-random value in half-open range [0:1]. The distribution is reasonably uniform.
// Ref: https://stackoverflow.com/a/17479300
float GenerateHashedRandomFloat(uint x)
{
return ConstructFloat(JenkinsHash(x));
}
float GenerateHashedRandomFloat(uint2 v)
{
return ConstructFloat(JenkinsHash(v));
}
float GenerateHashedRandomFloat(uint3 v)
{
return ConstructFloat(JenkinsHash(v));
}
float GenerateHashedRandomFloat(uint4 v)
{
return ConstructFloat(JenkinsHash(v));
}
#endif // UNITY_NOISE_INCLUDED

10
Assets/ScriptableRenderPipeline/ShaderLibrary/Noise.hlsl.meta


fileFormatVersion: 2
guid: 5918bc8b07f593546974c1961387db77
timeCreated: 1501167559
licenseType: Pro
ShaderImporter:
externalObjects: {}
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存