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);
        }
Ejemplo n.º 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));
 }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 5
0
 private static float GetBaseClipmapCellSize(DelegateParameterBinding <float> binding, RenderContext context)
 {
     return(GetTerrainNode(context).BaseClipmap.CellSizes[0]);
 }
Ejemplo n.º 6
0
 private static float GetHoleThreshold(DelegateParameterBinding <float> binding, RenderContext context)
 {
     return(GetTerrainNode(context).HoleThreshold);
 }
Ejemplo n.º 7
0
        private static Vector2 GetTerrainHoleTextureSize(DelegateParameterBinding <Vector2> binding, RenderContext context)
        {
            var texture = GetTerrainHoleTexture(null, context);

            return(new Vector2(texture.Width, texture.Height));
        }
Ejemplo n.º 8
0
 private static float GetPassIndexAsSingle(DelegateParameterBinding <float> binding, RenderContext context)
 {
     return(Math.Max(context.PassIndex, 0.0f));
 }
Ejemplo n.º 9
0
 private static float GetDetailFadeRange(DelegateParameterBinding <float> binding, RenderContext context)
 {
     return(GetTerrainNode(context).DetailFadeRange);
 }
Ejemplo n.º 10
0
 private static float GetDetailClipmapNumberOfColumns(DelegateParameterBinding <float> binding, RenderContext context)
 {
     return(GetTerrainNode(context).DetailClipmap.NumberOfTextureAtlasColumns);
 }
Ejemplo n.º 11
0
 private static Texture2D GetSourceTexture2D(DelegateParameterBinding <Texture2D> binding, RenderContext context)
 {
     return(context.SourceTexture);
 }
Ejemplo n.º 12
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));
        }
Ejemplo n.º 13
0
 private static float GetElapsedTime(DelegateParameterBinding <float> binding, RenderContext context)
 {
     return((float)context.DeltaTime.TotalSeconds);
 }
Ejemplo n.º 14
0
 private static float GetLastTime(DelegateParameterBinding <float> binding, RenderContext context)
 {
     return((float)(context.Time - context.DeltaTime).TotalSeconds);
 }
Ejemplo n.º 15
0
 private static float GetBaseClipmapNumberOfLevels(DelegateParameterBinding <float> binding, RenderContext context)
 {
     return(GetTerrainNode(context).BaseClipmap.NumberOfLevels);
 }
Ejemplo n.º 16
0
        private static Vector2 GetTerrainOrigin(DelegateParameterBinding <Vector2> binding, RenderContext context)
        {
            var terrainTile = GetTerrainTile(context);

            return(new Vector2(terrainTile.OriginX, terrainTile.OriginZ));
        }
Ejemplo n.º 17
0
 private static float GetDetailClipmapCellsPerLevel(DelegateParameterBinding <float> binding, RenderContext context)
 {
     return(GetTerrainNode(context).DetailClipmap.CellsPerLevel);
 }
Ejemplo n.º 18
0
        private static Vector2 GetTerrainSize(DelegateParameterBinding <Vector2> binding, RenderContext context)
        {
            var terrainTile = GetTerrainTile(context);

            return(new Vector2(terrainTile.WidthX, terrainTile.WidthZ));
        }
Ejemplo n.º 19
0
 private static float GetDetailClipmapLevelBias(DelegateParameterBinding <float> binding, RenderContext context)
 {
     return(GetTerrainNode(context).DetailClipmap.LevelBias);
 }
Ejemplo n.º 20
0
 private static Texture2D GetTerrainHoleTexture(DelegateParameterBinding <Texture2D> binding, RenderContext context)
 {
     return(GetTerrainTile(context).HoleTexture ?? context.GraphicsService.GetDefaultTexture2DWhite());
 }
Ejemplo n.º 21
0
 private static float GetDetailEnableAnisotropicFiltering(DelegateParameterBinding <float> binding, RenderContext context)
 {
     return(GetTerrainNode(context).DetailClipmap.EnableAnisotropicFiltering ? 1 : 0);
 }
Ejemplo n.º 22
0
 private static int GetPassIndexAsInt32(DelegateParameterBinding <int> binding, RenderContext context)
 {
     return(Math.Max(context.PassIndex, 0));
 }