Esempio n. 1
0
        void UpgradeUnlitMasterNode(UnlitMasterNode1 unlitMasterNode, out Dictionary <BlockFieldDescriptor, int> blockMap)
        {
            m_MigrateFromOldCrossPipelineSG = true;
            m_MigrateFromOldSG = true;

            // Set data
            systemData.surfaceType = (SurfaceType)unlitMasterNode.m_SurfaceType;
            systemData.blendMode   = HDSubShaderUtilities.UpgradeLegacyAlphaModeToBlendMode((int)unlitMasterNode.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.doubleSidedMode         = unlitMasterNode.m_TwoSided ? DoubleSidedMode.Enabled : DoubleSidedMode.Disabled;
            systemData.alphaTest               = HDSubShaderUtilities.UpgradeLegacyAlphaClip(unlitMasterNode);
            systemData.dotsInstancing          = false;
            systemData.transparentZWrite       = false;
            builtinData.addPrecomputedVelocity = false;
            target.customEditorGUI             = unlitMasterNode.m_OverrideEnabled ? unlitMasterNode.m_ShaderGUIOverride : "";

            // 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 },
            };
        }
        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;
            // 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.dotsInstancing          = false;
            systemData.alphaTest               = HDSubShaderUtilities.UpgradeLegacyAlphaClip(pbrMasterNode);
            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;
            litData.clearCoat      = false;
            target.customEditorGUI = pbrMasterNode.m_OverrideEnabled ? pbrMasterNode.m_ShaderGUIOverride : "";
            // 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;
            }

            // PBRMasterNode adds/removes Metallic/Specular based on settings
            BlockFieldDescriptor specularMetallicBlock;
            int specularMetallicId;

            if (litData.materialType == HDLitData.MaterialType.SpecularColor)
            {
                specularMetallicBlock = BlockFields.SurfaceDescription.Specular;
                specularMetallicId    = 3;
            }
            else
            {
                specularMetallicBlock = BlockFields.SurfaceDescription.Metallic;
                specularMetallicId    = 2;
            }

            // Set blockmap
            blockMap = new Dictionary <BlockFieldDescriptor, int>()
            {
                { BlockFields.VertexDescription.Position, 9 },
                { BlockFields.VertexDescription.Normal, 10 },
                { BlockFields.VertexDescription.Tangent, 11 },
                { BlockFields.SurfaceDescription.BaseColor, 0 },
                { normalBlock, 1 },
                { specularMetallicBlock, specularMetallicId },
                { BlockFields.SurfaceDescription.Emission, 4 },
                { BlockFields.SurfaceDescription.Smoothness, 5 },
                { BlockFields.SurfaceDescription.Occlusion, 6 },
                { BlockFields.SurfaceDescription.Alpha, 7 },
                { BlockFields.SurfaceDescription.AlphaClipThreshold, 8 },
            };
        }