public bool TryUpgradeFromMasterNode(IMasterNode1 masterNode, out Dictionary <BlockFieldDescriptor, int> blockMap) { blockMap = null; if (!(masterNode is DecalMasterNode1 decalMasterNode)) { return(false); } m_MigrateFromOldSG = true; // Set data systemData.surfaceType = (SurfaceType)decalMasterNode.m_SurfaceType; systemData.dotsInstancing = decalMasterNode.m_DOTSInstancing; decalData.affectsMetal = decalMasterNode.m_AffectsMetal; decalData.affectsAO = decalMasterNode.m_AffectsAO; decalData.affectsSmoothness = decalMasterNode.m_AffectsSmoothness; decalData.affectsAlbedo = decalMasterNode.m_AffectsAlbedo; decalData.affectsNormal = decalMasterNode.m_AffectsNormal; decalData.affectsEmission = decalMasterNode.m_AffectsEmission; decalData.drawOrder = decalMasterNode.m_DrawOrder; target.customEditorGUI = decalMasterNode.m_OverrideEnabled ? decalMasterNode.m_ShaderGUIOverride : ""; // Convert SlotMask to BlockMap entries var blockMapLookup = new Dictionary <DecalMasterNode1.SlotMask, BlockFieldDescriptor>() { { DecalMasterNode1.SlotMask.Position, BlockFields.VertexDescription.Position }, { DecalMasterNode1.SlotMask.VertexNormal, BlockFields.VertexDescription.Normal }, { DecalMasterNode1.SlotMask.VertexTangent, BlockFields.VertexDescription.Tangent }, { DecalMasterNode1.SlotMask.Albedo, BlockFields.SurfaceDescription.BaseColor }, { DecalMasterNode1.SlotMask.AlphaAlbedo, BlockFields.SurfaceDescription.Alpha }, { DecalMasterNode1.SlotMask.Normal, BlockFields.SurfaceDescription.NormalTS }, { DecalMasterNode1.SlotMask.AlphaNormal, HDBlockFields.SurfaceDescription.NormalAlpha }, { DecalMasterNode1.SlotMask.Metallic, BlockFields.SurfaceDescription.Metallic }, { DecalMasterNode1.SlotMask.Occlusion, BlockFields.SurfaceDescription.Occlusion }, { DecalMasterNode1.SlotMask.Smoothness, BlockFields.SurfaceDescription.Smoothness }, { DecalMasterNode1.SlotMask.AlphaMAOS, HDBlockFields.SurfaceDescription.MAOSAlpha }, { DecalMasterNode1.SlotMask.Emission, BlockFields.SurfaceDescription.Emission }, }; // Set blockmap blockMap = new Dictionary <BlockFieldDescriptor, int>(); foreach (DecalMasterNode1.SlotMask slotMask in Enum.GetValues(typeof(DecalMasterNode1.SlotMask))) { if (decalMasterNode.MaterialTypeUsesSlotMask(slotMask)) { if (!blockMapLookup.TryGetValue(slotMask, out var blockFieldDescriptor)) { continue; } var slotId = Mathf.Log((int)slotMask, 2); blockMap.Add(blockFieldDescriptor, (int)slotId); } } return(true); }
public static bool UpgradeLegacyAlphaClip(IMasterNode1 masterNode) { var clipThresholdId = 8; var node = masterNode as AbstractMaterialNode; var clipThresholdSlot = node.FindSlot <Vector1MaterialSlot>(clipThresholdId); if (clipThresholdSlot == null) { return(false); } clipThresholdSlot.owner = node; return(clipThresholdSlot.isConnected || clipThresholdSlot.value > 0.0f); }
public bool TryUpgradeFromMasterNode(IMasterNode1 masterNode, out Dictionary <BlockFieldDescriptor, int> blockMap) { blockMap = null; if (!(masterNode is CustomTextureMasterNode crtMasterNode)) { return(false); } blockMap = new Dictionary <BlockFieldDescriptor, int>() { { FullScreenBlocks.colorBlock, 0 }, }; return(true); }
public bool TryUpgradeFromMasterNode(IMasterNode1 masterNode, out Dictionary <BlockFieldDescriptor, int> blockMap) { blockMap = null; switch (masterNode) { case PBRMasterNode1 pbrMasterNode: UpgradePBRMasterNode(pbrMasterNode, out blockMap); return(true); case HDLitMasterNode1 hdLitMasterNode: UpgradeHDLitMasterNode(hdLitMasterNode, out blockMap); return(true); default: return(false); } }
public bool TryUpgradeFromMasterNode(IMasterNode1 masterNode, out Dictionary<BlockFieldDescriptor, int> blockMap) { blockMap = null; if(!(masterNode is SpriteUnlitMasterNode1 spriteUnlitMasterNode)) return false; // Set blockmap blockMap = new Dictionary<BlockFieldDescriptor, int>() { { BlockFields.VertexDescription.Position, 9 }, { BlockFields.VertexDescription.Normal, 10 }, { BlockFields.VertexDescription.Tangent, 11 }, { BlockFields.SurfaceDescriptionLegacy.SpriteColor, 0 }, }; return true; }
public bool TryUpgradeFromMasterNode(IMasterNode1 masterNode, out Dictionary <BlockFieldDescriptor, int> blockMap) { blockMap = null; if (!(masterNode is UnlitMasterNode1 unlitMasterNode)) { return(false); } // Set blockmap blockMap = new Dictionary <BlockFieldDescriptor, int>() { { BlockFields.VertexDescription.Position, 9 }, { BlockFields.VertexDescription.Normal, 10 }, { BlockFields.VertexDescription.Tangent, 11 }, { BlockFields.SurfaceDescription.BaseColor, 0 }, { BlockFields.SurfaceDescription.Alpha, 7 }, { BlockFields.SurfaceDescription.AlphaClipThreshold, 8 }, }; return(true); }
public bool TryUpgradeFromMasterNode(IMasterNode1 masterNode, out Dictionary <BlockFieldDescriptor, int> blockMap) { blockMap = null; if (!(masterNode is SpriteLitMasterNode1 spriteLitMasterNode)) { return(false); } // Set blockmap blockMap = new Dictionary <BlockFieldDescriptor, int>() { { BlockFields.VertexDescription.Position, 9 }, { BlockFields.VertexDescription.Normal, 10 }, { BlockFields.VertexDescription.Tangent, 11 }, { BlockFields.SurfaceDescriptionLegacy.SpriteColor, 0 }, { UniversalBlockFields.SurfaceDescription.SpriteMask, 1 }, { BlockFields.SurfaceDescription.NormalTS, 2 }, }; return(true); }
public bool TryUpgradeFromMasterNode(IMasterNode1 masterNode, out Dictionary <BlockFieldDescriptor, int> blockMap) { blockMap = null; if (!(masterNode is StackLitMasterNode1 stackLitMasterNode)) { return(false); } m_MigrateFromOldSG = true; // Set data systemData.surfaceType = (SurfaceType)stackLitMasterNode.m_SurfaceType; systemData.blendMode = HDSubShaderUtilities.UpgradeLegacyAlphaModeToBlendMode((int)stackLitMasterNode.m_AlphaMode); // Previous master node wasn't having any renderingPass. Assign it correctly now. systemData.renderingPass = systemData.surfaceType == SurfaceType.Opaque ? HDRenderQueue.RenderQueueType.Opaque : HDRenderQueue.RenderQueueType.Transparent; systemData.alphaTest = stackLitMasterNode.m_AlphaTest; systemData.sortPriority = stackLitMasterNode.m_SortPriority; systemData.doubleSidedMode = stackLitMasterNode.m_DoubleSidedMode; systemData.transparentZWrite = stackLitMasterNode.m_ZWrite; systemData.transparentCullMode = stackLitMasterNode.m_transparentCullMode; systemData.zTest = stackLitMasterNode.m_ZTest; systemData.dotsInstancing = stackLitMasterNode.m_DOTSInstancing; systemData.materialNeedsUpdateHash = stackLitMasterNode.m_MaterialNeedsUpdateHash; builtinData.supportLodCrossFade = stackLitMasterNode.m_SupportLodCrossFade; builtinData.transparencyFog = stackLitMasterNode.m_TransparencyFog; builtinData.distortion = stackLitMasterNode.m_Distortion; builtinData.distortionMode = stackLitMasterNode.m_DistortionMode; builtinData.distortionDepthTest = stackLitMasterNode.m_DistortionDepthTest; builtinData.addPrecomputedVelocity = stackLitMasterNode.m_AddPrecomputedVelocity; builtinData.depthOffset = stackLitMasterNode.m_depthOffset; builtinData.alphaToMask = stackLitMasterNode.m_AlphaToMask; lightingData.normalDropOffSpace = stackLitMasterNode.m_NormalDropOffSpace; lightingData.blendPreserveSpecular = stackLitMasterNode.m_BlendPreserveSpecular; lightingData.receiveDecals = stackLitMasterNode.m_ReceiveDecals; lightingData.receiveSSR = stackLitMasterNode.m_ReceiveSSR; lightingData.receiveSSRTransparent = stackLitMasterNode.m_ReceivesSSRTransparent; lightingData.overrideBakedGI = stackLitMasterNode.m_overrideBakedGI; lightingData.specularAA = stackLitMasterNode.m_GeometricSpecularAA; stackLitData.subsurfaceScattering = stackLitMasterNode.m_SubsurfaceScattering; stackLitData.transmission = stackLitMasterNode.m_Transmission; stackLitData.energyConservingSpecular = stackLitMasterNode.m_EnergyConservingSpecular; stackLitData.baseParametrization = stackLitMasterNode.m_BaseParametrization; stackLitData.dualSpecularLobeParametrization = stackLitMasterNode.m_DualSpecularLobeParametrization; stackLitData.anisotropy = stackLitMasterNode.m_Anisotropy; stackLitData.coat = stackLitMasterNode.m_Coat; stackLitData.coatNormal = stackLitMasterNode.m_CoatNormal; stackLitData.dualSpecularLobe = stackLitMasterNode.m_DualSpecularLobe; stackLitData.capHazinessWrtMetallic = stackLitMasterNode.m_CapHazinessWrtMetallic; stackLitData.iridescence = stackLitMasterNode.m_Iridescence; stackLitData.screenSpaceSpecularOcclusionBaseMode = (StackLitData.SpecularOcclusionBaseMode)stackLitMasterNode.m_ScreenSpaceSpecularOcclusionBaseMode; stackLitData.dataBasedSpecularOcclusionBaseMode = (StackLitData.SpecularOcclusionBaseMode)stackLitMasterNode.m_DataBasedSpecularOcclusionBaseMode; stackLitData.screenSpaceSpecularOcclusionAOConeSize = (StackLitData.SpecularOcclusionAOConeSize)stackLitMasterNode.m_ScreenSpaceSpecularOcclusionAOConeSize; stackLitData.screenSpaceSpecularOcclusionAOConeDir = (StackLitData.SpecularOcclusionAOConeDir)stackLitMasterNode.m_ScreenSpaceSpecularOcclusionAOConeDir; stackLitData.dataBasedSpecularOcclusionAOConeSize = (StackLitData.SpecularOcclusionAOConeSize)stackLitMasterNode.m_DataBasedSpecularOcclusionAOConeSize; stackLitData.specularOcclusionConeFixupMethod = (StackLitData.SpecularOcclusionConeFixupMethod)stackLitMasterNode.m_SpecularOcclusionConeFixupMethod; stackLitData.anisotropyForAreaLights = stackLitMasterNode.m_AnisotropyForAreaLights; stackLitData.recomputeStackPerLight = stackLitMasterNode.m_RecomputeStackPerLight; stackLitData.honorPerLightMinRoughness = stackLitMasterNode.m_HonorPerLightMinRoughness; stackLitData.shadeBaseUsingRefractedAngles = stackLitMasterNode.m_ShadeBaseUsingRefractedAngles; stackLitData.debug = stackLitMasterNode.m_Debug; stackLitData.devMode = stackLitMasterNode.m_DevMode; target.customEditorGUI = stackLitMasterNode.m_OverrideEnabled ? stackLitMasterNode.m_ShaderGUIOverride : ""; // Set blockmap blockMap = new Dictionary <BlockFieldDescriptor, int>(); blockMap.Add(BlockFields.VertexDescription.Position, StackLitMasterNode1.PositionSlotId); blockMap.Add(BlockFields.VertexDescription.Normal, StackLitMasterNode1.VertexNormalSlotId); blockMap.Add(BlockFields.VertexDescription.Tangent, StackLitMasterNode1.VertexTangentSlotId); // Handle mapping of Normal block specifically BlockFieldDescriptor normalBlock; switch (lightingData.normalDropOffSpace) { case NormalDropOffSpace.Object: normalBlock = BlockFields.SurfaceDescription.NormalOS; break; case NormalDropOffSpace.World: normalBlock = BlockFields.SurfaceDescription.NormalWS; break; default: normalBlock = BlockFields.SurfaceDescription.NormalTS; break; } blockMap.Add(normalBlock, StackLitMasterNode1.NormalSlotId); blockMap.Add(HDBlockFields.SurfaceDescription.BentNormal, StackLitMasterNode1.BentNormalSlotId); blockMap.Add(HDBlockFields.SurfaceDescription.Tangent, StackLitMasterNode1.TangentSlotId); blockMap.Add(BlockFields.SurfaceDescription.BaseColor, StackLitMasterNode1.BaseColorSlotId); if (stackLitData.baseParametrization == StackLit.BaseParametrization.BaseMetallic) { blockMap.Add(BlockFields.SurfaceDescription.Metallic, StackLitMasterNode1.MetallicSlotId); blockMap.Add(HDBlockFields.SurfaceDescription.DielectricIor, StackLitMasterNode1.DielectricIorSlotId); } else if (stackLitData.baseParametrization == StackLit.BaseParametrization.SpecularColor) { blockMap.Add(BlockFields.SurfaceDescription.Specular, StackLitMasterNode1.SpecularColorSlotId); } blockMap.Add(BlockFields.SurfaceDescription.Smoothness, StackLitMasterNode1.SmoothnessASlotId); if (stackLitData.anisotropy) { blockMap.Add(HDBlockFields.SurfaceDescription.Anisotropy, StackLitMasterNode1.AnisotropyASlotId); } blockMap.Add(BlockFields.SurfaceDescription.Occlusion, StackLitMasterNode1.AmbientOcclusionSlotId); if (stackLitData.dataBasedSpecularOcclusionBaseMode == StackLitData.SpecularOcclusionBaseMode.Custom) { blockMap.Add(HDBlockFields.SurfaceDescription.SpecularOcclusion, StackLitMasterNode1.SpecularOcclusionSlotId); } if (SpecularOcclusionUsesBentNormal(stackLitData) && stackLitData.specularOcclusionConeFixupMethod != StackLitData.SpecularOcclusionConeFixupMethod.Off) { blockMap.Add(HDBlockFields.SurfaceDescription.SOFixupVisibilityRatioThreshold, StackLitMasterNode1.SOFixupVisibilityRatioThresholdSlotId); blockMap.Add(HDBlockFields.SurfaceDescription.SOFixupStrengthFactor, StackLitMasterNode1.SOFixupStrengthFactorSlotId); if (SpecularOcclusionConeFixupMethodModifiesRoughness(stackLitData.specularOcclusionConeFixupMethod)) { blockMap.Add(HDBlockFields.SurfaceDescription.SOFixupMaxAddedRoughness, StackLitMasterNode1.SOFixupMaxAddedRoughnessSlotId); } } if (stackLitData.coat) { blockMap.Add(HDBlockFields.SurfaceDescription.CoatSmoothness, StackLitMasterNode1.CoatSmoothnessSlotId); blockMap.Add(HDBlockFields.SurfaceDescription.CoatIor, StackLitMasterNode1.CoatIorSlotId); blockMap.Add(HDBlockFields.SurfaceDescription.CoatThickness, StackLitMasterNode1.CoatThicknessSlotId); blockMap.Add(HDBlockFields.SurfaceDescription.CoatExtinction, StackLitMasterNode1.CoatExtinctionSlotId); if (stackLitData.coatNormal) { blockMap.Add(HDBlockFields.SurfaceDescription.CoatNormalTS, StackLitMasterNode1.CoatNormalSlotId); } blockMap.Add(HDBlockFields.SurfaceDescription.CoatMask, StackLitMasterNode1.CoatMaskSlotId); } if (stackLitData.dualSpecularLobe) { if (stackLitData.dualSpecularLobeParametrization == StackLit.DualSpecularLobeParametrization.Direct) { blockMap.Add(HDBlockFields.SurfaceDescription.SmoothnessB, StackLitMasterNode1.SmoothnessBSlotId); blockMap.Add(HDBlockFields.SurfaceDescription.LobeMix, StackLitMasterNode1.LobeMixSlotId); } else if (stackLitData.dualSpecularLobeParametrization == StackLit.DualSpecularLobeParametrization.HazyGloss) { blockMap.Add(HDBlockFields.SurfaceDescription.Haziness, StackLitMasterNode1.HazinessSlotId); blockMap.Add(HDBlockFields.SurfaceDescription.HazeExtent, StackLitMasterNode1.HazeExtentSlotId); if (stackLitData.capHazinessWrtMetallic && stackLitData.baseParametrization == StackLit.BaseParametrization.BaseMetallic) // the later should be an assert really { blockMap.Add(HDBlockFields.SurfaceDescription.HazyGlossMaxDielectricF0, StackLitMasterNode1.HazyGlossMaxDielectricF0SlotId); } } if (stackLitData.anisotropy) { blockMap.Add(HDBlockFields.SurfaceDescription.AnisotropyB, StackLitMasterNode1.AnisotropyBSlotId); } } if (stackLitData.iridescence) { blockMap.Add(HDBlockFields.SurfaceDescription.IridescenceMask, StackLitMasterNode1.IridescenceMaskSlotId); blockMap.Add(HDBlockFields.SurfaceDescription.IridescenceThickness, StackLitMasterNode1.IridescenceThicknessSlotId); if (stackLitData.coat) { blockMap.Add(HDBlockFields.SurfaceDescription.IridescenceCoatFixupTIR, StackLitMasterNode1.IridescenceCoatFixupTIRSlotId); blockMap.Add(HDBlockFields.SurfaceDescription.IridescenceCoatFixupTIRClamp, StackLitMasterNode1.IridescenceCoatFixupTIRClampSlotId); } } if (stackLitData.subsurfaceScattering) { blockMap.Add(HDBlockFields.SurfaceDescription.SubsurfaceMask, StackLitMasterNode1.SubsurfaceMaskSlotId); } if (stackLitData.transmission) { blockMap.Add(HDBlockFields.SurfaceDescription.Thickness, StackLitMasterNode1.ThicknessSlotId); } if (stackLitData.subsurfaceScattering || stackLitData.transmission) { blockMap.Add(HDBlockFields.SurfaceDescription.DiffusionProfileHash, StackLitMasterNode1.DiffusionProfileHashSlotId); } blockMap.Add(BlockFields.SurfaceDescription.Alpha, StackLitMasterNode1.AlphaSlotId); if (systemData.alphaTest) { blockMap.Add(BlockFields.SurfaceDescription.AlphaClipThreshold, StackLitMasterNode1.AlphaClipThresholdSlotId); } blockMap.Add(BlockFields.SurfaceDescription.Emission, StackLitMasterNode1.EmissionSlotId); if (systemData.surfaceType == SurfaceType.Transparent && builtinData.distortion) { blockMap.Add(HDBlockFields.SurfaceDescription.Distortion, StackLitMasterNode1.DistortionSlotId); blockMap.Add(HDBlockFields.SurfaceDescription.DistortionBlur, StackLitMasterNode1.DistortionBlurSlotId); } if (lightingData.specularAA) { blockMap.Add(HDBlockFields.SurfaceDescription.SpecularAAScreenSpaceVariance, StackLitMasterNode1.SpecularAAScreenSpaceVarianceSlotId); blockMap.Add(HDBlockFields.SurfaceDescription.SpecularAAThreshold, StackLitMasterNode1.SpecularAAThresholdSlotId); } if (lightingData.overrideBakedGI) { blockMap.Add(HDBlockFields.SurfaceDescription.BakedGI, StackLitMasterNode1.LightingSlotId); blockMap.Add(HDBlockFields.SurfaceDescription.BakedBackGI, StackLitMasterNode1.BackLightingSlotId); } if (builtinData.depthOffset) { blockMap.Add(HDBlockFields.SurfaceDescription.DepthOffset, StackLitMasterNode1.DepthOffsetSlotId); } return(true); }
public bool TryUpgradeFromMasterNode(IMasterNode1 masterNode, out Dictionary <BlockFieldDescriptor, int> blockMap) { blockMap = null; if (!(masterNode is EyeMasterNode1 eyeMasterNode)) { return(false); } m_MigrateFromOldSG = true; // Set data systemData.surfaceType = (SurfaceType)eyeMasterNode.m_SurfaceType; systemData.blendMode = HDSubShaderUtilities.UpgradeLegacyAlphaModeToBlendMode((int)eyeMasterNode.m_AlphaMode); // Previous master node wasn't having any renderingPass. Assign it correctly now. systemData.renderQueueType = systemData.surfaceType == SurfaceType.Opaque ? HDRenderQueue.RenderQueueType.Opaque : HDRenderQueue.RenderQueueType.Transparent; systemData.alphaTest = eyeMasterNode.m_AlphaTest; systemData.sortPriority = eyeMasterNode.m_SortPriority; systemData.doubleSidedMode = eyeMasterNode.m_DoubleSidedMode; systemData.transparentZWrite = eyeMasterNode.m_ZWrite; systemData.transparentCullMode = eyeMasterNode.m_transparentCullMode; systemData.zTest = eyeMasterNode.m_ZTest; systemData.dotsInstancing = eyeMasterNode.m_DOTSInstancing; systemData.materialNeedsUpdateHash = eyeMasterNode.m_MaterialNeedsUpdateHash; builtinData.transparentDepthPrepass = eyeMasterNode.m_AlphaTestDepthPrepass; builtinData.transparentDepthPostpass = eyeMasterNode.m_AlphaTestDepthPostpass; builtinData.supportLodCrossFade = eyeMasterNode.m_SupportLodCrossFade; builtinData.transparencyFog = eyeMasterNode.m_TransparencyFog; builtinData.addPrecomputedVelocity = eyeMasterNode.m_AddPrecomputedVelocity; builtinData.depthOffset = eyeMasterNode.m_depthOffset; builtinData.alphaToMask = eyeMasterNode.m_AlphaToMask; lightingData.blendPreserveSpecular = eyeMasterNode.m_BlendPreserveSpecular; lightingData.receiveDecals = eyeMasterNode.m_ReceiveDecals; lightingData.receiveSSR = eyeMasterNode.m_ReceivesSSR; lightingData.receiveSSRTransparent = eyeMasterNode.m_ReceivesSSRTransparent; lightingData.specularOcclusionMode = eyeMasterNode.m_SpecularOcclusionMode; lightingData.overrideBakedGI = eyeMasterNode.m_overrideBakedGI; eyeData.subsurfaceScattering = eyeMasterNode.m_SubsurfaceScattering; eyeData.materialType = (EyeData.MaterialType)eyeMasterNode.m_MaterialType; target.customEditorGUI = eyeMasterNode.m_OverrideEnabled ? eyeMasterNode.m_ShaderGUIOverride : ""; // Convert SlotMask to BlockMap entries var blockMapLookup = new Dictionary <EyeMasterNode1.SlotMask, BlockFieldDescriptor>() { { EyeMasterNode1.SlotMask.Position, BlockFields.VertexDescription.Position }, { EyeMasterNode1.SlotMask.VertexNormal, BlockFields.VertexDescription.Normal }, { EyeMasterNode1.SlotMask.VertexTangent, BlockFields.VertexDescription.Tangent }, { EyeMasterNode1.SlotMask.Albedo, BlockFields.SurfaceDescription.BaseColor }, { EyeMasterNode1.SlotMask.SpecularOcclusion, HDBlockFields.SurfaceDescription.SpecularOcclusion }, { EyeMasterNode1.SlotMask.Normal, BlockFields.SurfaceDescription.NormalTS }, { EyeMasterNode1.SlotMask.IrisNormal, HDBlockFields.SurfaceDescription.IrisNormalTS }, { EyeMasterNode1.SlotMask.BentNormal, HDBlockFields.SurfaceDescription.BentNormal }, { EyeMasterNode1.SlotMask.Smoothness, BlockFields.SurfaceDescription.Smoothness }, { EyeMasterNode1.SlotMask.IOR, HDBlockFields.SurfaceDescription.IOR }, { EyeMasterNode1.SlotMask.Occlusion, BlockFields.SurfaceDescription.Occlusion }, { EyeMasterNode1.SlotMask.Mask, HDBlockFields.SurfaceDescription.Mask }, { EyeMasterNode1.SlotMask.DiffusionProfile, HDBlockFields.SurfaceDescription.DiffusionProfileHash }, { EyeMasterNode1.SlotMask.SubsurfaceMask, HDBlockFields.SurfaceDescription.SubsurfaceMask }, { EyeMasterNode1.SlotMask.Emission, BlockFields.SurfaceDescription.Emission }, { EyeMasterNode1.SlotMask.Alpha, BlockFields.SurfaceDescription.Alpha }, { EyeMasterNode1.SlotMask.AlphaClipThreshold, BlockFields.SurfaceDescription.AlphaClipThreshold }, }; // Legacy master node slots have additional slot conditions, test them here bool AdditionalSlotMaskTests(EyeMasterNode1.SlotMask slotMask) { switch (slotMask) { case EyeMasterNode1.SlotMask.SpecularOcclusion: return(lightingData.specularOcclusionMode == SpecularOcclusionMode.Custom); case EyeMasterNode1.SlotMask.DiffusionProfile: return(eyeData.subsurfaceScattering); case EyeMasterNode1.SlotMask.SubsurfaceMask: return(eyeData.subsurfaceScattering); case EyeMasterNode1.SlotMask.AlphaClipThreshold: return(systemData.alphaTest); default: return(true); } } // Set blockmap blockMap = new Dictionary <BlockFieldDescriptor, int>(); foreach (EyeMasterNode1.SlotMask slotMask in Enum.GetValues(typeof(EyeMasterNode1.SlotMask))) { if (eyeMasterNode.MaterialTypeUsesSlotMask(slotMask)) { if (!blockMapLookup.TryGetValue(slotMask, out var blockFieldDescriptor)) { continue; } if (!AdditionalSlotMaskTests(slotMask)) { continue; } var slotId = Mathf.Log((int)slotMask, 2); blockMap.Add(blockFieldDescriptor, (int)slotId); } } // Override Baked GI if (lightingData.overrideBakedGI) { blockMap.Add(HDBlockFields.SurfaceDescription.BakedGI, EyeMasterNode1.LightingSlotId); blockMap.Add(HDBlockFields.SurfaceDescription.BakedBackGI, EyeMasterNode1.BackLightingSlotId); } // Depth Offset if (builtinData.depthOffset) { blockMap.Add(HDBlockFields.SurfaceDescription.DepthOffset, EyeMasterNode1.DepthOffsetSlotId); } return(true); }
public bool TryUpgradeFromMasterNode(IMasterNode1 masterNode, out Dictionary <BlockFieldDescriptor, int> blockMap) { blockMap = null; if (!(masterNode is HairMasterNode1 hairMasterNode)) { return(false); } m_MigrateFromOldSG = true; // Set data systemData.surfaceType = (SurfaceType)hairMasterNode.m_SurfaceType; systemData.blendMode = HDSubShaderUtilities.UpgradeLegacyAlphaModeToBlendMode((int)hairMasterNode.m_AlphaMode); // Previous master node wasn't having any renderingPass. Assign it correctly now. systemData.renderQueueType = systemData.surfaceType == SurfaceType.Opaque ? HDRenderQueue.RenderQueueType.Opaque : HDRenderQueue.RenderQueueType.Transparent; systemData.alphaTest = hairMasterNode.m_AlphaTest; systemData.sortPriority = hairMasterNode.m_SortPriority; systemData.doubleSidedMode = hairMasterNode.m_DoubleSidedMode; systemData.transparentZWrite = hairMasterNode.m_ZWrite; systemData.transparentCullMode = hairMasterNode.m_transparentCullMode; systemData.zTest = hairMasterNode.m_ZTest; systemData.dotsInstancing = hairMasterNode.m_DOTSInstancing; systemData.materialNeedsUpdateHash = hairMasterNode.m_MaterialNeedsUpdateHash; builtinData.supportLodCrossFade = hairMasterNode.m_SupportLodCrossFade; builtinData.transparentDepthPrepass = hairMasterNode.m_AlphaTestDepthPrepass; builtinData.transparentDepthPostpass = hairMasterNode.m_AlphaTestDepthPostpass; builtinData.transparencyFog = hairMasterNode.m_TransparencyFog; builtinData.transparentWritesMotionVec = hairMasterNode.m_TransparentWritesMotionVec; builtinData.addPrecomputedVelocity = hairMasterNode.m_AddPrecomputedVelocity; builtinData.depthOffset = hairMasterNode.m_depthOffset; builtinData.alphaTestShadow = hairMasterNode.m_AlphaTestShadow; builtinData.backThenFrontRendering = hairMasterNode.m_BackThenFrontRendering; lightingData.blendPreserveSpecular = hairMasterNode.m_BlendPreserveSpecular; lightingData.receiveDecals = hairMasterNode.m_ReceiveDecals; lightingData.receiveSSR = hairMasterNode.m_ReceivesSSR; lightingData.receiveSSRTransparent = hairMasterNode.m_ReceivesSSRTransparent; lightingData.specularAA = hairMasterNode.m_SpecularAA; lightingData.specularOcclusionMode = hairMasterNode.m_SpecularOcclusionMode; lightingData.overrideBakedGI = hairMasterNode.m_overrideBakedGI; hairData.materialType = (HairData.MaterialType)hairMasterNode.m_MaterialType; hairData.geometryType = hairMasterNode.m_UseLightFacingNormal ? HairData.GeometryType.Strands : HairData.GeometryType.Cards; target.customEditorGUI = hairMasterNode.m_OverrideEnabled ? hairMasterNode.m_ShaderGUIOverride : ""; // Convert SlotMask to BlockMap entries var blockMapLookup = new Dictionary <HairMasterNode1.SlotMask, BlockFieldDescriptor>() { { HairMasterNode1.SlotMask.Position, BlockFields.VertexDescription.Position }, { HairMasterNode1.SlotMask.VertexNormal, BlockFields.VertexDescription.Normal }, { HairMasterNode1.SlotMask.VertexTangent, BlockFields.VertexDescription.Tangent }, { HairMasterNode1.SlotMask.Albedo, BlockFields.SurfaceDescription.BaseColor }, { HairMasterNode1.SlotMask.SpecularOcclusion, HDBlockFields.SurfaceDescription.SpecularOcclusion }, { HairMasterNode1.SlotMask.Normal, BlockFields.SurfaceDescription.NormalTS }, { HairMasterNode1.SlotMask.BentNormal, HDBlockFields.SurfaceDescription.BentNormal }, { HairMasterNode1.SlotMask.Smoothness, BlockFields.SurfaceDescription.Smoothness }, { HairMasterNode1.SlotMask.Occlusion, BlockFields.SurfaceDescription.Occlusion }, { HairMasterNode1.SlotMask.Transmittance, HDBlockFields.SurfaceDescription.Transmittance }, { HairMasterNode1.SlotMask.RimTransmissionIntensity, HDBlockFields.SurfaceDescription.RimTransmissionIntensity }, { HairMasterNode1.SlotMask.HairStrandDirection, HDBlockFields.SurfaceDescription.HairStrandDirection }, { HairMasterNode1.SlotMask.Emission, BlockFields.SurfaceDescription.Emission }, { HairMasterNode1.SlotMask.Alpha, BlockFields.SurfaceDescription.Alpha }, { HairMasterNode1.SlotMask.AlphaClipThreshold, BlockFields.SurfaceDescription.AlphaClipThreshold }, { HairMasterNode1.SlotMask.AlphaClipThresholdDepthPrepass, HDBlockFields.SurfaceDescription.AlphaClipThresholdDepthPrepass }, { HairMasterNode1.SlotMask.AlphaClipThresholdDepthPostpass, HDBlockFields.SurfaceDescription.AlphaClipThresholdDepthPostpass }, { HairMasterNode1.SlotMask.AlphaClipThresholdShadow, HDBlockFields.SurfaceDescription.AlphaClipThresholdShadow }, { HairMasterNode1.SlotMask.SpecularTint, HDBlockFields.SurfaceDescription.SpecularTint }, { HairMasterNode1.SlotMask.SpecularShift, HDBlockFields.SurfaceDescription.SpecularShift }, { HairMasterNode1.SlotMask.SecondarySpecularTint, HDBlockFields.SurfaceDescription.SecondarySpecularTint }, { HairMasterNode1.SlotMask.SecondarySmoothness, HDBlockFields.SurfaceDescription.SecondarySmoothness }, { HairMasterNode1.SlotMask.SecondarySpecularShift, HDBlockFields.SurfaceDescription.SecondarySpecularShift }, }; // Legacy master node slots have additional slot conditions, test them here bool AdditionalSlotMaskTests(HairMasterNode1.SlotMask slotMask) { switch (slotMask) { case HairMasterNode1.SlotMask.SpecularOcclusion: return(lightingData.specularOcclusionMode == SpecularOcclusionMode.Custom); case HairMasterNode1.SlotMask.AlphaClipThreshold: return(systemData.alphaTest); case HairMasterNode1.SlotMask.AlphaClipThresholdDepthPrepass: return(systemData.surfaceType == SurfaceType.Transparent && systemData.alphaTest && builtinData.transparentDepthPrepass); case HairMasterNode1.SlotMask.AlphaClipThresholdDepthPostpass: return(systemData.surfaceType == SurfaceType.Transparent && systemData.alphaTest && builtinData.transparentDepthPostpass); case HairMasterNode1.SlotMask.AlphaClipThresholdShadow: return(systemData.alphaTest && builtinData.alphaTestShadow); default: return(true); } } // Set blockmap blockMap = new Dictionary <BlockFieldDescriptor, int>(); foreach (HairMasterNode1.SlotMask slotMask in Enum.GetValues(typeof(HairMasterNode1.SlotMask))) { if (hairMasterNode.MaterialTypeUsesSlotMask(slotMask)) { if (!blockMapLookup.TryGetValue(slotMask, out var blockFieldDescriptor)) { continue; } if (!AdditionalSlotMaskTests(slotMask)) { continue; } var slotId = Mathf.Log((int)slotMask, 2); blockMap.Add(blockFieldDescriptor, (int)slotId); } } // Specular AA if (lightingData.specularAA) { blockMap.Add(HDBlockFields.SurfaceDescription.SpecularAAScreenSpaceVariance, HairMasterNode1.SpecularAAScreenSpaceVarianceSlotId); blockMap.Add(HDBlockFields.SurfaceDescription.SpecularAAThreshold, HairMasterNode1.SpecularAAThresholdSlotId); } // Override Baked GI if (lightingData.overrideBakedGI) { blockMap.Add(HDBlockFields.SurfaceDescription.BakedGI, HairMasterNode1.LightingSlotId); blockMap.Add(HDBlockFields.SurfaceDescription.BakedBackGI, HairMasterNode1.BackLightingSlotId); } // Depth Offset if (builtinData.depthOffset) { blockMap.Add(HDBlockFields.SurfaceDescription.DepthOffset, HairMasterNode1.DepthOffsetSlotId); } return(true); }
public bool TryUpgradeFromMasterNode(IMasterNode1 masterNode, out Dictionary <BlockFieldDescriptor, int> blockMap) { blockMap = null; return(false); }