浏览代码

Merge pull request #551 from Unity-Technologies/Unity-2017.3

Unity 2017.3
/main
GitHub 7 年前
当前提交
ae2a6ad0
共有 10 个文件被更改,包括 66 次插入32 次删除
  1. 9
      SampleScenes/HDTest/GraphicTest/SSS/Materials/SSSHead.mat
  2. 13
      SampleScenes/HDTest/GraphicTest/Two Sided/Material/GroundLeaf_DoubleSided.mat
  3. 11
      SampleScenes/HDTest/GraphicTest/Two Sided/Material/GroundLeaf_DoubleSidedFlipSSS.mat
  4. 11
      SampleScenes/HDTest/GraphicTest/Unlit/Material/TestUnlit Mask.mat
  5. 9
      SampleScenes/HDTest/GraphicTest/Unlit/Material/TestUnlit Transparent.mat
  6. 7
      SampleScenes/HDTest/GraphicTest/Unlit/Material/TestUnlit.mat
  7. 2
      ScriptableRenderPipeline/Core/ShaderLibrary/CommonLighting.hlsl
  8. 14
      ScriptableRenderPipeline/Core/ShaderLibrary/Refraction.hlsl
  9. 7
      ScriptableRenderPipeline/Core/ShaderLibrary/VolumeRendering.hlsl
  10. 15
      ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.hlsl

9
SampleScenes/HDTest/GraphicTest/SSS/Materials/SSSHead.mat


