inline void generate_mipmaps_1d
(
    texture_type & Texture, fetch_func Fetch, write_func Write,
    typename texture_type::size_type BaseLayer, typename texture_type::size_type MaxLayer,
    typename texture_type::size_type BaseFace, typename texture_type::size_type MaxFace,
    typename texture_type::size_type BaseLevel, typename texture_type::size_type MaxLevel,
    filter Min
)
{
    typedef typename detail::interpolate<sampler_value_type>::type interpolate_type;
    typedef typename texture_type::texelcoord_type texelcoord_type;
    typedef typename texture_type::size_type size_type;
    typedef typename texelcoord_type::value_type component_type;
    typedef typename detail::filterBase<detail::DIMENSION_1D, texture_type, interpolate_type, samplecoord_type, fetch_func, texel_type>::filterFunc filter_func;

    filter_func const Filter = detail::get_filter<filter_func, detail::DIMENSION_1D, texture_type, interpolate_type, samplecoord_type, fetch_func, texel_type, sampler_value_type>(FILTER_NEAREST, Min, false);
    GLI_ASSERT(Filter);

    for(size_type Layer = BaseLayer; Layer <= MaxLayer; ++Layer)
        for(size_type Face = BaseFace; Face <= MaxFace; ++Face)
            for(size_type Level = BaseLevel; Level < MaxLevel; ++Level)
            {
                texelcoord_type const& DimDst = Texture.dimensions(Level + 1);
                samplecoord_type const& Scale = samplecoord_type(1) / samplecoord_type(max(DimDst - texelcoord_type(1), texelcoord_type(1)));

                for(component_type i = 0; i < DimDst.x; ++i)
                {
                    samplecoord_type const& SamplePosition(samplecoord_type(static_cast<typename samplecoord_type::value_type>(i)) * Scale);
                    texel_type const& Texel = Filter(Texture, Fetch, SamplePosition, Layer, Face, static_cast<sampler_value_type>(Level), texel_type(0));
                    Write(Texture, texelcoord_type(i), Layer, Face, Level + 1, Texel);
                }
            }
}
Beispiel #2
0
	inline coord_nearest<texelcoord_type, samplecoord_type> make_coord_nearest(texelcoord_type const & TexelDim, samplecoord_type const & SampleCoord)
	{
		samplecoord_type const TexelLast(samplecoord_type(TexelDim) - samplecoord_type(1));

		coord_nearest<texelcoord_type, samplecoord_type> Coord;
		Coord.Texel = texelcoord_type(round(SampleCoord * TexelLast));
		Coord.UseTexel = in_interval(Coord.Texel, texelcoord_type(0), TexelDim - 1);
		return Coord;
	}
		static texel_type call(texture_type const & Texture, fetch_type Fetch, samplecoord_type const & SampleCoordWrap, size_type Layer, size_type Face, interpolate_type Level, texel_type const & BorderColor)
		{
			size_type const LevelIndex = static_cast<size_type>(Level);
			texelcoord_type const TexelDim(Texture.dimensions(LevelIndex));
			samplecoord_type const TexelLast(samplecoord_type(TexelDim) - samplecoord_type(1));
			texelcoord_type const TexelCoord = texelcoord_type(round(SampleCoordWrap * TexelLast));
			typename texelcoord_type::bool_type const UseTexelCoord = in_interval(TexelCoord, texelcoord_type(0), TexelDim - 1);

			texel_type Texel(BorderColor);
			if(all(UseTexelCoord))
				Texel = Fetch(Texture, TexelCoord, Layer, Face, LevelIndex);

			return Texel;
		}
		static texel_type call(texture_type const & Texture, fetch_type Fetch, samplecoord_type const & SampleCoordWrap, size_type Layer, size_type Face, interpolate_type Level, texel_type const & BorderColor)
		{
			size_type const LevelIndex = static_cast<size_type>(Level);
			samplecoord_type const TexelLast(samplecoord_type(Texture.dimensions(LevelIndex)) - samplecoord_type(1));
			texelcoord_type const TexelCoord = texelcoord_type(round(SampleCoordWrap * TexelLast));

			return Fetch(Texture, TexelCoord, Layer, Face, LevelIndex);
		}
Beispiel #5
0
	GLI_FORCE_INLINE coord_linear<texelcoord_type, samplecoord_type> make_coord_linear(texelcoord_type const & TexelDim, samplecoord_type const & SampleCoord)
	{
		coord_linear<texelcoord_type, samplecoord_type> Coord;

		samplecoord_type const TexelDimF(TexelDim);
		samplecoord_type const TexelLast = TexelDimF - samplecoord_type(1);
		samplecoord_type const ScaledCoord(SampleCoord * TexelLast);
		samplecoord_type const ScaledCoordFloor(floor(ScaledCoord));
		samplecoord_type const ScaledCoordCeil(ceil(ScaledCoord));

		Coord.Blend = ScaledCoord - ScaledCoordFloor;
		Coord.TexelFloor = texelcoord_type(ScaledCoordFloor);
		Coord.TexelCeil = texelcoord_type(ScaledCoordCeil);

		return Coord;
	}