Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,19 @@ sealed partial class DecalSubTarget : HDSubTarget, ILegacyTarget, IRequiresData<
{
public DecalSubTarget() => displayName = "Decal";

public static string passTemplatePath => $"{HDUtils.GetHDRenderPipelinePath()}Editor/Material/Decal/ShaderGraph/DecalPass.template";

static string[] passTemplateMaterialDirectories = new string[]
protected override string templatePath => $"{HDUtils.GetHDRenderPipelinePath()}Editor/Material/Decal/ShaderGraph/DecalPass.template";
protected override string[] templateMaterialDirectories => new string[]
{
$"{HDUtils.GetHDRenderPipelinePath()}Editor/Material/ShaderGraph/Templates",
$"{HDUtils.GetHDRenderPipelinePath()}Editor/Material/ShaderGraph/Templates/"
};

protected override string templatePath => passTemplatePath;
protected override string[] templateMaterialDirectories => passTemplateMaterialDirectories;
protected override string subTargetAssetGuid => "3ec927dfcb5d60e4883b2c224857b6c2";
protected override string customInspector => "Rendering.HighDefinition.DecalGUI";
protected override string renderType => HDRenderTypeTags.Opaque.ToString();
protected override string renderQueue => HDRenderQueue.GetShaderTagValue(HDRenderQueue.ChangeType(HDRenderQueue.RenderQueueType.Opaque, decalData.drawOrder, false, false));
protected override ShaderID shaderID => HDShaderUtils.ShaderID.SG_Lit;
protected override FieldDescriptor subShaderField => new FieldDescriptor(kSubShader, "Decal Subshader", "");
protected override string subShaderInclude => "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Decal/Decal.hlsl";

// Material Data
DecalData m_DecalData;
Expand All @@ -53,7 +51,12 @@ public DecalData decalData

protected override IEnumerable<SubShaderDescriptor> EnumerateSubShaders()
{
yield return SubShaders.Decal;
yield return PostProcessSubShader(SubShaders.Decal);
}

protected override void CollectPassKeywords(ref PassDescriptor pass)
{
pass.keywords.Add(CoreKeywordDescriptors.AlphaTest, new FieldCondition(Fields.AlphaTest, true));
}

public static FieldDescriptor AffectsAlbedo = new FieldDescriptor(kMaterial, "AffectsAlbedo", "_MATERIAL_AFFECTS_ALBEDO 1");
Expand Down Expand Up @@ -127,7 +130,6 @@ static class SubShaders
{
public static SubShaderDescriptor Decal = new SubShaderDescriptor()
{
pipelineTag = HDRenderPipeline.k_ShaderTagName,
generatesPreview = true,
passes = new PassCollection
{
Expand Down Expand Up @@ -156,10 +158,6 @@ public static class DecalPasses
lightMode = DecalSystem.s_MaterialSGDecalPassNames[(int)DecalSystem.MaterialSGDecalPass.ShaderGraph_DBufferProjector3RT],
useInPreview = false,

// Template
passTemplatePath = passTemplatePath,
sharedTemplateDirectories = passTemplateMaterialDirectories,

// Port mask
validPixelBlocks = DecalBlockMasks.FragmentDefault,

Expand All @@ -180,10 +178,6 @@ public static class DecalPasses
lightMode = DecalSystem.s_MaterialSGDecalPassNames[(int)DecalSystem.MaterialSGDecalPass.ShaderGraph_DBufferProjector4RT],
useInPreview = false,

// Template
passTemplatePath = passTemplatePath,
sharedTemplateDirectories = passTemplateMaterialDirectories,

// Port mask
validPixelBlocks = DecalBlockMasks.FragmentDefault,

Expand All @@ -206,10 +200,6 @@ public static class DecalPasses
lightMode = DecalSystem.s_MaterialSGDecalPassNames[(int)DecalSystem.MaterialSGDecalPass.ShaderGraph_ProjectorEmissive],
useInPreview = false,

// Template
passTemplatePath = passTemplatePath,
sharedTemplateDirectories = passTemplateMaterialDirectories,

// Port mask
validPixelBlocks = DecalBlockMasks.FragmentEmissive,

Expand All @@ -231,10 +221,6 @@ public static class DecalPasses
lightMode = DecalSystem.s_MaterialSGDecalPassNames[(int)DecalSystem.MaterialSGDecalPass.ShaderGraph_DBufferMesh3RT],
useInPreview = false,

// Template
passTemplatePath = passTemplatePath,
sharedTemplateDirectories = passTemplateMaterialDirectories,

// Port mask
validPixelBlocks = DecalBlockMasks.FragmentDefault,

Expand All @@ -258,10 +244,6 @@ public static class DecalPasses
lightMode = DecalSystem.s_MaterialSGDecalPassNames[(int)DecalSystem.MaterialSGDecalPass.ShaderGraph_DBufferMesh4RT],
useInPreview = false,

// Template
passTemplatePath = passTemplatePath,
sharedTemplateDirectories = passTemplateMaterialDirectories,

// Port mask
validPixelBlocks = DecalBlockMasks.FragmentDefault,

Expand All @@ -285,10 +267,6 @@ public static class DecalPasses
lightMode = DecalSystem.s_MaterialSGDecalPassNames[(int)DecalSystem.MaterialSGDecalPass.ShaderGraph_MeshEmissive],
useInPreview = false,

// Template
passTemplatePath = passTemplatePath,
sharedTemplateDirectories = passTemplateMaterialDirectories,

// Port mask
validPixelBlocks = DecalBlockMasks.FragmentMeshEmissive,

Expand All @@ -311,10 +289,6 @@ public static class DecalPasses
lightMode = "ForwardOnly",
useInPreview = true,

// Template
passTemplatePath = passTemplatePath,
sharedTemplateDirectories = passTemplateMaterialDirectories,

// Port mask
validPixelBlocks = DecalBlockMasks.FragmentMeshEmissive,

Expand Down Expand Up @@ -592,7 +566,6 @@ static class Descriptors
};
}
#endregion
// protected override IncludeCollection subShaderIncludes => "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Decal/Decal.hlsl";

#region Includes
static class DecalIncludes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ public override void GetFields(ref TargetFieldContext context)
context.AddField(Eye, eyeData.materialType == EyeData.MaterialType.Eye);
context.AddField(EyeCinematic, eyeData.materialType == EyeData.MaterialType.EyeCinematic);
context.AddField(SubsurfaceScattering, eyeData.subsurfaceScattering && systemData.surfaceType != SurfaceType.Transparent);

context.AddField(SpecularAA, lightingData.specularAA &&
context.pass.validPixelBlocks.Contains(HDBlockFields.SurfaceDescription.SpecularAAThreshold) &&
context.pass.validPixelBlocks.Contains(HDBlockFields.SurfaceDescription.SpecularAAScreenSpaceVariance));
}

public override void GetActiveBlocks(ref TargetActiveBlockContext context)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ public override void GetFields(ref TargetFieldContext context)
context.AddField(SubsurfaceScattering, fabricData.subsurfaceScattering && systemData.surfaceType != SurfaceType.Transparent);
context.AddField(Transmission, fabricData.transmission);
context.AddField(EnergyConservingSpecular, fabricData.energyConservingSpecular);

context.AddField(SpecularAA, lightingData.specularAA &&
context.pass.validPixelBlocks.Contains(HDBlockFields.SurfaceDescription.SpecularAAThreshold) &&
context.pass.validPixelBlocks.Contains(HDBlockFields.SurfaceDescription.SpecularAAScreenSpaceVariance));
}

public override void GetActiveBlocks(ref TargetActiveBlockContext context)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ public override void GetFields(ref TargetFieldContext context)
context.AddField(ClearCoat, litData.clearCoat); // Enable clear coat material feature
context.AddField(Tangent, descs.Contains(HDBlockFields.SurfaceDescription.Tangent) && context.pass.validPixelBlocks.Contains(HDBlockFields.SurfaceDescription.Tangent));
context.AddField(RayTracing, litData.rayTracing);

context.AddField(SpecularAA, lightingData.specularAA &&
context.pass.validPixelBlocks.Contains(HDBlockFields.SurfaceDescription.SpecularAAThreshold) &&
context.pass.validPixelBlocks.Contains(HDBlockFields.SurfaceDescription.SpecularAAScreenSpaceVariance));
}

public override void GetActiveBlocks(ref TargetActiveBlockContext context)
Expand Down
Loading