m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Texture: {fileID: 2800000, guid: 6e9f830fee2ef0c44af529384a948910, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MaskMap:

m_Offset: {x: 0, y: 0}
- _ThicknessMap:
m_Texture: {fileID: 2800000, guid: 13ef23776cd487941973bab55623a077, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _TransmittanceColorMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:

- _SrcBlend: 1
- _StencilRef: 1
- _Stiffness: 1
- _SubsurfaceProfile: 0
- _SubsurfaceProfile: 1
- _SubsurfaceRadius: 1
- _SurfaceType: 0
- _TexWorldScale: 1

- _EmissiveColor: {r: 0, g: 0, b: 0, a: 1}
- _InvPrimScale: {r: 1, g: 1, b: 0, a: 0}
- _SpecularColor: {r: 1, g: 1, b: 1, a: 1}
- _ThicknessRemap: {r: 0, g: 1, b: 0, a: 0}
- _TransmittanceColor: {r: 1, g: 1, b: 1, a: 1}
- _UVDetailsMappingMask: {r: 1, g: 0, b: 0, a: 0}
- _UVMappingMask: {r: 1, g: 0, b: 0, a: 0}

13
SampleScenes/HDTest/GraphicTest/Two Sided/Material/GroundLeaf_DoubleSided.mat


m_ShaderKeywords: _ALPHATEST_ON _DOUBLESIDED_ON
m_LightmapFlags: 1
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_DoubleSidedGI: 1
m_CustomRenderQueue: 2450
stringTagMap:
RenderType: TransparentCutout

m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 2800000, guid: 00447c5eeb984f54d92c80818840a36b, type: 3}
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MaskMap:

m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _UnlitColorMap:
m_Texture: {fileID: 2800000, guid: 00447c5eeb984f54d92c80818840a36b, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _AlphaCutoff: 0.5
- _AlphaCutoffEnable: 1

- _ZWrite: 1
m_Colors:
- _BaseColor: {r: 1, g: 1, b: 1, a: 1}
- _Color: {r: 0.5882353, g: 0.5882353, b: 0.5882353, a: 1}
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _EmissiveColor: {r: 0, g: 0, b: 0, a: 1}
- _EmissiveColor: {r: 1, g: 1, b: 1, a: 1}
- _UnlitColor: {r: 1, g: 1, b: 1, a: 1}

11
SampleScenes/HDTest/GraphicTest/Two Sided/Material/GroundLeaf_DoubleSidedFlipSSS.mat


_MASKMAP _MATID_SSS _NORMALMAP _NORMALMAP_TANGENT_SPACE
m_LightmapFlags: 1
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_DoubleSidedGI: 1
m_CustomRenderQueue: 2450
stringTagMap:
RenderType: TransparentCutout

m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ThicknessMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _TransmittanceColorMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}

- _SrcBlend: 1
- _StencilRef: 1
- _Stiffness: 1
- _SubsurfaceProfile: 1
- _SubsurfaceProfile: 2
- _SubsurfaceRadius: 1
- _SurfaceType: 0
- _TessellationBackFaceCullEpsilon: -0.375

- _ZWrite: 1
m_Colors:
- _BaseColor: {r: 1, g: 1, b: 1, a: 1}
- _Color: {r: 0.5882353, g: 0.5882353, b: 0.5882353, a: 1}
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _ThicknessRemap: {r: 0, g: 1, b: 0, a: 0}
- _TransmittanceColor: {r: 1, g: 1, b: 1, a: 1}
- _UVDetailsMappingMask: {r: 1, g: 0, b: 0, a: 0}
- _UVMappingMask: {r: 1, g: 0, b: 0, a: 0}

11
SampleScenes/HDTest/GraphicTest/Unlit/Material/TestUnlit Mask.mat


m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _UnlitColorMap:
m_Texture: {fileID: 2800000, guid: 46531a9b9b2461347a4d5a0f75c33766, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _AlphaCutoff: 0.4
- _AlphaCutoffEnable: 1

- _Cutoff: 0.5
- _Cutoff: 0.4
- _DetailNormalMapScale: 1
- _DistortionBlendMode: 0
- _DistortionBlurBlendMode: 0

- _ZTestMode: 8
- _ZWrite: 1
m_Colors:
- _Color: {r: 1, g: 1, b: 1, a: 0.559}
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _EmissiveColor: {r: 0, g: 0, b: 0, a: 1}
- _EmissiveColor: {r: 1, g: 1, b: 1, a: 1}
- _UnlitColor: {r: 1, g: 1, b: 1, a: 1}

9
SampleScenes/HDTest/GraphicTest/Unlit/Material/TestUnlit Transparent.mat


m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _UnlitColorMap:
m_Texture: {fileID: 2800000, guid: eb22c3aedea15d246959bf77d8f9e766, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _AlphaCutoff: 0.5
- _AlphaCutoffEnable: 0

- _ZTestMode: 8
- _ZWrite: 0
m_Colors:
- _Color: {r: 1, g: 1, b: 1, a: 0.341}
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _EmissiveColor: {r: 0, g: 0, b: 0, a: 1}
- _EmissiveColor: {r: 1, g: 1, b: 1, a: 1}
- _UnlitColor: {r: 1, g: 1, b: 1, a: 0.359}

7
SampleScenes/HDTest/GraphicTest/Unlit/Material/TestUnlit.mat


m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _UnlitColorMap:
m_Texture: {fileID: 2800000, guid: eb22c3aedea15d246959bf77d8f9e766, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _AlphaCutoff: 0.5
- _AlphaCutoffEnable: 0

m_Colors:
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _EmissiveColor: {r: 0, g: 0, b: 0, a: 1}
- _EmissiveColor: {r: 1, g: 1, b: 1, a: 1}
- _UnlitColor: {r: 1, g: 1, b: 1, a: 1}

2
ScriptableRenderPipeline/Core/ShaderLibrary/CommonLighting.hlsl


}
// ior is a value between 1.0 and 2.5
float ConvertIORToFresnel0(float ior)
float IORToFresnel0(float ior)
{
return Sqr((ior - 1.0) / (ior + 1.0));
}

14
ScriptableRenderPipeline/Core/ShaderLibrary/Refraction.hlsl


struct RefractionModelResult
{
float opticalDepth;
float distance; // length of the transmission during refraction through the shape
float3 positionWS; // out ray position
float3 rayWS; // out ray direction
};

// Second refraction (tangent sphere out)
float NoR1 = dot(normalWS, R1);
// Optical depth within the sphere
float opticalDepth = -NoR1 * thickness;
float distance = -NoR1 * thickness;
float3 P1 = positionWS + R1 * opticalDepth;
float3 P1 = positionWS + R1 * distance;
// Out normal
float3 N1 = normalize(C - P1);
// Out refracted ray

RefractionModelResult result;
result.opticalDepth = opticalDepth;
result.distance = distance;
result.positionWS = P1;
result.rayWS = R2;

float3 R = refract(-V, normalWS, 1.0 / ior);
// Optical depth within the thin plane
float opticalDepth = thickness / dot(R, -normalWS);
float distance = thickness / dot(R, -normalWS);
result.opticalDepth = opticalDepth;
result.positionWS = positionWS + R * opticalDepth;
result.distance = distance;
result.positionWS = positionWS + R * distance;
result.rayWS = -V;
return result;

7
ScriptableRenderPipeline/Core/ShaderLibrary/VolumeRendering.hlsl


HenyeyGreensteinPhasePartVarying(asymmetry, LdotD);
}
// Absorption coefficient from Disney: http://blog.selfshadow.com/publications/s2015-shading-course/burley/s2015_pbs_disney_bsdf_notes.pdf
float TransmittanceColorAtDistanceToAbsorption(float3 transmittanceColor, float atDistance)
{
return -log(transmittanceColor + 0.00001) / max(atDistance, 0.000001);
}
#endif // UNITY_VOLUME_RENDERING_INCLUDED

15
ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.hlsl


bsdfData.ior = ior;
// IOR define the fresnel0 value, so update it also for consistency (and even if not physical we still need to take into account any metal mask)
bsdfData.fresnel0 = lerp(ConvertIORToFresnel0(ior).xxx, baseColor, metallic);
bsdfData.fresnel0 = lerp(IORToFresnel0(ior).xxx, baseColor, metallic);
// Absorption coefficient from Disney: http://blog.selfshadow.com/publications/s2015-shading-course/burley/s2015_pbs_disney_bsdf_notes.pdf
bsdfData.absorptionCoefficient = -log(transmittanceColor + 0.00001) / max(atDistance, 0.000001);
bsdfData.absorptionCoefficient = TransmittanceColorAtDistanceToAbsorption (transmittanceColor, atDistance);
bsdfData.transmittanceMask = transmittanceMask;
bsdfData.thickness = max(thickness, 0.0001);
}

// Refraction
float3 transmissionRefractV; // refracted view vector after exiting the shape
float3 transmissionPositionWS; // start of the refracted ray after exiting the shape
float transmissionOpticalDepth; // length of the transmission during refraction through the shape
float3 transmissionTransmittance; // transmittance due to absorption
float transmissionSSMipLevel; // mip level of the screen space gaussian pyramid for rough refraction

};
// This is a refract - TODO: do we call original refract or this one, original maybe slightly emore expensive, to check
// This is a refract - TODO: do we call original refract or this one, original maybe slightly more expensive, to check
float3 ClearCoatTransform(float3 X, float3 N, float ieta)
{
float XdotN = saturate(dot(N, X));

RefractionModelResult refraction = REFRACTION_MODEL(V, posInput, bsdfData);
preLightData.transmissionRefractV = refraction.rayWS;
preLightData.transmissionPositionWS = refraction.positionWS;
preLightData.transmissionOpticalDepth = refraction.opticalDepth;
preLightData.transmissionTransmittance = exp(-bsdfData.absorptionCoefficient * refraction.opticalDepth);
preLightData.transmissionSSMipLevel = PerceptualRoughnessToMipmapLevel(bsdfData.perceptualRoughness, uint(_GaussianPyramidColorMipSize.z));
preLightData.transmissionTransmittance = exp(-bsdfData.absorptionCoefficient * refraction.distance);
// Empirical remap to try to match a bit the refractio probe blurring for the fallback
preLightData.transmissionSSMipLevel = sqrt(bsdfData.perceptualRoughness) * uint(_GaussianPyramidColorMipSize.z);
preLightData.transmissionOpticalDepth = 0;
preLightData.transmissionTransmittance = float3(1.0, 1.0, 1.0);
preLightData.transmissionSSMipLevel = 0;
#endif

正在加载...
取消
保存