Пример #1
0
        private void UpdateMipSamplingModeInputs()
        {
            var capabilities = ShaderStageCapability.Fragment;

            if (m_MipSamplingMode == Texture2DMipSamplingMode.LOD || m_MipSamplingMode == Texture2DMipSamplingMode.Gradient)
            {
                capabilities |= ShaderStageCapability.Vertex;
            }

            m_RGBAPins.SetCapabilities(capabilities);

            m_Mip2DSamplingInputs = MipSamplingModesUtils.CreateMip2DSamplingInputs(
                this, m_MipSamplingMode, m_Mip2DSamplingInputs, MipBiasInput, LodInput, DdxInput, DdyInput);
        }
Пример #2
0
        public static string GetSamplerMipArgs(
            AbstractMaterialNode node, Texture2DMipSamplingMode mode, Mip2DSamplingInputs inputs, GenerationMode generationMode)
        {
            switch (mode)
            {
            case Texture2DMipSamplingMode.LOD:
                return(string.Format(", {0}", node.GetSlotValue(inputs.lodInput, generationMode)));

            case Texture2DMipSamplingMode.Bias:
                return(string.Format(", {0}", node.GetSlotValue(inputs.biasInput, generationMode)));

            case Texture2DMipSamplingMode.Gradient:
                return(string.Format(", {0}, {1}", node.GetSlotValue(inputs.ddxInput, generationMode), node.GetSlotValue(inputs.ddyInput, generationMode)));
            }

            return("");
        }
Пример #3
0
        public static Mip2DSamplingInputs CreateMip2DSamplingInputs(
            AbstractMaterialNode node, Texture2DMipSamplingMode mode, Mip2DSamplingInputs previousInputs,
            int biasInputId, int lodInputId, int ddxInputId, int ddyInputId)
        {
            if (previousInputs.bias != null)
            {
                node.RemoveSlot(previousInputs.bias.id);
            }
            if (previousInputs.lod != null)
            {
                node.RemoveSlot(previousInputs.lod.id);
            }
            if (previousInputs.ddx != null)
            {
                node.RemoveSlot(previousInputs.ddx.id);
            }
            if (previousInputs.ddy != null)
            {
                node.RemoveSlot(previousInputs.ddy.id);
            }

            Mip2DSamplingInputs inputs = Mip2DSamplingInputs.NewDefault();

            inputs.biasInput = biasInputId;
            inputs.lodInput  = lodInputId;
            inputs.ddxInput  = ddxInputId;
            inputs.ddyInput  = ddyInputId;
            switch (mode)
            {
            case Texture2DMipSamplingMode.LOD:
                inputs.lod = node.AddSlot(new Vector1MaterialSlot(lodInputId, kLodName, kLodName, SlotType.Input, 0.0f));
                break;

            case Texture2DMipSamplingMode.Bias:
                inputs.bias = node.AddSlot(new Vector1MaterialSlot(biasInputId, kBiasName, kBiasName, SlotType.Input, 0.0f));
                break;

            case Texture2DMipSamplingMode.Gradient:
                inputs.ddx = node.AddSlot(new Vector2MaterialSlot(ddxInputId, kDdxName, kDdxName, SlotType.Input, new Vector2(0.0f, 0.0f)));
                inputs.ddy = node.AddSlot(new Vector2MaterialSlot(ddyInputId, kDdyName, kDdyName, SlotType.Input, new Vector2(0.0f, 0.0f)));
                break;
            }

            return(inputs);
        }