149 lines
5.5 KiB
C#
149 lines
5.5 KiB
C#
using UnityEngine.Rendering.HighDefinition.Attributes;
|
|
|
|
namespace UnityEngine.Rendering.HighDefinition
|
|
{
|
|
partial class Hair : RenderPipelineMaterial
|
|
{
|
|
[GenerateHLSL(PackingRules.Exact)]
|
|
public enum MaterialFeatureFlags
|
|
{
|
|
HairKajiyaKay = 1 << 0,
|
|
};
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// SurfaceData
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Main structure that store the user data (i.e user input of master node in material graph)
|
|
[GenerateHLSL(PackingRules.Exact, false, false, true, 1400)]
|
|
public struct SurfaceData
|
|
{
|
|
[SurfaceDataAttributes("Material Features")]
|
|
public uint materialFeatures;
|
|
|
|
[MaterialSharedPropertyMapping(MaterialSharedProperty.AmbientOcclusion)]
|
|
[SurfaceDataAttributes("Ambient Occlusion")]
|
|
public float ambientOcclusion;
|
|
|
|
// Standard
|
|
[MaterialSharedPropertyMapping(MaterialSharedProperty.Albedo)]
|
|
[SurfaceDataAttributes("Diffuse", false, true)]
|
|
public Vector3 diffuseColor;
|
|
[SurfaceDataAttributes("Specular Occlusion")]
|
|
public float specularOcclusion;
|
|
|
|
[MaterialSharedPropertyMapping(MaterialSharedProperty.Normal)]
|
|
[SurfaceDataAttributes(new string[] {"Normal", "Normal View Space"}, true, checkIsNormalized = true)]
|
|
public Vector3 normalWS;
|
|
|
|
[SurfaceDataAttributes(new string[] { "Geometric Normal", "Geometric Normal View Space" }, true, checkIsNormalized = true)]
|
|
public Vector3 geomNormalWS;
|
|
|
|
[MaterialSharedPropertyMapping(MaterialSharedProperty.Smoothness)]
|
|
[SurfaceDataAttributes("Smoothness")]
|
|
public float perceptualSmoothness;
|
|
|
|
[SurfaceDataAttributes("Transmittance")]
|
|
public Vector3 transmittance;
|
|
|
|
[SurfaceDataAttributes("Rim Transmission Intensity")]
|
|
public float rimTransmissionIntensity;
|
|
|
|
// Anisotropic
|
|
[SurfaceDataAttributes("Hair Strand Direction", true)]
|
|
public Vector3 hairStrandDirectionWS;
|
|
|
|
// Kajiya kay
|
|
[SurfaceDataAttributes("Secondary Smoothness")]
|
|
public float secondaryPerceptualSmoothness;
|
|
|
|
// Specular Color
|
|
[MaterialSharedPropertyMapping(MaterialSharedProperty.Specular)]
|
|
[SurfaceDataAttributes("Specular Tint", false, true)]
|
|
public Vector3 specularTint;
|
|
|
|
[SurfaceDataAttributes("Secondary Specular Tint", false, true)]
|
|
public Vector3 secondarySpecularTint;
|
|
|
|
[SurfaceDataAttributes("Specular Shift")]
|
|
public float specularShift;
|
|
|
|
[SurfaceDataAttributes("Secondary Specular Shift")]
|
|
public float secondarySpecularShift;
|
|
};
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// BSDFData
|
|
//-----------------------------------------------------------------------------
|
|
|
|
[GenerateHLSL(PackingRules.Exact, false, false, true, 1450)]
|
|
public struct BSDFData
|
|
{
|
|
public uint materialFeatures;
|
|
|
|
public float ambientOcclusion;
|
|
public float specularOcclusion;
|
|
|
|
[SurfaceDataAttributes("", false, true)]
|
|
public Vector3 diffuseColor;
|
|
public Vector3 fresnel0;
|
|
|
|
public Vector3 specularTint;
|
|
|
|
[SurfaceDataAttributes(new string[] { "Normal WS", "Normal View Space" }, true, checkIsNormalized = true)]
|
|
public Vector3 normalWS;
|
|
|
|
[SurfaceDataAttributes(new string[] { "Geometric Normal", "Geometric Normal View Space" }, true, checkIsNormalized = true)]
|
|
public Vector3 geomNormalWS;
|
|
|
|
public float perceptualRoughness;
|
|
|
|
public Vector3 transmittance;
|
|
public float rimTransmissionIntensity;
|
|
|
|
// Anisotropic
|
|
[SurfaceDataAttributes("", true)]
|
|
public Vector3 hairStrandDirectionWS;
|
|
public float anisotropy;
|
|
|
|
// Kajiya kay
|
|
public float secondaryPerceptualRoughness;
|
|
public Vector3 secondarySpecularTint;
|
|
public float specularExponent;
|
|
public float secondarySpecularExponent;
|
|
public float specularShift;
|
|
public float secondarySpecularShift;
|
|
};
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Init precomputed texture
|
|
//-----------------------------------------------------------------------------
|
|
|
|
public Hair() {}
|
|
|
|
public override void Build(HDRenderPipelineAsset hdAsset, RenderPipelineResources defaultResources)
|
|
{
|
|
PreIntegratedFGD.instance.Build(PreIntegratedFGD.FGDIndex.FGD_GGXAndDisneyDiffuse);
|
|
LTCAreaLight.instance.Build();
|
|
}
|
|
|
|
public override void Cleanup()
|
|
{
|
|
PreIntegratedFGD.instance.Cleanup(PreIntegratedFGD.FGDIndex.FGD_GGXAndDisneyDiffuse);
|
|
LTCAreaLight.instance.Cleanup();
|
|
}
|
|
|
|
public override void RenderInit(CommandBuffer cmd)
|
|
{
|
|
PreIntegratedFGD.instance.RenderInit(PreIntegratedFGD.FGDIndex.FGD_GGXAndDisneyDiffuse, cmd);
|
|
}
|
|
|
|
public override void Bind(CommandBuffer cmd)
|
|
{
|
|
PreIntegratedFGD.instance.Bind(cmd, PreIntegratedFGD.FGDIndex.FGD_GGXAndDisneyDiffuse);
|
|
LTCAreaLight.instance.Bind(cmd);
|
|
}
|
|
}
|
|
}
|