[Draft] Fix upgrade of Unlit and PBR cross pipeline SG to HD SG [Skip CI] by sebastienlagarde · Pull Request #685 · Unity-Technologies/Graphics · GitHub
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 @@ -33,15 +33,20 @@ public bool TryUpgradeFromMasterNode(IMasterNode1 masterNode, out Dictionary<Blo

void UpgradePBRMasterNode(PBRMasterNode1 pbrMasterNode, out Dictionary<BlockFieldDescriptor, int> blockMap)
{
m_MigrateFromOldCrossPipelineSG = true;

// Set data
systemData.surfaceType = (SurfaceType)pbrMasterNode.m_SurfaceType;
systemData.blendMode = HDSubShaderUtilities.UpgradeLegacyAlphaModeToBlendMode((int)pbrMasterNode.m_AlphaMode);
systemData.doubleSidedMode = pbrMasterNode.m_TwoSided ? DoubleSidedMode.Enabled : DoubleSidedMode.Disabled;
systemData.alphaTest = HDSubShaderUtilities.UpgradeLegacyAlphaClip(pbrMasterNode);
systemData.dotsInstancing = pbrMasterNode.m_DOTSInstancing;
systemData.dotsInstancing = false;
builtinData.addPrecomputedVelocity = false;
lightingData.blendPreserveSpecular = false;
lightingData.normalDropOffSpace = pbrMasterNode.m_NormalDropOffSpace;
lightingData.receiveDecals = false;
lightingData.receiveSSR = true;
lightingData.receiveSSRTransparent = false;
litData.materialType = pbrMasterNode.m_Model == PBRMasterNode1.Model.Specular ? HDLitData.MaterialType.SpecularColor : HDLitData.MaterialType.Standard;
litData.energyConservingSpecular = false;
target.customEditorGUI = pbrMasterNode.m_OverrideEnabled ? pbrMasterNode.m_ShaderGUIOverride : "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ abstract class HDSubTarget : SubTarget<HDTarget>, IHasMetadata,
IRequiresData<SystemData>
{
SystemData m_SystemData;
protected bool m_MigrateFromOldCrossPipelineSG; // Use only for the migration to shader stack architecture

// Interface Properties
SystemData IRequiresData<SystemData>.data
Expand Down Expand Up @@ -53,6 +54,7 @@ public virtual ScriptableObject GetMetadataObject()
{
var hdMetadata = ScriptableObject.CreateInstance<HDMetadata>();
hdMetadata.shaderID = shaderID;
hdMetadata.migrateFromOldCrossPipelineSG = m_MigrateFromOldCrossPipelineSG;
return hdMetadata;
}

Expand Down Expand Up @@ -107,4 +109,4 @@ public override object saveContext
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,16 @@ public bool TryUpgradeFromMasterNode(IMasterNode1 masterNode, out Dictionary<Blo

void UpgradeUnlitMasterNode(UnlitMasterNode1 unlitMasterNode, out Dictionary<BlockFieldDescriptor, int> blockMap)
{
m_MigrateFromOldCrossPipelineSG = true;

// Set data
systemData.surfaceType = (SurfaceType)unlitMasterNode.m_SurfaceType;
systemData.blendMode = HDSubShaderUtilities.UpgradeLegacyAlphaModeToBlendMode((int)unlitMasterNode.m_AlphaMode);
systemData.doubleSidedMode = unlitMasterNode.m_TwoSided ? DoubleSidedMode.Enabled : DoubleSidedMode.Disabled;
systemData.alphaTest = HDSubShaderUtilities.UpgradeLegacyAlphaClip(unlitMasterNode);
systemData.dotsInstancing = unlitMasterNode.m_DOTSInstancing;
systemData.dotsInstancing = false;
systemData.zWrite = false;
builtinData.addPrecomputedVelocity = unlitMasterNode.m_AddPrecomputedVelocity;
builtinData.addPrecomputedVelocity = false;
target.customEditorGUI = unlitMasterNode.m_OverrideEnabled ? unlitMasterNode.m_ShaderGUIOverride : "";

// Set blockmap
Expand Down Expand Up @@ -105,4 +107,4 @@ void UpgradeHDUnlitMasterNode(HDUnlitMasterNode1 hdUnlitMasterNode, out Dictiona
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using UnityEngine;
using UnityEditor.Rendering.HighDefinition;

Expand All @@ -10,10 +10,19 @@ sealed class HDMetadata : ScriptableObject
[SerializeField]
HDShaderUtils.ShaderID m_ShaderID;

[SerializeField]
bool m_MigrateFromOldCrossPipelineSG; // Keep track from which old SG master node we come from

public HDShaderUtils.ShaderID shaderID
{
get => m_ShaderID;
set => m_ShaderID = value;
}

public bool migrateFromOldCrossPipelineSG
{
get => m_MigrateFromOldCrossPipelineSG;
set => m_MigrateFromOldCrossPipelineSG = value;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ void UpgradeAlphaClip()
m_AlphaMode = (AlphaMode)unlitMasterNode.m_AlphaMode;
m_TwoSided = unlitMasterNode.m_TwoSided;
UpgradeAlphaClip();
m_AddPrecomputedVelocity = unlitMasterNode.m_AddPrecomputedVelocity;
m_AddPrecomputedVelocity = false;
m_CustomEditorGUI = unlitMasterNode.m_OverrideEnabled ? unlitMasterNode.m_ShaderGUIOverride : "";
break;
case SpriteLitMasterNode1 spriteLitMasterNode:
Expand Down
3 changes: 1 addition & 2 deletions com.unity.shadergraph/Editor/Data/Legacy/PBRMasterNode1.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using UnityEditor.Graphing;

Expand Down Expand Up @@ -32,7 +32,6 @@ public enum Model
public AlphaMode m_AlphaMode;
public bool m_TwoSided;
public NormalDropOffSpace m_NormalDropOffSpace;
public bool m_DOTSInstancing;
public string m_ShaderGUIOverride;
public bool m_OverrideEnabled;
}
Expand Down
4 changes: 1 addition & 3 deletions com.unity.shadergraph/Editor/Data/Legacy/UnlitMasterNode1.cs