public DelegateParameterBinding <T> Set <T>(EffectParameter parameter, Func <DelegateParameterBinding <T>, RenderContext, T> computeParameter)
        {
            DelegateParameterBinding <T> binding;
            int index = ParameterBindings.IndexOf(parameter);

            if (index >= 0)
            {
                // An effect parameter binding already exists.
                binding = ParameterBindings[index] as DelegateParameterBinding <T>;
                if (binding != null)
                {
                    // Update existing binding.
                    binding.ComputeParameter = computeParameter;
                }
                else
                {
                    // Replace existing binding.
                    binding = new DelegateParameterBinding <T>(Effect, parameter, computeParameter);
                    ParameterBindings[index] = binding;
                }
            }
            else
            {
                // Create a new binding.
                binding = new DelegateParameterBinding <T>(Effect, parameter, computeParameter);
                CheckHint(binding);
                ParameterBindings.Add(binding);
            }

            return(binding);
        }
Пример #2
0
 private static Vector4 GetDebug(DelegateParameterBinding <Vector4> binding, RenderContext context)
 {
     if (binding.Description.Index == 0)
     {
         return(Debug0);
     }
     if (binding.Description.Index == 1)
     {
         return(Debug1);
     }
     return(new Vector4(0, 0, 0, 0));
 }
Пример #3
0
        private static Texture2D GetDetailClipmapTexture(DelegateParameterBinding <Texture2D> binding, RenderContext context)
        {
            var usage    = binding.Description;
            int index    = (usage != null) ? usage.Index : 0;
            var textures = GetTerrainNode(context).DetailClipmap.Textures;

            if (index < textures.Length)
            {
                return(textures[index]);
            }

            return(null);
        }
Пример #4
0
        private static Texture2D GetLightBuffer(DelegateParameterBinding <Texture2D> binding, RenderContext context)
        {
            if (binding.Description.Index == 0)
            {
                return(context.LightBuffer0);
            }
            if (binding.Description.Index == 1)
            {
                return(context.LightBuffer1);
            }

            return(null);
        }
Пример #5
0
 private static float GetDetailClipmapCellsPerLevel(DelegateParameterBinding <float> binding, RenderContext context)
 {
     return(GetTerrainNode(context).DetailClipmap.CellsPerLevel);
 }
Пример #6
0
 private static float GetBaseClipmapNumberOfLevels(DelegateParameterBinding <float> binding, RenderContext context)
 {
     return(GetTerrainNode(context).BaseClipmap.NumberOfLevels);
 }
Пример #7
0
 private static float GetBaseClipmapCellSize(DelegateParameterBinding <float> binding, RenderContext context)
 {
     return(GetTerrainNode(context).BaseClipmap.CellSizes[0]);
 }
Пример #8
0
 private static float GetPassIndexAsSingle(DelegateParameterBinding <float> binding, RenderContext context)
 {
     return(Math.Max(context.PassIndex, 0.0f));
 }
Пример #9
0
        private static Vector2 GetTerrainOrigin(DelegateParameterBinding <Vector2> binding, RenderContext context)
        {
            var terrainTile = GetTerrainTile(context);

            return(new Vector2(terrainTile.OriginX, terrainTile.OriginZ));
        }
Пример #10
0
 private static float GetDetailFadeRange(DelegateParameterBinding <float> binding, RenderContext context)
 {
     return(GetTerrainNode(context).DetailFadeRange);
 }
Пример #11
0
        private static Vector2 GetTerrainSize(DelegateParameterBinding <Vector2> binding, RenderContext context)
        {
            var terrainTile = GetTerrainTile(context);

            return(new Vector2(terrainTile.WidthX, terrainTile.WidthZ));
        }
Пример #12
0
 private static Texture2D GetSourceTexture2D(DelegateParameterBinding <Texture2D> binding, RenderContext context)
 {
     return(context.SourceTexture);
 }
Пример #13
0
        //private Vector2 GetRenderTargetSize(DelegateParameterBinding<Vector2> binding, RenderContext context)
        //{
        //  var renderTarget = context.RenderTarget;
        //  if (renderTarget != null)
        //    return new Vector2(renderTarget.Width, renderTarget.Height);

        //  var presentationParameters = context.GraphicsService.GraphicsDevice.PresentationParameters;
        //  return new Vector2(presentationParameters.BackBufferWidth, presentationParameters.BackBufferHeight);
        //}


        private static Vector2 GetViewportSize(DelegateParameterBinding <Vector2> binding, RenderContext context)
        {
            var viewport = context.GraphicsService.GraphicsDevice.Viewport;

            return(new Vector2(viewport.Width, viewport.Height));
        }
Пример #14
0
 private static float GetElapsedTime(DelegateParameterBinding <float> binding, RenderContext context)
 {
     return((float)context.DeltaTime.TotalSeconds);
 }
Пример #15
0
 private static float GetLastTime(DelegateParameterBinding <float> binding, RenderContext context)
 {
     return((float)(context.Time - context.DeltaTime).TotalSeconds);
 }
Пример #16
0
 private static float GetDetailClipmapNumberOfColumns(DelegateParameterBinding <float> binding, RenderContext context)
 {
     return(GetTerrainNode(context).DetailClipmap.NumberOfTextureAtlasColumns);
 }
Пример #17
0
 private static float GetDetailClipmapLevelBias(DelegateParameterBinding <float> binding, RenderContext context)
 {
     return(GetTerrainNode(context).DetailClipmap.LevelBias);
 }
Пример #18
0
 private static Texture2D GetTerrainHoleTexture(DelegateParameterBinding <Texture2D> binding, RenderContext context)
 {
     return(GetTerrainTile(context).HoleTexture ?? context.GraphicsService.GetDefaultTexture2DWhite());
 }
Пример #19
0
 private static float GetDetailEnableAnisotropicFiltering(DelegateParameterBinding <float> binding, RenderContext context)
 {
     return(GetTerrainNode(context).DetailClipmap.EnableAnisotropicFiltering ? 1 : 0);
 }
Пример #20
0
        private static Vector2 GetTerrainHoleTextureSize(DelegateParameterBinding <Vector2> binding, RenderContext context)
        {
            var texture = GetTerrainHoleTexture(null, context);

            return(new Vector2(texture.Width, texture.Height));
        }
Пример #21
0
 private static float GetHoleThreshold(DelegateParameterBinding <float> binding, RenderContext context)
 {
     return(GetTerrainNode(context).HoleThreshold);
 }
Пример #22
0
 private static int GetPassIndexAsInt32(DelegateParameterBinding <int> binding, RenderContext context)
 {
     return(Math.Max(context.PassIndex, 0));
 }