Пример #1
0
        public void Initialize(Device device)
        {
            _b = EffectUtils.Load(ShadersResourceManager.Manager, "BakeryShaders");
            E  = new Effect(device, _b);

            TechPerPixel              = new EffectReadyTechnique(E.GetTechniqueByName("PerPixel"));
            TechMultiLayer            = new EffectReadyTechnique(E.GetTechniqueByName("MultiLayer"));
            TechPerPixel_SecondPass   = new EffectReadyTechnique(E.GetTechniqueByName("PerPixel_SecondPass"));
            TechMultiLayer_SecondPass = new EffectReadyTechnique(E.GetTechniqueByName("MultiLayer_SecondPass"));
            TechPerPixel_GrassPass    = new EffectReadyTechnique(E.GetTechniqueByName("PerPixel_GrassPass"));

            for (var i = 0; i < TechPerPixel.Description.PassCount && InputSignaturePNTG == null; i++)
            {
                InputSignaturePNTG = TechPerPixel.GetPassByIndex(i).Description.Signature;
            }
            if (InputSignaturePNTG == null)
            {
                throw new System.Exception("input signature (BakeryShaders, PNTG, PerPixel) == null");
            }
            LayoutPNTG = new InputLayout(device, InputSignaturePNTG, InputLayouts.VerticePNTG.InputElementsValue);

            FxWorldViewProj  = new EffectOnlyMatrixVariable(E.GetVariableByName("gWorldViewProj"));
            FxDiffuseMap     = new EffectOnlyResourceVariable(E.GetVariableByName("gDiffuseMap"));
            FxMaskMap        = new EffectOnlyResourceVariable(E.GetVariableByName("gMaskMap"));
            FxDetailRMap     = new EffectOnlyResourceVariable(E.GetVariableByName("gDetailRMap"));
            FxDetailGMap     = new EffectOnlyResourceVariable(E.GetVariableByName("gDetailGMap"));
            FxDetailBMap     = new EffectOnlyResourceVariable(E.GetVariableByName("gDetailBMap"));
            FxDetailAMap     = new EffectOnlyResourceVariable(E.GetVariableByName("gDetailAMap"));
            FxAlphaMap       = new EffectOnlyResourceVariable(E.GetVariableByName("gAlphaMap"));
            FxKsDiffuse      = new EffectOnlyFloatVariable(E.GetVariableByName("gKsDiffuse"));
            FxAlphaRef       = new EffectOnlyFloatVariable(E.GetVariableByName("gAlphaRef"));
            FxMagicMult      = new EffectOnlyFloatVariable(E.GetVariableByName("gMagicMult"));
            FxSecondPassMode = new EffectOnlyFloatVariable(E.GetVariableByName("gSecondPassMode"));
            FxMultRGBA       = new EffectOnlyVector4Variable(E.GetVariableByName("gMultRGBA"));
        }
Пример #2
0
        protected void SetRandomValues(DeviceContextHolder holder, EffectOnlyResourceVariable texture, EffectOnlyVector4Variable size, bool accumulationMode,
                                       Vector2 targetSize)
        {
            if (_accumulationMode != accumulationMode)
            {
                _accumulationMode = accumulationMode;

                var randomSize = accumulationMode ? 16 : 4;
                texture.SetResource(holder.GetRandomTexture(randomSize, randomSize));
                _randomSize = randomSize;

                if (!accumulationMode)
                {
                    size.Set(new Vector4(targetSize.X / _randomSize, targetSize.Y / _randomSize, 0f, 0f));
                }
            }
            else if (accumulationMode)
            {
                size.Set(new Vector4(targetSize.X / _randomSize, targetSize.Y / _randomSize, MathUtils.Random(0f, 1f), MathUtils.Random(0f, 1f)));
            }
        }
 public static void Set([CanBeNull] this SourceReady ready, [NotNull] EffectOnlyResourceVariable resource,
                        [NotNull] EffectOnlyVector4Variable channelsAssignments)
 {
     resource.SetResource(ready?.View);
     channelsAssignments.Set(ready?.ChannelsAssignments ?? default(Vector4));
 }